Skip to content

fix: prevent SSRF in fetch_url - #106

Merged
knight22-21 merged 1 commit into
knight22-21:mainfrom
mikemikimike:codex/issue-101-fetch-url-ssrf
Oct 17, 2026
Merged

knight22-21 merged 1 commit into
knight22-21:mainfrom
mikemikimike:codex/issue-101-fetch-url-ssrf

Conversation

@mikemikimike

Copy link
Copy Markdown
Contributor

Summary

fetch_url() allowed agent-directed requests to cloud metadata and private services. This PR validates DNS results before connecting and rechecks every redirect.

Changes

  • Restrict URLs to HTTP(S), reject credentials, and block non-public addresses, including private IPv4 values embedded in IPv6.
  • Pin connections to validated public IPs while preserving the original Host and HTTPS SNI; ignore environment proxy settings.
  • Revalidate redirect targets, cap redirects at five, and fall back only to another validated address after a connection error or timeout.

Tests

  • python -m pytest tests/test_phase11.py -k fetch_url -v --tb=short
  • python -m pytest tests/ -v --tb=short on Python 3.12 and 3.13: 842 passed, 1 skipped (the optional notebook suite requires nbformat).
  • python -m ruff check devagent/ tests/
  • python -m build
  • git diff --check

Compatibility / Known limitations

ruff format --check reports formatting differences that are also present in the unmodified baseline; no formatting-only changes are included. The repository CI workflow does not run this formatter check. mypy passes for devagent/tools/web_tools.py; checking the test module reports 9 pre-existing attribute errors because the Web Search test helpers are annotated as object.

Fixes #101: #101

@knight22-21
knight22-21 merged commit b99eb5b into knight22-21:main Oct 17, 2026
5 checks passed
@knight22-21

Copy link
Copy Markdown
Owner

Thanks for the fix, @mikemikimike! Pinning connections to validated public IPs, blocking non-public ranges, and re-validating redirect hops thoroughly addresses the SSRF vulnerability in \ etch_url.

If you find DevAgent useful, a ⭐ on the repo would mean a lot — no pressure though!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fetch_url() lacks private IP blocklist and redirect limit, enabling SSRF

2 participants