Block 127.0.0.0/8 and cloud-metadata hostnames in OAuth2 discovery SSRF check#431
Open
adilburaksen wants to merge 2 commits into
Open
Block 127.0.0.0/8 and cloud-metadata hostnames in OAuth2 discovery SSRF check#431adilburaksen wants to merge 2 commits into
adilburaksen wants to merge 2 commits 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
validateDiscoveryUrl(core/src/auth/oauth2/oauth2_discovery.ts) gates thefetch()in OAuth2 metadata discovery against SSRF. Following the SSRF hardening in #354, two reachable internal targets remain allowed:127.0.0.0/8loopback — the check is exact-matchhost === '127.0.0.1', sohttps://127.0.0.2(and the rest of the range) is allowed.normaliseHostname()even un-maps[::ffff:7f00:2]→127.0.0.2, which then passes.metadata.google.internal(andmetadata.goog) is allowed even though169.254.169.254is blocked.The handler's own test suite asserts that loopback/
localhostdiscovery URLs must be rejected, so blocking these is by-design; the existing fix is just incomplete.Change
127.prefix check (whole127.0.0.0/8).metadata.google.internalandmetadata.goog.127.0.0.2,metadata.google.internal,metadata.goog.Existing allowed hosts are unaffected.