Repository navigation
fix(websearch): block non-public URLs in page fetching - #1020
Open
SiyuanChenToDo wants to merge 1 commit into
Open
SiyuanChenToDo wants to merge 1 commit into
SiyuanChenToDo wants to merge 1 commit into
Conversation
fetch_page accepted arbitrary model-supplied URLs and passed them to Jina Reader, the direct urllib fallback, and the Playwright fallback without restricting the destination. Resolve hostnames and reject loopback, private, link-local, multicast, reserved, and cloud-metadata addresses; re-validate every HTTP redirect; and re-check document navigations in the Playwright fallback. Fixes modelscope#1018 Co-Authored-By: Claude Code <noreply@anthropic.com>
This branch has not been deployed
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
WebSearchTool.fetch_pageaccepted arbitrary model-supplied URLs and passedthem to Jina Reader, the direct urllib fallback, and the Playwright fallback
without restricting the destination. This allowed SSRF against loopback,
RFC1918, link-local, multicast, and cloud-metadata addresses (for example
169.254.169.254 and 100.100.100.200), and redirects were followed without
re-validation.
This adds
ms_agent/tools/url_safety.py:http/httpsURLs with a hostname;loopback, private, link-local, multicast, reserved, unspecified, or
otherwise non-global;
.localhost/.local/.internalsuffixes;
The check runs before Jina Reader, before the direct HTTP fallback, and on
every document navigation in the Playwright fallback, so a public URL cannot
redirect into an internal one.
ContentFetchernow documents that localfetchers must enforce this.
Fixes #1018
Test
pytest tests/tools/test_url_safety.py tests/tools/test_server_tools_smoke.py -q— 41 passed, 3 skippedflake8/yapf 0.32/py_compileon changed files — passedpublic/private DNS answers, metadata addresses, redirects, and the
Jina/Playwright entry points
AI assistance
Prepared with AI assistance (Claude Code); I reviewed the diff, ran the tests,
and can explain and defend the change.