FIX: Add destination allowlist before forwarding Bearer credential to Graph in EntraAuthMiddleware#2183
Open
jsong468 wants to merge 1 commit into
Open
FIX: Add destination allowlist before forwarding Bearer credential to Graph in EntraAuthMiddleware#2183jsong468 wants to merge 1 commit into
jsong468 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.
Description
EntraAuthMiddleware._resolve_excess_groups_asyncforwards the user's Bearer credential to a host derived from token claims (_claim_sources.src1.endpoint) and from the response body (@odata.nextLink) without an explicit allowlist. There is no check that these values resolve tograph.microsoft.combefore the credentialed request is made. This adds an explicit host + scheme allowlist before each request.This is not an exploitable bug today: the endpoint originates from a signature-validated JWT and pagination links come from a TLS-authenticated Graph response. The allowlist makes the safety property local and robust against future changes and hardens the currently-dead path before it is re-enabled (see the existing
NOTEabout the Graph audience migration).Changes
pyrit/backend/middleware/auth.py_GRAPH_HOSTSclass constant ({"graph.microsoft.com"}_is_trusted_graph_url()helper usingurlparse(...).hostname(correctly handles userinfo/port, sograph.microsoft.com@evil.com-style spoofs are rejected).POSTendpoint: refuse + log + return[]if untrusted.@odata.nextLinkin the pagination loop: refuse + log + break if untrusted.Tests
tests/unit/backend/test_auth_middleware.py_is_trusted_graph_url(legit Graph URLs vs.http://, wrong host, suffix-spoof, userinfo-spoof, empty).[]and makes no HTTP request (token is never forwarded).