fix: normalize IPv6 hostnames in preferredAuthUrl loopback filter - #210
Open
nidsnitesh wants to merge 1 commit into
Open
fix: normalize IPv6 hostnames in preferredAuthUrl loopback filter#210nidsnitesh wants to merge 1 commit into
nidsnitesh wants to merge 1 commit into
Conversation
The preferredAuthUrl function previously compared raw URL hostnames against bracketed strings like '[::1]' and '[::ffff:7f...'. Depending on URL parser implementations and IPv6 formats, bracket presence and IPv6 string representations (such as ::ffff:127.0.0.1 or expanded zero segments) could bypass the loopback check. This commit introduces an isLoopbackHost helper that strips outer brackets and checks IPv4/IPv6 loopback, unspecified, IPv4-mapped, and IPv4-compatible IP forms, preventing loopback URLs from being selected as authentication endpoints.
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
Fixes an issue where IPv6 loopback and IPv4-mapped loopback URLs (e.g.
[::1],[::ffff:127.0.0.1],[0:0:0:0:0:0:0:1]) could bypass loopback filtering inpreferredAuthUrl.Details
\x60preferredAuthUrl\x60 parses CLI terminal output to extract valid OAuth login verification URLs while filtering out local listening servers.
Previously, the code compared
new URL(url).hostnamedirectly against literal strings like"[::1]"or prefix"[::ffff:7f". Differences in bracket representation, IPv4-mapped notation (127.0.0.1vs7f00:1), and expanded zero-segments meant certain loopback URLs were not filtered out.Fix
isLoopbackHosthelper that strips outer brackets ([/]) and handles:127.0.0.0/8,0.0.0.0)::1,0:0:0:0:0:0:0:1)::,0:0:0:0:0:0:0:0)::ffff:127.x,::ffff:7f...,::127.x, etc.)sdk/typescript/tests-ts/auth.test.ts.