Repository navigation
[Bugs] safe-fetch: IPv6 special ranges, DNS abort, log trimming - #1157
Merged
Merged
Conversation
The IETF protocol assignments block was only partly covered (Teredo and benchmarking). The whole /23 is now blocked, except 2001:1::1-3, 2001:3::/32, 2001:4:112::/48, 2001:20::/28 and 2001:30::/28, which IANA lists as globally reachable.
… a path Blocked-fetch logs now cap the path at 128 characters. data: and javascript: URLs carry their payload in the path, so blocked non-http(s) schemes log only scheme and host.
…lowlisted A public host's other services (SSH, Redis, admin ports) are no longer reachable through the image fetch. An origin listed in PASCAL_ALLOWED_ASSET_ORIGINS may still name any port.
dns.lookup cannot be cancelled, so a resolver that never answered held the fetch past its timeout. The lookup now races the fetch's abort signal and fails as fetch_timeout.
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
Aymericr
commented
Oct 27, 2026
Aymericr
left a comment
Member
Author
There was a problem hiding this comment.
Maintainer review: looks good to me.
- The
2001::/23carve-outs match the IANA special-purpose registry (2001:1::1–3 anycast, 2001:3::/32 AMT, 2001:4:112::/48 AS112, 2001:20::/28 ORCHIDv2, 2001:30::/28 drone remote ID), and the tests cover both edges, including2001:200::1just past the block. - Racing the DNS lookup against the abort signal is the right fix, since
dns.lookupcan't be cancelled. Rethrowing onsignal.abortedkeeps it reported asfetch_timeoutrather thandns_lookup_failed. - The port check runs in
assertAllowedUrl, so redirect hops are covered too, and allowlisted origins can still use any port. - Log trimming for
data:/javascript:URLs is a nice cleanup.
No visual change, so screenshots aren't needed. This is SSRF hardening, so I'm asking Security to approve it. It can merge once CI is green and that approval is in.
3 of 4 tasks
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.
What does this PR do?
Follow-up to #1154 for
packages/mcp/src/lib/safe-fetch.ts, with one commit per finding:2001::/23. Blocks the whole IETF protocol assignments block. Before this, only Teredo (2001::/32) and benchmarking (2001:2::/48) were blocked. The entries IANA lists as globally reachable stay allowed:2001:1::1–2001:1::3,2001:3::/32,2001:4:112::/48,2001:20::/28and2001:30::/28.dns.lookupcan't be cancelled, so before this a resolver that never answered kept the fetch open pasttimeoutMs. It now fails asfetch_timeoutand never sends a request.PASCAL_ALLOWED_ASSET_ORIGINSmay still name any port, since the operator has trusted it explicitly. The rejection reason isurl_port_not_allowed.loggableUrlcaps the logged path at 128 characters. Blocked non-http(s) URLs such asdata:andjavascript:carry their payload in the path, so they now log only the scheme and host (for exampledata:orftp://a.example).How to test
cd packages/mcp && bun test src/lib/safe-fetch.test.ts: all 38 tests pass.main'ssafe-fetch.ts:blocks IETF protocol assignments 2001::/23a DNS lookup that never answers still times out: uses Bun fake timers with a resolver that never settles.only web ports are fetched unless the origin is allowlistedtruncates long logged paths and logs only scheme and host for other schemeslogs blocked URLs without query, fragment or userinfoallows public addressesnow also covers the2001::/23exceptions and2001:200::1, the first address past the block.turbo run test check-types --filter=@pascal-app/mcp.Screenshots / screen recording
N/A — non-visual change
Checklist
bun devbun checkto verify)mainbranchNote
High Risk
Changes security-critical URL fetch validation for user-supplied image URLs; stricter port and IPv6 rules may block previously allowed asset URLs unless allowlisted.
Reviewed by Cursor Bugbot for commit bb56dd8. Bugbot is set up for automated code reviews on this repo. Configure here.