fix: reject CR/LF in push notification Authorization header - #1043
Open
ez-lbz wants to merge 1 commit into
Open
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.
What changed
1. Reject CR/LF characters in push notification Authorization header
Problem:
BasePushNotificationSender.dispatchNotificationbuilt theAuthorizationheader asscheme + " " + credentialswith direct string concatenation. Both values are client-controlled (stored in the push notification config), so a credential or scheme containing\r/\ncould inject arbitrary extra headers (CWE-113). The JDKHttpClienthappens to validate headers, butA2AHttpClientis a pluggable SPI whose implementations (including custom ones) cannot be assumed to do the same.Fix (server-common/src/main/java/org/a2aproject/sdk/server/tasks/BasePushNotificationSender.java):
buildAuthorizationHeader(AuthenticationInfo), which assembles"scheme credentials"and throwsIllegalArgumentExceptionif the resulting value contains CR or LF. The notification dispatch then fails safely (logged) and the injected header is never sent.Fix (server-common/src/test/java/org/a2aproject/sdk/server/tasks/PushNotificationSenderTest.java):
testSendNotificationWithAuthHeader— a validAuthenticationInfo("Bearer", "token123")sendsAuthorization: Bearer token123.testSendNotificationRejectsCrlfInCredentials— credentials containing\r\nX-Injected: 1cause the notification to be dropped; no HTTP call is made.testSendNotificationRejectsCrlfInScheme— a scheme containing\ncauses the notification to be dropped.Behavior change: push notifications whose configured auth scheme/credentials contain CR or LF are no longer dispatched (previously the raw value was passed through to the HTTP client). Valid credentials are unaffected.
Testing
mvn -pl server-common test— 450 tests run, 0 failures, 0 errors, 0 skipped (BUILD SUCCESS), including the 3 new regression tests.