Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.
TypeScript acmeagentsai-agentscertificate-managementdevsecopsenvironment-variableskubernetesopen-sourcepampkipostgresprivate-caprivileged-access-managementsecret-managementsecret-managersecretssecrets-managementsecuritysecurity-toolsvault
misc: addressed
Sheen Capadnganf11a5a884888
diff --git a/backend/src/ee/services/ai-mcp-server/ai-mcp-server-service.ts b/backend/src/ee/services/ai-mcp-server/ai-mcp-server-service.tsindex 4158bb087a..859162d7ee 100644--- a/backend/src/ee/services/ai-mcp-server/ai-mcp-server-service.ts+++ b/backend/src/ee/services/ai-mcp-server/ai-mcp-server-service.ts@@ -18,7 +18,7 @@ import { BadRequestError, NotFoundError } from "@app/lib/errors";import { GatewayProxyProtocol } from "@app/lib/gateway";import { withGatewayV2Proxy } from "@app/lib/gateway-v2/gateway-v2";import { logger } from "@app/lib/logger";-import { ssrfSafeGet, ssrfSafePost, validateSsrfUrl } from "@app/lib/validator";+import { ssrfSafeGet, ssrfSafePost } from "@app/lib/validator";import { ActorType, AuthMethod } from "@app/services/auth/auth-type";import { TKmsServiceFactory } from "@app/services/kms/kms-service";import { KmsDataKey } from "@app/services/kms/kms-types";@@ -567,11 +567,6 @@ export const aiMcpServerServiceFactory = ({});}- // Validate registration_endpoint for SSRF protection (comes from attacker-controlled AS metadata)- if (!gatewayId) {- await validateSsrfUrl(authServer.registration_endpoint);- }-// Route DCR request through gateway when configuredconst { data: clientMetadata } = await gatewayRequest.post<TOAuthDynamicClientMetadata>(authServer.registration_endpoint,@@ -662,15 +657,7 @@ export const aiMcpServerServiceFactory = ({// Create gateway-aware request helper using the stored gatewayIdconst serverUrlObj = new URL(sessionData.serverUrl);const gatewayRequest = createGatewayAwareRequest(sessionData.gatewayId, serverUrlObj);- const isUsingGateway = Boolean(sessionData.gatewayId);-- // 2. Validate token endpoint for SSRF protection before making the request- // This is critical as the tokenEndpoint was stored from attacker-controlled AS metadata- if (!isUsingGateway) {- await validateSsrfUrl(sessionData.tokenEndpoint);- }-- // 3. Exchange code for tokens using the stored token endpoint+ // 2. Exchange code for tokens using the stored token endpointconst tokenParams: Record<string, string> = {grant_type: "authorization_code",code,diff --git a/backend/src/lib/validator/validate-url.ts b/backend/src/lib/validator/validate-url.tsindex 2f7a9d53be..3bdfbeb2e0 100644--- a/backend/src/lib/validator/validate-url.ts+++ b/backend/src/lib/validator/validate-url.ts@@ -142,9 +142,7 @@ export const isFQDN = (str: string, options: FQDNOptions = {}): boolean => {const MAX_SAFE_REDIRECTS = 5;type SsrfSafeRequestOptions = {- /** If true, skips SSRF validation (for gateway-proxied requests) */allowPrivateIps?: boolean;- /** Custom status validator for axios */validateStatus?: (status: number) => boolean;};@@ -226,18 +224,17 @@ export const ssrfSafeGet = async <T>(/*** Makes an HTTP POST request with SSRF protection.- * POST requests do not follow redirects for security reasons.- *- * Note: URL validation should be done by the caller before invoking this function.- * This function ensures redirects are blocked as a defense-in-depth measure.+ * Validates the URL before making the request and disables redirects.*/export const ssrfSafePost = async <T>(url: string,data: unknown,- config?: { headers?: Record<string, string> }+ options?: Pick<SsrfSafeRequestOptions, "allowPrivateIps"> & { headers?: Record<string, string> }): Promise<{ data: T }> => {+ await validateSsrfUrl(url, options);+return request.post<T>(url, data, {- ...config,+ headers: options?.headers,maxRedirects: 0});};