Skip to content

JWS protected 'typ' (application/didcomm-signed+json) is parsed but never validated on the verify path #32

Description

@moisesja

JwsParser decodes the protected header but never inspects typ, so a received signed envelope with absent, empty, or arbitrary typ verifies identically to one carrying the canonical media type.

Severity: Info
Category: spec-noncompliance

Affected code

  • /Users/moises/Projects/didcomm-dotnet/src/DidComm.Core/Jose/Signing/JwsProtectedHeader.cs:25
  • /Users/moises/Projects/didcomm-dotnet/src/DidComm.Core/Jose/Signing/JwsParser.cs:71

Details
JwsProtectedHeader declares a Typ property (JwsProtectedHeader.cs:25), and JwsBuilder sets it to application/didcomm-signed+json on emit (JwsBuilder.cs:86). But JwsParser.Parse decodes the protected header (JwsParser.cs:71) and validates crit, b64, alg, and the kid cross-check — yet never reads header.Typ (a grep for .Typ across the Jose tree finds only the builder's write). No other layer checks it: EnvelopeDetector.Detect classifies envelope kind purely structurally (ciphertext / signatures / signature+payload), media-type independent. Therefore a received signed envelope with absent/empty/arbitrary typ verifies identically and cannot cause envelope-kind confusion.

Non-compliance
No concrete attack exists: the envelope kind is determined structurally, not by typ, and RFC 7515 §4.1.9 treats typ as advisory only. FR-SIG-04 makes setting the signed typ a SHOULD on emit (and permits JWM in the construction header), with no MUST to validate typ on receive — so not enforcing it is within spec. Reported only as a hardening/observability note: the library does not assert that the envelope it verified actually claimed to be a DIDComm signed message.

Recommended fix
Optionally record header.Typ in the parse result for diagnostics, and (defense-in-depth) reject only clearly-wrong typ values while continuing to tolerate absent typ and JWM per FR-SIG-04. No functional change is required for spec compliance.

References
RFC 7515 §4.1.9 (typ advisory); DIDComm v2.1 §Message Signing; PRD FR-SIG-04 / FR-ENV-01

Filed from an automated multi-agent security & compliance review.

Metadata

Metadata

Assignees

Labels

severity:infoInformational / hardening notespec-complianceDIDComm v2.1 / RFC / PRD non-compliance

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions