fix: add optional API key authentication to all mutating HTTP endpoints#91
Closed
Joshua-Medvinsky wants to merge 1 commit into
Closed
fix: add optional API key authentication to all mutating HTTP endpoints#91Joshua-Medvinsky wants to merge 1 commit into
Joshua-Medvinsky wants to merge 1 commit into
Conversation
Introduces an api_key parameter to create_flask_app(). When set, every POST route (/a2a, /stream, /tasks/send, /tasks/cancel, /) requires an Authorization: Bearer <token> header and returns 401 otherwise. Read-only GET routes (agent card, health, metadata) are intentionally left unauthenticated so service-discovery clients can operate without credentials, consistent with the A2A spec.
Author
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
api_keyparameter tocreate_flask_app()/a2a,/stream,/a2a/tasks/send,/a2a/tasks/cancel,/) enforceAuthorization: Bearer <token>authenticationapi_keysee no behaviour changeVulnerability
All POST endpoints in the A2A server were completely unauthenticated. Any client on the network could:
/a2aPOST)/a2a/tasks/send,/a2a/tasks/cancel)/stream)The server also binds to
0.0.0.0:5000by default, making every interface reachable.Severity: High
CWE: CWE-306 (Missing Authentication for Critical Function)
Usage
Clients must then include:
Test plan
POST /a2awithout header → 401POST /a2awith correct bearer → 200POST /a2a/tasks/sendwithout header → 401POST /a2a/tasks/cancelwithout header → 401GET /agent.json(no token) → 200 (read-only routes unaffected)api_key=None(default) → all routes behave as before