fix: prevent token leak via URL userinfo host confusion#2000
Open
MIchaelMainer wants to merge 2 commits into
Open
fix: prevent token leak via URL userinfo host confusion#2000MIchaelMainer wants to merge 2 commits into
MIchaelMainer wants to merge 2 commits into
Conversation
adrian05-ms
reviewed
Jun 16, 2026
| throw new GraphClientError("Unable to parse the URL: " + path); | ||
| } | ||
| // Reject URLs with userinfo to prevent host-confusion attacks | ||
| if (parsedUrl.username !== "" || parsedUrl.password !== "") { |
There was a problem hiding this comment.
is it possible for username to be undefined? what happens if it does?
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
Changes Made
Replaced the hand-rolled indexOf(":") host extraction with new URL() parsing:
Added new URL() validation at the entry point of path parsing:
Motivation
A vulnerability in the Microsoft Graph SDK for JavaScript allows an attacker to exploit a host-classification bug in the
isValidEndpointfunction, causing the SDK to misclassify attacker-controlled URLs as valid Microsoft Graph endpoints. This results in the SDK attaching and sending the caller's Microsoft Graph bearer token to the attacker's host. The issue is confirmed in version 3.0.7 and earlier, specifically when using thenode-fetchruntime. The root cause is improper URL parsing that fails to correctly identify the real host when userinfo is included in the URL. The vulnerability can lead to the exposure of sensitive tokens, which can be replayed against Microsoft Graph services within the token's granted scopes.Test plan
Regression tests added