Skip to content

[Bugs] safe-fetch: redacted error data, refuse URL credentials, allowlist doc fixes - #1168

Merged
Aymericr merged 6 commits into
mainfrom
cursor/safe-fetch-redact-error-data-5540
Oct 27, 2026
Merged

Aymericr merged 6 commits into
mainfrom
cursor/safe-fetch-redact-error-data-5540

Conversation

@Aymericr

@Aymericr Aymericr commented Oct 27, 2026 •

Copy link
Copy Markdown
Member

Follow-ups to #1161, #1163 and #1166.

  • mcp/safe-fetch: error data now carries only redacted URLs (loggableUrl) for every failure reason and for each redirect hop. invalid_url carries no URL. DNS and fetch failures report a system error code only. A table test checks every reason.
  • mcp/safe-fetch: request URLs with userinfo are refused as url_credentials_not_allowed, before lookup and on redirect hops.
  • core: __resetAllowedOriginsCacheForTests() added for the one-time warning cache, and the tests now use it.
  • docs: an all-invalid or whitespace-only allowlist admits no https: origin. Local, blob, data-image and relative assets are still accepted. The CHANGELOG notes that safeFetch is unchanged there. Also fixes a comment line break in asset-url.ts.
  • ifc-converter: check-types now type-checks src/__bench__.

Locally, lint, skills validation, check-types and all package tests pass.


Note

Medium Risk
Changes MCP SSRF fetch validation and what agents see in errors; operators relying on full URLs in ProtocolError data or URLs with embedded credentials will need to adjust.

Overview
Hardens MCP safeFetch so failure paths no longer leak secrets in ProtocolError data or logs: URLs use loggableUrl (no query, fragment, or userinfo), invalid_url omits the URL entirely, redirect hops are redacted, HTTP failures use STATUS_CODES instead of the server reason phrase, and DNS/network errors expose only a validated code (not Error.message).

safeFetch now rejects any hop whose URL contains userinfo as url_credentials_not_allowed (before DNS), including redirect targets that embed credentials.

Core adds test-only __resetAllowedOriginsCacheForTests() so allowlist warning cache behavior is assertable; CHANGELOG / CROSS_CUTTING clarify that a whitespace-only PASCAL_ALLOWED_ASSET_ORIGINS blocks https: scene assets while non-allowlisted schemes still pass, and that safeFetch behavior there is unchanged.

@pascal-app/ifc-converter adds a check-types script targeting src/__bench__ via tsconfig.bench.json.

Reviewed by Cursor Bugbot for commit 36791eb. Bugbot is set up for automated code reviews on this repo. Configure here.

Node sends user:pass@ in a request URL as a Basic Authorization header.
safeFetch now refuses such URLs, on the first hop or a redirect, as
url_credentials_not_allowed before any lookup.
Every failure's data.url is now loggableUrl() (scheme, host, truncated
path), as is each too_many_redirects hop; invalid_url carries no URL.
DNS and fetch failures report the system error code instead of its
message. A table test checks that no reason's error data contains a
query string, fragment or userinfo.
__resetAllowedOriginsCacheForTests() clears the one-value cache, and the
core and safe-fetch tests reset it before each test instead of choosing
distinct allowlist values to get warnings logged again.
…hing

Scene asset URLs that never consult the allowlist (asset://, blob:,
data:image/, app-relative paths, localhost http) are still accepted, so
CROSS_CUTTING, the changelog and the asset-url doc say "no https:
origin". The changelog no longer reads as if safeFetch changed for a
whitespace-only value; it already refused every fetch. Fixes a stray
line break in the allowedOriginsFrom comment.
src/__bench__ is out of the build's tsconfig, so check-types now runs
tsc on tsconfig.bench.json, which turbo's check-types task picks up.
@Aymericr Aymericr added the bot:bugs label Oct 27, 2026 — with Cursor
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 27, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-27T01:56:43.537577Z 94705c1 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@Aymericr Aymericr left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maintainer triage: reviewed, looks good to merge once CI is green and Security has signed off (this touches how outbound fetch errors handle secrets in URLs, so it needs a Security approval under the fleet rules).

What I checked:

  • Every ProtocolError path in safeFetch now carries loggableUrl(...) or no URL at all, including redirect hops and the timeout/fetch_error catch, and inFlight correctly avoids echoing the raw urlStr.
  • errorCode() only passes through codes matching ^[A-Z0-9_]{1,64}$, so an error message can't smuggle the URL back in.
  • Userinfo is refused before DNS, on the first hop and on redirects, and the test asserts no lookup happens.
  • The table test covers every reason.

One non-blocking nit: __resetAllowedOriginsCacheForTests is exported from the public @pascal-app/core/schema barrel. Consider tagging it @internal (or importing it from ./asset-url directly where possible) so it doesn't look like supported API.

No UI change, so no screenshots needed. No architect-harness content here.

statusText came from the server's reason phrase, which a server can set
to anything, including the requested URL. It is now
http.STATUS_CODES[status]. The response helper takes a reason phrase,
and the redaction table has a row where the server echoes the URL and
credentials in it.
@Aymericr
Aymericr merged commit 57dc659 into main Oct 27, 2026
5 checks passed
@Aymericr
Aymericr deleted the cursor/safe-fetch-redact-error-data-5540 branch October 27, 2026 12:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants