UID2-7505: Detect unencrypted JSON request bodies in v2 envelope parsing#2660
Open
swibi-ttd wants to merge 7 commits into
Open
UID2-7505: Detect unencrypted JSON request bodies in v2 envelope parsing#2660swibi-ttd wants to merge 7 commits into
swibi-ttd wants to merge 7 commits into
Conversation
When a v2 request body fails envelope parsing and the (decoded) bytes parse as JSON, return a specific error explaining the body must be an encrypted request envelope, with a link to the encryption/decryption docs (unifiedid.com or euid.eu depending on identity scope). An encrypted envelope never parses as JSON, so the check only fires for genuinely unencrypted payloads, and the existing error messages remain byte-identical for all other causes (corrupted envelope, proxy-transformed body, wrong client secret). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…stant
'Version mismatch' reads as an operator/API version problem. Rename the
constant to ENVELOPE_FORMAT_VERSION and report the error using the docs'
own term ('version of the envelope format'), including the received byte:
'Invalid body: Invalid request envelope format version: received X, must be 1.'
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
A neutral pointer to the envelope-format docs, appended after each error's cause statement; the leading phrase of every message is preserved. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
When both the binary and base64 interpretations of an octet-stream body fail, the binary error was always returned - hiding the base64 path's more accurate diagnosis (e.g. unencrypted JSON) whenever the body was actually base64 text. A binary envelope can never be valid base64 (its first byte is the 0x01 envelope version byte, not a base64 character), so if the fallback got past base64 decoding, the body was base64 text and the fallback's error applies. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
swibi-ttd
force-pushed
the
swi-UID2-7505-detect-unencrypted-json
branch
from
July 23, 2026 03:07
0e75e91 to
94170b3
Compare
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.
Improves the v2 envelope parse error messages. A common integration mistake — sending base64-encoded plain JSON (e.g. via curl) instead of an encrypted request envelope — currently returns the opaque
Invalid body: Version mismatch., which gives no hint that the payload must be encrypted.Changes
Version mismatcherror, which reads as an operator/API version problem: "Invalid body: Invalid request envelope format version: received X, must be 1." (VERSIONconstant →ENVELOPE_FORMAT_VERSION.)0x01envelope version byte, not a base64 character), so if the fallback got past base64 decoding, the body was base64 text and the fallback's error is returned instead.Docs links are scope-aware (unifiedid.com / euid.eu);
IdentityScopeis plumbed fromV2PayloadHandler. All existing leading phrases are preserved, and nothing in uid2-operator, uid2-e2e, uid2-validator, or the client SDKs matches the oldVersion mismatchstring.Testing
New tests for base64-encoded, raw, and short unencrypted JSON bodies, genuine version mismatch, the EUID docs link, and both directions of the octet-stream fallback precedence.
mvn clean test: 757 tests, 0 failures.Jira
UID2-7505
🤖 Generated with Claude Code