Improve SSRF IP validation and add protocol allowlist#18518
Merged
FelixMalfait merged 3 commits intomainfrom Mar 10, 2026
Merged
Improve SSRF IP validation and add protocol allowlist#18518FelixMalfait merged 3 commits intomainfrom
FelixMalfait merged 3 commits intomainfrom
Conversation
Node.js URL parser normalizes IPv4-mapped IPv6 addresses to hex form (e.g. ::ffff:169.254.169.254 → ::ffff:a9fe:a9fe) before they reach createConnection. The regex-based isPrivateIp only matched dotted-decimal form, so the hex form bypassed all SSRF protection. Replace regex-based IP range matching with net.BlockList for CIDR-based range checking. Extract embedded IPv4 from both hex and dotted forms of IPv4-mapped IPv6 before checking. This eliminates the entire class of string normalization bypass vulnerabilities. Made-with: Cursor
…ol validation Add missing non-routable IP ranges to the BlockList: carrier-grade NAT (100.64.0.0/10), IANA special purpose (192.0.0.0/24), documentation networks (192.0.2.0/24, 198.51.100.0/24, 203.0.113.0/24), benchmarking (198.18.0.0/15), multicast (224.0.0.0/4), and reserved (240.0.0.0/4). Add protocol allowlist (http/https only) as an axios interceptor in SecureHttpClientService and as a Zod refinement in the HTTP tool schema, blocking non-HTTP schemes like ftp: and file: as defense-in-depth. Made-with: Cursor
Contributor
There was a problem hiding this comment.
Your free trial has ended. If you'd like to continue receiving code reviews, you can add a payment method here.
Contributor
There was a problem hiding this comment.
1 issue found across 5 files
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="packages/twenty-server/src/engine/core-modules/secure-http-client/secure-http-client.service.ts">
<violation number="1" location="packages/twenty-server/src/engine/core-modules/secure-http-client/secure-http-client.service.ts:67">
P1: Protocol allowlist can be bypassed when `requestConfig.url` is an empty string because validation is skipped before checking `baseURL`.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
packages/twenty-server/src/engine/core-modules/secure-http-client/secure-http-client.service.ts
Outdated
Show resolved
Hide resolved
Empty string url with ?? skips validation since "" is not nullish, allowing a non-http baseURL to go unchecked. Using || ensures the baseURL is checked when url is empty. Made-with: Cursor
Member
Author
|
🚀 Preview Environment Ready! Your preview environment is available at: http://bore.pub:2695 This environment will automatically shut down after 5 hours. |
thomtrp
approved these changes
Mar 10, 2026
|
Hey @FelixMalfait! After you've done the QA of your Pull Request, you can mark it as done here. Thank you! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
isPrivateIpwith Node.jsnet.BlockListfor CIDR-based range checking, which properly handles all IPv4-mapped IPv6 representations (both dotted-decimal and hex forms)100.64.0.0/10), IANA special purpose, documentation networks, benchmarking, multicast, and reserved rangesSecureHttpClientServiceand as a Zod refinement in the HTTP tool schemaTest plan
ftp:andfile:schemesMade with Cursor