Skip to content

feat: verify SNS deliveries and reject a token without a user id - #137

Merged
mogita merged 2 commits into
mainfrom
fix/token-user-id-check
Nov 23, 2026
Merged

mogita merged 2 commits into
mainfrom
fix/token-user-id-check

Conversation

@mogita

@mogita mogita commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

Submit a pull request

CLA

  • I have signed the Stream CLA (required).
  • The code changes follow best practices
  • Code changes are tested (add some information if not applicable)

Description of the pull request

Tickets: https://linear.app/stream/issue/CHA-7200, https://linear.app/stream/issue/CHA-7202

  • Webhook.verifyAndParseSns(notificationBody, secret) and client.verifyAndParseSns(...) verify the signature message attribute (the same HMAC as X-Signature) on SNS HTTP(S) deliveries before parsing. The parseSns and parseSqs Javadoc no longer says IAM authenticates SNS HTTP deliveries.
  • TokenBuilder.createToken (and so Call.createSRTCredentials) throws IllegalArgumentException for a null, empty or blank userId. A secret-signed token without a user id authenticates as the server.

How to verify: ./gradlew spotlessCheck test --tests 'io.getstream.WebhookTest' --tests 'io.getstream.services.framework.TokenBuilderTest'

Webhook.java, WebhookTest.java and src/test/resources/fixtures/webhooks/ are generated by GetStream/chat#21473 at openapi-v241.18.5. Merge after it, so the next regeneration produces the same files.

BEGIN_COMMIT_OVERRIDE
feat: add verifyAndParseSns to verify the signature attribute on SNS HTTP(S) deliveries before parsing
fix: TokenBuilder.createToken rejects a null, empty or blank userId instead of minting a server-side token
fix: Webhook.verifySignature returns false for a null or empty secret or signature instead of throwing
END_COMMIT_OVERRIDE


Note

Medium Risk
Touches webhook authentication and token minting; behavior change for callers that passed blank userIds, with new security paths covered by conformance tests.

Overview
Adds Webhook.verifyAndParseSns (and StreamSDKClient.verifyAndParseSns) for SNS HTTP(S) subscriptions: unwrap the envelope, decode the inner message, verify the HMAC in MessageAttributes.signature (same as X-Signature), then parse. parseSns / parseSqs stay unsigned and their docs now say to use them only for IAM-protected queue paths, not public SNS POSTs.

verifySignature now returns false when the secret or signature is null or empty, and conformance fixtures/tests cover SNS verification and forged/missing signatures.

TokenBuilder.createToken throws IllegalArgumentException for null, empty, or blank userId so the SDK no longer mints a server-authenticating token by mistake.

Reviewed by Cursor Bugbot for commit 06d31d7. Bugbot is set up for automated code reviews on this repo. Configure here.

Add Webhook.verifyAndParseSns and StreamSDKClient.verifyAndParseSns, which
verify the signature message attribute on SNS HTTP(S) deliveries before
parsing, and correct the parseSns and parseSqs docs.

TokenBuilder.createToken rejects a null, empty or blank userId: a secret-signed
token without a user id authenticates as the server.
@mogita
mogita merged commit 2758291 into main Nov 23, 2026
13 checks passed
@mogita
mogita deleted the fix/token-user-id-check branch November 23, 2026 16:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant