Repository navigation
fix(security): require an OAuth state on the callback (GHSA-75j5-qp3x-mx37) - #164
Merged
Merged
Conversation
…-mx37) get_auth_url emitted no state and the callback validated none (RFC 6749 10.12), so any page that could reach the local callback server could hand it an authorization code of the attacker's choosing. A random state is now minted per authorization request, carried in the auth URL and required on the callback: missing, mismatched or replayed state means the code is rejected and never stored. The server also binds 127.0.0.1 explicitly and shuts down once it has handled a valid callback rather than idling out the 180s window. The report's fourth item (random high port) is not actionable: Meta validates redirect URIs against the list registered on the app, so the flow only works on pre-registered ports. Bumps to 1.0.124 and documents the advisory in SECURITY.md.
PM-Labs
pushed a commit
to pmlabs-org/mcp-meta-ads
that referenced
this pull request
Oct 11, 2026
…-mx37) (pipeboard-co#164) get_auth_url emitted no state and the callback validated none (RFC 6749 10.12), so any page that could reach the local callback server could hand it an authorization code of the attacker's choosing. A random state is now minted per authorization request, carried in the auth URL and required on the callback: missing, mismatched or replayed state means the code is rejected and never stored. The server also binds 127.0.0.1 explicitly and shuts down once it has handled a valid callback rather than idling out the 180s window. The report's fourth item (random high port) is not actionable: Meta validates redirect URIs against the list registered on the app, so the flow only works on pre-registered ports. Bumps to 1.0.124 and documents the advisory in SECURITY.md.
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.
Closes the still-open item of GHSA-75j5-qp3x-mx37, reported by @Gal3m and @mohammad228.
Status of the three reported weaknesses
GET /tokendisclosed the stored auth artifactstateminted or validatedChanges
stateis minted per authorization request (new_oauth_state()), carried in the URL built byget_auth_url(), and required by the callback. A code whosestateis missing, mismatched, or replayed is rejected and never reachestoken_container. Comparison issecrets.compare_digest; a failed check does not burn the state, a successful one does.127.0.0.1explicitly instead of whateverlocalhostresolves to.shutdown()is not called from the serving thread).tests/test_callback_server_state.py; the two existing success-path tests intest_callback_server_xss.pynow mint a state first.The report's fourth suggestion — bind a random high port — is not actionable. Meta validates the redirect URI against the list registered on the app, so the flow only works on pre-registered ports;
8080-8089is a requirement, not an oversight. Thestatecheck is what makes an unsolicited callback useless.Finding: the local OAuth flow has been broken since 0.4.4
Worth a separate decision, so flagging rather than fixing here.
AUTH_RESPONSE_TYPE = "token"(implicit flow), so Meta returns the credential in the URL fragment — which never reaches the server. Commita3fa12d(2025-07-17, "simplify callback server", first released in 0.4.4) removed the JS that readlocation.hashand thetoken_container["token"]write that went with it, but left the response type alone. Since then:?code=branch cannot fire, because Meta never sends a code in this mode;token_container["token"], sologin()polls a key that staysNoneand times out after 5 minutes;--loginor theget_login_linktool authorizes in the browser and lands on the "Unexpected Response" page.So the
statecheck added here guards a branch that is currently unreachable. It is still correct — it is required the moment the flow is repaired, and it is what the advisory asks for — but the flow itself needs a decision: repair it (switch toresponse_type=codewith an exchange step, or restore fragment extraction) or remove the local login path and lean onMETA_ACCESS_TOKEN/ the hosted MCP, which is already what the authentication-required message recommends.Full suite: 558 passed, 9 skipped.