Skip to content

fix(fetchers): enforce SSRF safeguards in StackOverflow API fetcher#120

Merged
chaliy merged 2 commits into
mainfrom
2026-05-17-fix-stackoverflowfetcher-ssrf-policy-bypass
May 17, 2026
Merged

fix(fetchers): enforce SSRF safeguards in StackOverflow API fetcher#120
chaliy merged 2 commits into
mainfrom
2026-05-17-fix-stackoverflowfetcher-ssrf-policy-bypass

Conversation

@chaliy
Copy link
Copy Markdown
Contributor

@chaliy chaliy commented May 17, 2026

Motivation

  • A specialized StackOverflowFetcher created its own reqwest client and followed redirects without using the repository's DNS/redirect validation, weakening the default SSRF/egress protections for matching Stack Exchange URLs.
  • Restore the same resolve-then-validate and redirect constraints used by the DefaultFetcher while preserving the specialized fetcher's behavior.

Description

  • Disable automatic redirect following for Stack Exchange API requests by using redirect(reqwest::redirect::Policy::none()) for the API client.
  • Add constants for the API host/port (api.stackexchange.com:443) and use options.dns_policy.resolve_and_validate when dns_policy.block_private is enabled.
  • Pin the validated DNS result with ClientBuilder::resolve so the client connects only to the checked IP address.
  • Keep existing behaviors such as no_proxy() when respect_proxy_env is false and maintain API request/response handling and formatting logic.

Testing

  • Ran formatting with cargo fmt --all, which completed successfully.
  • Ran targeted tests with cargo test -p fetchkit stackoverflow, and the fetcher tests passed (9 passed; 0 failed).
  • Built and ran the test profile used by CI during the change, and the test run finished with no failing tests in the modified area.

Codex Task

@chaliy chaliy merged commit 601e506 into main May 17, 2026
11 checks passed
@chaliy chaliy deleted the 2026-05-17-fix-stackoverflowfetcher-ssrf-policy-bypass branch May 17, 2026 18:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant