Skip to content

fix(api): report a missing sha256 claim in WebhookReceiver - #860

Merged
lukasIO merged 1 commit into
livekit:mainfrom
ANDROIDHASSAN:fix/webhook-missing-sha256
Oct 14, 2026
Merged

lukasIO merged 1 commit into
livekit:mainfrom
ANDROIDHASSAN:fix/webhook-missing-sha256

Conversation

@ANDROIDHASSAN

Copy link
Copy Markdown
Contributor

WebhookReceiver.receive() checks claims.sha256 is None to report a token without a body hash, but TokenVerifier.verify() fills a missing sha256 claim with "", so that branch never runs. A webhook token without sha256 falls through to the hash comparison and is rejected with a misleading message:

jwt = AccessToken(key, secret).to_jwt()          # no sha256 claim
WebhookReceiver(TokenVerifier(key, secret)).receive(body, jwt)
# Exception: hash mismatch

The check is now if not claims.sha256, so it raises sha256 was not found in the token. The token is rejected in both cases; only the reason changes.

test_missing_hash in tests/api/test_webhook.py fails on main (hash mismatch) and passes with this change; pytest tests/api: 11 passed, 28 skipped.

TokenVerifier.verify() returns sha256 as "" when the claim is absent, so the
`claims.sha256 is None` check never fired and such tokens were rejected with
"hash mismatch" instead of "sha256 was not found in the token".

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no bugs or issues to report.

Devin Review

@lukasIO lukasIO left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that's a good improvement, thanks!

@lukasIO
lukasIO merged commit 6873622 into livekit:main Oct 14, 2026
23 checks passed
@ANDROIDHASSAN
ANDROIDHASSAN deleted the fix/webhook-missing-sha256 branch October 14, 2026 14:23
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.

2 participants