fix: validate push notification URLs before dispatch - #1169
Open
ez-lbz wants to merge 1 commit into
Open
Conversation
Client-set push config URLs were posted to by the server without any scheme or IP checks, letting a caller point the server at private, link-local, or cloud metadata hosts. Reject non-http(s) schemes, hostless URLs, private/link-local/multicast/reserved literal IPs, and known cloud metadata endpoints. Loopback addresses stay allowed so local notification receivers keep working.
🧪 Code Coverage (vs
|
| Base | PR | Delta | |
|---|---|---|---|
| src/a2a/server/tasks/base_push_notification_sender.py | 94.44% | 96.92% | 🟢 +2.48% |
| Total | 93.00% | 93.02% | 🟢 +0.02% |
Generated by coverage-comment.yml
4 tasks
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
Client-set push config URLs were POSTed to by the server without any
validation, so a caller who can create a push notification config can
point the server at loopback, private-network, link-local, or
cloud-metadata hosts.
Root cause
In
src/a2a/server/tasks/base_push_notification_sender.py,_dispatch_notificationpassespush_info.urlstraight toself._client.post(url, ...)— the URL comes from aTaskPushNotificationConfigthat callers can create, and no scheme orIP checks exist before the request is sent.
Fix
Added
_validate_push_url()and call it before POSTing:http/httpsschemes are allowedmulticast are rejected
169.254.169.254,metadata.google.internal,metadata.azure.com) are blocked explicitlyInvalid URLs fail the notification dispatch gracefully (logged and
skipped), the same failure path as a normal HTTP error.
Testing
cloud-metadata hostnames, non-http schemes, hostless URLs, and the
public-IP allow path.
./scripts/lint.shpasses (ruff + ty).tests/server/tasks/test_push_notification_sender.py— 15 passed.