Skip to content

Comments

fix: use exact match for loopback hosts in issuer URL validation#2089

Merged
maxisbey merged 1 commit intomainfrom
fix/validate-issuer-url-loopback-check
Feb 18, 2026
Merged

fix: use exact match for loopback hosts in issuer URL validation#2089
maxisbey merged 1 commit intomainfrom
fix/validate-issuer-url-loopback-check

Conversation

@maxisbey
Copy link
Contributor

Problem

validate_issuer_url() used startswith("127.0.0.1") to exempt loopback addresses from the HTTPS requirement. This is a string prefix match, not an exact equality check, so it incorrectly allowed non-loopback hostnames like 127.0.0.1.evil.com or 127.0.0.1something.example.com to bypass the HTTPS check.

Additionally, the IPv6 loopback address ::1 was not covered by the exemption, despite being handled correctly in the DNS rebinding protection elsewhere in the codebase.

Fix

Replace the startswith prefix check with an exact match against the set of loopback hosts (localhost, 127.0.0.1, [::1]), consistent with the approach used in the DNS rebinding auto-config in lowlevel/server.py and mcpserver/server.py.

Also removed pragma: no cover from the validation branches now that they have dedicated test coverage.

AI Disclaimer

validate_issuer_url() used startswith("127.0.0.1") to exempt loopback
addresses from the HTTPS requirement. This prefix match incorrectly
allowed non-loopback hostnames like 127.0.0.1.evil.com or
127.0.0.1something.example.com to bypass the HTTPS check.

Replace with an exact match against the set of loopback hosts
(localhost, 127.0.0.1, [::1]), consistent with the DNS rebinding
protection elsewhere in the codebase. This also adds the missing
IPv6 loopback (::1) exemption.

Remove pragma: no cover from validation branches now that they
have dedicated test coverage.
@maxisbey maxisbey merged commit 0e96aec into main Feb 18, 2026
30 checks passed
@maxisbey maxisbey deleted the fix/validate-issuer-url-loopback-check branch February 18, 2026 19:40
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.

2 participants