Repository navigation
[Bugs] safe-fetch: redacted error data, refuse URL credentials, allowlist doc fixes - #1168
Conversation
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.
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
left a comment
There was a problem hiding this comment.
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
ProtocolErrorpath insafeFetchnow carriesloggableUrl(...)or no URL at all, including redirect hops and the timeout/fetch_error catch, andinFlightcorrectly avoids echoing the rawurlStr. 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.
Follow-ups to #1161, #1163 and #1166.
loggableUrl) for every failure reason and for each redirect hop.invalid_urlcarries no URL. DNS and fetch failures report a system error code only. A table test checks every reason.url_credentials_not_allowed, before lookup and on redirect hops.__resetAllowedOriginsCacheForTests()added for the one-time warning cache, and the tests now use it.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 inasset-url.ts.check-typesnow type-checkssrc/__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
ProtocolErrordata or URLs with embedded credentials will need to adjust.Overview
Hardens MCP
safeFetchso failure paths no longer leak secrets inProtocolErrordata or logs: URLs useloggableUrl(no query, fragment, or userinfo),invalid_urlomits the URL entirely, redirecthopsare redacted, HTTP failures useSTATUS_CODESinstead of the server reason phrase, and DNS/network errors expose only a validatedcode(notError.message).safeFetchnow rejects any hop whose URL contains userinfo asurl_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-onlyPASCAL_ALLOWED_ASSET_ORIGINSblockshttps:scene assets while non-allowlisted schemes still pass, and thatsafeFetchbehavior there is unchanged.@pascal-app/ifc-converteradds acheck-typesscript targetingsrc/__bench__viatsconfig.bench.json.Reviewed by Cursor Bugbot for commit 36791eb. Bugbot is set up for automated code reviews on this repo. Configure here.