Skip to content

fix(http_policy): allowlist dial host for SSRF - #58

Merged
ManintheCrowds merged 1 commit into
mainfrom
fix/http-policy-dial-host-ssrf
Oct 7, 2026
Merged

ManintheCrowds merged 1 commit into
mainfrom
fix/http-policy-dial-host-ssrf

Conversation

@ManintheCrowds

Copy link
Copy Markdown
Owner

Summary

  • Close host-allowlist bypass (\@ / userinfo): reject unsafe URL shape, allowlist the host requests will dial (prepare().url), require parse/dial parity.
  • Apply private/link-local refusal to antigen/registry/contribute fetches, with exact allowlisted loopback exception (A4).
  • Wire assert_localhost_fetch_url and 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
  • Confirm \@ URL with allowlist example.com fails before Session get/post (no L402 Authorization attached)
  • Confirm http://127.0.0.1/... still works when 127.0.0.1 is allowlisted
  • Confirm private/link-local literals stay denied even if named on the allowlist

Reject \\ and userinfo; compare urlparse vs requests prepare host;
block private/link-local except exact allowlisted loopback.

Co-authored-by: Cursor <[email protected]>
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 7, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-07T04:31:47.334909Z ff8ac35 PR opened
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment thread src/scp/http_policy.py
Comment on lines +96 to +100
# 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

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

@ManintheCrowds
ManintheCrowds merged commit 69dc756 into main Oct 7, 2026
5 checks passed
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.

1 participant