Restrict cleartext credential URLs to loopback hostnames - #1848
Open
sylvesterkaczmarek wants to merge 1 commit into
Open
Restrict cleartext credential URLs to loopback hostnames#1848sylvesterkaczmarek wants to merge 1 commit into
sylvesterkaczmarek wants to merge 1 commit into
Conversation
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.
Summary
Restrict the credential subsystem's cleartext-HTTP exception to explicit loopback hostnames instead of textual URL prefixes.
_require_https()protects OAuth/federation token-exchange endpoints, whose request bodies can contain an assertion JWT or a long-lived refresh token. It currently allows local test endpoints with prefix checks such asurl.startswith("http://localhost")andurl.startswith("http://127.0.0.1").Those checks also accept non-local lookalike hosts including
http://localhost.evil.exampleandhttp://127.0.0.1.evil.example. A credential configuration using one of those hosts can therefore pass the HTTPS guard and send secret token-exchange material over cleartext HTTP to a remote endpoint.Fix
Parse the URL and validate its scheme and hostname separately.
localhost,127.0.0.1, or::1.localhost.remains supported for local testing.This preserves the existing localhost testing exception without allowing prefix-based hostname confusion.
Regression coverage
Adds focused tests covering valid HTTPS and loopback endpoints plus deceptive/non-loopback cleartext URLs, including:
localhost.evil.examplelocalhost-example.com127.0.0.1.evil.examplelocalhost@evil.exampleThe production change is confined to the hand-maintained credential URL validation helper.