Repository navigation
fix(tools): check every webfetch redirect against the network policy - #529
Merged
Merged
Conversation
The allow and deny lists were applied to the first URL only; the client then followed redirects on its own, so an allowed host could send the fetch anywhere. Redirects are now followed by hand, each hop checked first, at most ten. The body is read in chunks up to 5 MB instead of whole, and a fetch times out after 60 s. Co-Authored-By: Claude Fable 5.2 <[email protected]>
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.
From the same source audit as #527 and #528.
Problem
webfetchcheckedsecurity.network_allowlist/network_denylistagainst the first URL only. The HTTP client then followed redirects on its own, so an allowed host could send the fetch to any other host. The body was also read whole into memory before the result was cut tomax_length, and a fetch had no overall timeout.Change
get_checkedfollows them by hand: each hop is checked against the policy before it is requested, at most 10 hops. The result reports the final URL.websearchkeeps the shared client and its behaviour.Not in this PR
A check of the resolved IP address (loopback, private, link-local) is still missing. It would also block local dev servers, so it needs its own setting.
Verification
crates/tools/src/web/fetch.rsmeasured locally with the web tests: no missed lines. The fullwhycodes-toolsrun could not finish locally because one GitHub API test fails in the offline measurement environment; CI measures the whole crate.🤖 Generated with Claude Code