Skip to content

fix(loadResource): re-validate URL policy after redirects - #2503

Open
jatinsingh1603 wants to merge 1 commit into
ChromeDevTools:mainfrom
jatinsingh1603:fix/redirect-bypasses-url-allow-blocklist
Open

fix(loadResource): re-validate URL policy after redirects#2503
jatinsingh1603 wants to merge 1 commit into
ChromeDevTools:mainfrom
jatinsingh1603:fix/redirect-bypasses-url-allow-blocklist

Conversation

@jatinsingh1603

Copy link
Copy Markdown

Summary

loadResource() only validated the allow/block list against the initial request URL. If a URL that passed policy responded with an HTTP redirect (e.g. a 302), the built-in fetch(..., {redirect: 'follow'}) behavior followed it to the final destination without re-checking that destination against the configured policy. An allowed origin could therefore redirect to a URL the policy was specifically configured to block.

This PR follows redirects manually (redirect: 'manual') and re-validates every hop's target against #validateUrlNotBlocked / #validateUrlAllowed before following it.

Fixes #2502

Test plan

  • Added unit tests in tests/McpContext.test.ts covering: redirect target rejected by blocklist, redirect target rejected by allowlist, and a normal allowed redirect chain still resolving successfully.
  • npm run typecheck
  • npm run check-format
  • node scripts/test.js tests/McpContext.test.ts (all passing)

@google-cla

google-cla Bot commented Aug 8, 2026

Copy link
Copy Markdown

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@jatinsingh1603

Copy link
Copy Markdown
Author

recheck

loadResource() only checked the allow/block list against the initial
request URL. An allowed origin could redirect to a blocked (or
otherwise disallowed) destination and the fetch would follow it
without any further policy check.

Fetch redirects are now followed manually so each hop's target is
re-validated against the allow/block list before it is followed.

Fixes ChromeDevTools#2502
@jatinsingh1603
jatinsingh1603 force-pushed the fix/redirect-bypasses-url-allow-blocklist branch from 8122b31 to 159d91f Compare August 8, 2026 07:06
@jatinsingh1603

Copy link
Copy Markdown
Author

recheck

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

URL allow/block policy not re-validated after HTTP redirect in loadResource

1 participant