fix(envelope): fail closed when an authenticated decrypt surfaces no skid (#52)#55
Merged
Merged
Conversation
…skid (#52) The authcrypt unpack branch trusted DataProofs' definitional invariant IsAuthenticated <=> non-empty skid without asserting it. Had it ever regressed, a null skid would silently skip the FR-CONSIST-01 from<->skid binding on an envelope still reported authenticated; an empty skid would escape as a raw ArgumentException off the FR-API-07 contract. Assert a surfaced skid whenever a decrypt is authenticated, rejecting with ConsistencyException — parity with the JWS branch's signer-kid guard (6f393e9). The check lives in AddressingConsistency as CheckAuthcryptSkidSurfaced so it is directly unit-tested; the EnvelopeReader call site is unreachable through today's parser by construction, so no current input changes behavior. Closes #52. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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.
Closes #52.
What
Defense-in-depth guard in the authcrypt unpack branch: whenever a decrypt is authenticated,
EnvelopeReadernow asserts a non-emptyskidand rejects withConsistencyExceptionotherwise — parity with the JWS branch's empty-signer-kid guard (6f393e9).Why
The branch trusted DataProofs' definitional invariant
IsAuthenticated ⟺ non-empty skid(JweParser.cs:439/572) without asserting it. Both regression shapes were traced:from↔skidcheck is silently skipped;message.Fromwould be attacker-set on an envelope the whole stack reports as authenticated.CheckAuthcryptFromMatchesSkidthrows a rawArgumentException, escaping the FR-API-07 unpack exception contract (fails closed, wrong type).The guard covers both and fires before any trust state (
authenticated/senderKid) is set.Decisions (pre-made, per the issue)
ConsistencyException, as the issue specifies. The JWS branch'sCryptoExceptionasymmetry is deliberate and untouched — no scope creep into that branch, line-127 semantics, DataProofs, or the PRD.EnvelopeReadercall site is unreachable through the real parser by construction (the invariant is definitional upstream; no parser seam exists, deliberately). The check therefore lives inAddressingConsistencyasCheckAuthcryptSkidSurfacedand is unit-tested directly (null → throws, empty → throws, valid → passes), the same pattern as every other FR-CONSIST rule. Precedent: the JWS guard shipped without a message-level test.Risk
Zero behavior change for any input that exists today — no legitimate flow, no currently-craftable envelope reaches the guard. Full suite green: 757 passed, 0 failed (598 core + 159 interop), no existing test modified.
🤖 Generated with Claude Code