Repository navigation
fix(http_policy): allowlist dial host for SSRF - #58
Conversation
Reject \\ and userinfo; compare urlparse vs requests prepare host; block private/link-local except exact allowlisted loopback. Co-authored-by: Cursor <[email protected]>
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: ff8ac357cd
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| # A4: exact allowlisted loopback may pass; other blocked ranges stay refused. | ||
| if dial in _LOOPBACK_HOSTS: | ||
| return True | ||
| if _hostname_is_blocked(dial): | ||
| return False |
There was a problem hiding this comment.
Resolve hostname targets before the private-range check
For an allowlisted DNS hostname, dial remains only the textual hostname, so _hostname_is_blocked never evaluates the address that requests will connect to. If an allowlisted hostname resolves (or DNS-rebinds) to 127.0.0.1, a link-local address, or another private target, this branch returns True and the fetch/POST proceeds, bypassing the newly added private-target refusal. Resolve and validate the destination addresses (and ensure the connection uses the validated address) rather than applying the guard only to IP literals.
Useful? React with 👍 / 👎.
Summary
\@/ userinfo): reject unsafe URL shape, allowlist the hostrequestswill dial (prepare().url), require parse/dial parity.assert_localhost_fetch_urland HTTP localhost scheme checks through the same dial-host helpers.Test plan
PYTHONPATH=src pytest tests/test_http_policy_host_allowlist.py tests/test_appsec_host_allowlists.py -q\@URL with allowlistexample.comfails before Session get/post (no L402 Authorization attached)http://127.0.0.1/...still works when127.0.0.1is allowlisted