fix: use exact match for loopback hosts in issuer URL validation#2089
Merged
fix: use exact match for loopback hosts in issuer URL validation#2089
Conversation
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.
felixweinberger
approved these changes
Feb 18, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
validate_issuer_url()usedstartswith("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 like127.0.0.1.evil.comor127.0.0.1something.example.comto bypass the HTTPS check.Additionally, the IPv6 loopback address
::1was not covered by the exemption, despite being handled correctly in the DNS rebinding protection elsewhere in the codebase.Fix
Replace the
startswithprefix 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 inlowlevel/server.pyandmcpserver/server.py.Also removed
pragma: no coverfrom the validation branches now that they have dedicated test coverage.AI Disclaimer