Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions workflow/packages/backend/api/src/app/ai/ai-provider-proxy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,21 @@ export const proxyController: FastifyPluginAsyncTypebox = async (
request.headers as Record<string, string | string[] | undefined>,
aiProvider.config.defaultHeaders,
)
// --- SECURITY FIX: SSRF PROTECTION ---
// Prevent access to internal/private IP addresses (e.g., Cloud Metadata)
const parsedUrl = new URL(url);
const forbiddenIps = ['127.0.0.1', '169.254.169.254', 'localhost'];
const isPrivateIp = (hostname: string) => {
return forbiddenIps.includes(hostname) ||
hostname.startsWith('10.') ||
hostname.startsWith('192.168.') ||
hostname.startsWith('172.');
};

if (isPrivateIp(parsedUrl.hostname)) {
throw new Error("Security Alert: Access to internal network resources is restricted.");
}
// --- END SECURITY FIX ---
const response = await fetch(url, {
method: request.method,
headers: cleanHeaders,
Expand Down