Fix: prevent ssrf and Input type confusion issues multiple components #5336
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description Of Fixes
This request fixes an addresses multiple security vulnerabilities related to Server-Side Request Forgery (SSRF) and unvalidated user input handling across several files within the FlowiseAI codebase. These issues could allow attackers to manipulate outgoing requests, access unintended internal resources, or exploit type confusion to bypass sanitization logic. Each fix introduces proper input validation, allow-list enforcement, and type-safety improvements to ensure robust protection against such threats.
1. Secure Tenant ID Validation in Azure SSO
packages/server/src/enterprise/sso/AzureSSO.tsThetestSetupstatic method previously allowed unvalidated user input (tenantID) to control the hostname in an outgoing HTTP request to Microsoft Azure.This could enable SSRF attacks by redirecting requests to unintended endpoints or internal services.
Fix implemented:
tenantIDbefore constructing the authentication URL..onmicrosoft.com.2. Outbound Request Allow-List for Secure Fetch
packages/components/src/httpSecurity.tsPreviously, user-supplied URLs were used directly in outbound HTTP requests, protected only by a deny-list. This approach left room for bypass attacks or indirect SSRF through redirects.Fix implemented:
secureFetchfunction for both the initial URL and all redirects.HTTP_ALLOW_LIST, defining a comma-separated list of allowed domains or wildcard patterns (e.g.,*.example.com).httpandhttpsonly.3. Validation of Chatflow IDs in Evaluation Service
packages/server/src/services/evaluations/index.tsThe service previously used unvalidatedchatflowIdvalues to construct request URLs, creating a potential SSRF vector if arbitrary IDs were supplied.Fix implemented:
chatflowIdbefore executingEvaluationRunner.runEvaluations.4. Type-Safe Validation for Feedback Parameters
packages/server/src/controllers/chat-messages/index.tsCertain query parameters (feedbackType) were assumed to be strings but could be arrays due to crafted malicious requests. This type confusion could bypass sanitization logic.Fix implemented:
feedbackTypeparameters.ChatMessageRatingTypeenum values are accepted.5. Runtime Type Enforcement for Storage Prefix Parameters
packages/components/src/storageUtils.tsUnvalidatedprefixparameters could cause unsafe string operations or logic errors if arrays or non-string types were passed in.Fix implemented:
prefixis always a valid string before operations likesubstringor concatenation._cleanEmptyS3Foldersfor minimal code impact and maximum safety.These changes collectively harden the application against:
All fixes follow the principle of defense in depth, ensuring that user inputs are validated, sanitized, and restricted at the earliest possible stage.
secureFetchcorrectly blocks disallowed domains.Additional Notes
HTTP_ALLOW_LISTcan be provided via environment variables or config files.