security: cryptographically verify RFC 3161 tokens and TSA trust chains #1
Labels
No labels
nagonag
nagonag/ignore
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
heiko/mailseal#1
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Problem
sign.goaccepts timestamp responses without verifying the CMS signature or the TSA certificate chain.Response.Validate(req)checks RFC 3161 structure, status, message imprint, nonce, generation-time form, and certificate presence, but the upstream package explicitly requires callers to invokeSignedToken.Verifybefore consumption.verify.gois also parse-only: it JSON-decodes eachx-signature, callsParseSignedToken, logs the parsed token, and returns success. It does not:The CLI help still describes this command as “Verify a signed message”. Several enabled TSA URLs use plain HTTP. An active network attacker can observe the request imprint and nonce and return a structurally matching token signed by an untrusted key; the current application provides no trust decision that rejects it.
Relevant code:
sign.go:ts.Response.Validate(ts.Request),SignedToken()and header emissionverify.go: complete current implementationmain.go:verifyCmdhelp text and HTTP TSA endpointsheader.go: unauthenticated JSON metadataResponse.ValidateandSignedToken.VerifyChecklist: Go mistake #53 (required errors/verification are not handled).
Proposed fix
SignedToken.Verify(ctx, x509.VerifyOptions{...})before emitting any output.Version == 1;Fieldspolicy rather than blindly trusting the header;TSTInfo, normalize the message, and compare SHA-512 imprint;inspectand do not expose it asverify.Historical timestamp validation needs a documented policy for certificate validity time and revocation; do not silently equate current system trust with validity at the timestamp generation time.
Acceptance criteria
mail-seal-signature(5)accurately describe the trust policy.Reviewed against
948b7a9onmaster(Go 1.26.2).Cryptographic signing/verification, trust-policy documentation, and failure-path acceptance tests are complete.
Closing commit:
96b9850d7a6e