← Back to DAGDA | Support | Source: https://github.com/jwtk/jjwt/pull/1066
Skip to content

Fix empty JSON encrypted content parsing - #1066

Merged
lhazlewood merged 1 commit into
jwtk:mainfrom
exijn:fix-1035-encrypted-content-json
Aug 24, 2026
Merged

lhazlewood merged 1 commit into
jwtk:mainfrom
exijn:fix-1035-encrypted-content-json

Conversation

@exijn

@exijn exijn commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

Fixes #1035

Summary

This updates JWT parsing so encrypted content with an empty JSON object byte payload ({}) is not automatically treated as Claims unless Claims parsing was explicitly requested.

The previous behavior caused parseEncryptedContent to fail with Unexpected Claims JWE. when arbitrary encrypted content happened to deserialize as an empty JSON object.

Changes

  • Preserve empty JSON object payloads as content for content parsing paths.
  • Keep Claims parsing behavior when Claims are explicitly requested.
  • Add a regression test for encrypted content containing {} bytes.

Verification

  • .\mvnw -pl impl -am -Dtest=JwtsTest '-Dsurefire.failIfNoSpecifiedTests=false' test
  • .\mvnw -pl impl -am -Dtest=JwtParserTest '-Dsurefire.failIfNoSpecifiedTests=false' test
  • .\mvnw verify

@exijn
exijn marked this pull request as ready for review July 17, 2026 06:08
@lhazlewood
lhazlewood merged commit 95d0022 into jwtk:main Aug 24, 2026
@lhazlewood

Copy link
Copy Markdown
Contributor

Thank you for the PR!

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.

JWE with no "cty" where content accidentally looks like JSON cannot be decrypted with parseEncryptedContent

2 participants