fix(web): share SSRF guard and isolate web.run sessions#4563
Conversation
Extract the DNS-pin + restricted-IP SSRF preflight from fetch_url into tools::web::guard and route web_run open/click fetches through the same path so private, loopback, metadata, and unsafe redirect targets are refused with consistent permission errors. Signed-off-by: Hunter B <hmbown@gmail.com>
Deduplicate DuckDuckGo/Bing HTML SERP parsers into tools::web::scrape so web_search and web_run share one implementation. The #964 single-domain spam heuristic now applies on the web_run path as well (intended behavior change); caller-side result caps and formatting are unchanged. Signed-off-by: Hunter B <hmbown@gmail.com>
Disable ambient proxies on DNS-pinned fetches, require trusted fake-IP hosts and benchmark CIDRs together, and keep private address classes fail-closed. Enforce web.run cache namespaces, exercise the real redirect and click paths, and replace the broad same-root spam heuristic with the known #964 spam-domain evidence so site-scoped and public-suffix results remain valid. Signed-off-by: Hunter B <hmbown@gmail.com>
Construct the fake-IP policy in one expression and serialize async web.run state fixtures with a Tokio mutex so the security regressions stay warning-free under all-target clippy. Signed-off-by: Hunter B <hmbown@gmail.com>
|
Bugbot is not enabled for your account, so this pull request was not reviewed. Enable Bugbot in the Cursor dashboard to get automatic reviews on future PRs. |
|
Claude finished @Hmbown's task in 2m 56s —— View job Claude finished the review
SummaryThis is a solid, well-tested security fix. I read the full diff against
Minor observations (non-blocking)
Verification noteI don't have permission to run CI on this PR was still running at review time ( |
Refresh the published W1 security branch after P1 landed so exact-head review and CI cover the current release base. Signed-off-by: Hunter B <hmbown@gmail.com>
|
Claude finished @Hmbown's task in 1m 8s —— View job Claude re-review (synchronize event)
SummaryNo new review needed on the security-relevant code — this push is a merge of I diffed the previously-reviewed head ( The only files touched are unrelated route/model-routing files pulled in from The one touch point worth double-checking was the merge conflict resolution in
My prior full review (posted earlier on this PR) still stands — no correctness bugs, no bypass of the SSRF invariants, redirect/session isolation and trusted-proxy fake-IP restriction all hold. Only the two non-blocking nits noted previously remain (missing CI statusCI was still in progress at review time: |
Summary
fetch_urlandweb.runpage fetches through one DNS-pinned SSRF guard198.18.0.0/15fake-IP placeholder rangeweb.runpages by state namespace and reject exact foreign-session refs for both open and clickweb_searchandweb.run, filtering the known spam family without dropping legitimate same-domain,.co.uk,github.io, or small result setsThis is the repaired W1 slice. It closes the proxy-rebinding, trusted-host private-address, cache namespace, redirect/click, and broad same-root heuristic findings from security review.
Security verification after merging current main
web.run: 22 passedfetch_url: 10 passedcargo fmt --all -- --checkcargo clippy -p codewhale-config -p codewhale-tui --all-targets --all-features --locked -- -D warningsgit diff --check origin/main...HEADThe complete locked workspace/all-features suite also passed before the initial push (TUI 7480 passed / 3 ignored; PTY 16 passed / 1 ignored; integration and doc tests green). Exact-head CI is required before merge.
Current exact head:
ab87b0eb645973f161356f37dcd41d12bc9a36d4.