fix(vl): re-validate every redirect hop when fetching image_url (SSRF #4761)#4762
Closed
Anai-Guo wants to merge 2 commits into
Closed
fix(vl): re-validate every redirect hop when fetching image_url (SSRF #4761)#4762Anai-Guo wants to merge 2 commits into
Anai-Guo wants to merge 2 commits into
Conversation
_load_http_url ran the private-IP guard (_is_safe_url) only on the original URL, then fetched with allow_redirects=True. requests follows a 302 without re-checking, so a public host that passes the guard could redirect to an internal or cloud-metadata address and have its bytes returned through the image pipeline. Follow redirects manually and run _is_safe_url on each Location before following it. Fixes InternLM#4761
Author
|
Pushed a follow-up to fix the failing unit test: the existing |
Collaborator
|
Hi, thanks for the PR. Since #4734 already addresses this issue and has broader test coverage for redirect/allowlist edge cases, I am going to close this one in favor of that. |
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.
Summary
Fixes #4761 — an unauthenticated SSRF in the multimodal
image_urlfetch path. The private-IP guard_is_safe_urlwas applied only to the original URL, after which the response was fetched withallow_redirects=True.requestsfollows a302Locationwithout re-running the guard, so an attacker-controlled public host (which passes the guard) can redirect tohttp://127.0.0.1:.../orhttp://169.254.169.254/...and have the internal/metadata bytes returned through the image pipeline. On the default0.0.0.0+ no-auth server, any client of a vision deployment can reach this.Fix
_load_http_urlnow follows redirects manually withallow_redirects=False, and re-runs_is_safe_urlon each resolvedLocationbefore following it. The redirect budget (max_redirects = 3) is preserved. Non-http(s) schemes are already rejected by_is_safe_url, so a redirect can no longer switch to a disallowed scheme either.Verification
Local unit-level reproduction against the changed function (no GPU / model download):
302-redirects to an internal target → now blocked at the redirect hop withURL is blocked for security reasons: ...(previously the internal bytes were returned).This keeps the change tight to the reported redirect-bypass. Connection-level IP pinning (DNS-rebinding hardening) and default-auth are separate concerns noted in the issue and are intentionally left out of scope here.
🤖 Generated with Claude Code