Skip to content

Fix empty JSON encrypted content parsing - #1066

Open
hej090224 wants to merge 1 commit into
jwtk:mainfrom
hej090224:fix-1035-encrypted-content-json
Open

Fix empty JSON encrypted content parsing#1066
hej090224 wants to merge 1 commit into
jwtk:mainfrom
hej090224:fix-1035-encrypted-content-json

Conversation

@hej090224

Copy link
Copy Markdown

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

@hej090224
hej090224 marked this pull request as ready for review July 17, 2026 06:08
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

1 participant