fork/pr 309 jwt audience validation#20
Closed
shpaw415 wants to merge 19 commits intokagii-dev:masterfrom
Closed
Conversation
Port of anomalyco#309 by @execute008. Fixes a critical security vulnerability where JWT tokens were issued with 'aud' (audience) claims but never validated during verification, allowing token mix-up / confused deputy attacks (RFC 7519 §4.1.3). Changes: - Add audience parameter to VerifyOptions with full JSDoc - Validate audience in client.verify() using jose's built-in validation, defaulting to clientID for backward compatibility - Wrap /userinfo JWT verification in try/catch with audience presence check - Bump hono 4.6.9 → 4.10.5 (latest security patches) - Add 21-test suite covering attack scenarios, RFC compliance, and edge cases Co-authored-by: execute008 <36474314+execute008@users.noreply.github.com> Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
I like the core security fix here, but this PR feels too broad for what should be a fairly focused change.
My preference would be:
|
|
The client.verify() change in packages/openauth/src/client.ts looks like the real fix: passing audience into jwtVerify() closes the token mix-up issue and the default to clientID seems like the right compatibility behavior. A couple of follow-ups from review:
|
…p on authorize flow & secure issuer with authorizedAudiences add missing aud props and audience presence and match validation
…a audience helper
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
Port of anomalyco/openauth#309 by @execute008.
Fixes a critical security vulnerability in JWT token validation that could allow token mix-up attacks (confused deputy vulnerability). Tokens were being issued with
aud(audience) claims but never validated during verification, violating RFC 7519 §4.1.3 requirements.Vulnerability Details
Type: Token mix-up / Confused deputy attack
Severity: Critical
RFC Reference: RFC 7519 §4.1.3 (Audience Claim)
Problem:
aud: clientIDclaim when creatediss) was being validatedAttack Scenario:
An attacker could obtain a valid JWT token for Service B and successfully use it to access Service A, since only the issuer was validated.
Changes Made
VerifyOptionsinterface with full documentationclient.verify()using jose library's built-in validationBefore:
After:
Test Coverage
Added 5-test suite (
jwt-audience-validation.test.ts) covering:Backward Compatibility
Fully backward compatible. When no explicit
audienceoption is provided, validation defaults to the client'sclientID.References