acme/api: reject General JSON Serialization JWS bodies per RFC 8555#2662
Open
SAY-5 wants to merge 1 commit into
Open
acme/api: reject General JSON Serialization JWS bodies per RFC 8555#2662SAY-5 wants to merge 1 commit into
SAY-5 wants to merge 1 commit into
Conversation
|
|
Skyb0rg007
reviewed
May 22, 2026
| // singular "signature" + "protected" alongside "payload". | ||
| func rejectGeneralJWS(body []byte) error { | ||
| var peek struct { | ||
| Signatures json.RawMessage `json:"signatures"` |
There was a problem hiding this comment.
You should also assert that the message doesn't include the unprotected header
Suggested change
| Signatures json.RawMessage `json:"signatures"` | |
| Signatures json.RawMessage `json:"signatures"` | |
| Header json.RawMessage `json:"header"` |
Author
|
Good catch. rejectGeneralJWS now also rejects a top-level "header" member (the JWS Unprotected Header, forbidden by RFC 8555 section 6.2), with a matching test case. 880c12c. |
RFC 8555 section 6.2 mandates Flattened JSON Serialization. go-jose/v3's ParseSigned accepts both Flattened and General forms, so step-ca silently accepted invalid ACME bodies. Reject them explicitly. Also reject the JWS Unprotected Header member per RFC 8555 section 6.2 which does not permit it in ACME requests. Fixes smallstep#2642. Signed-off-by: Sai Asish Y <say.apm35@gmail.com>
880c12c to
e4c004f
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.
Summary
Fixes #2642.
RFC 8555 section 6.2 mandates that ACME JWS bodies MUST use the Flattened JSON Serialization. go-jose/v3's
ParseSignedaccepts both Flattened and General forms, sostep-casilently accepted:{"payload": "...", "signatures": [{"protected": "...", "signature": "..."}]}as if it were a legal RFC 7515 flattened body. As the reporter notes, go-jose doesn't expose a way to restrict this, so the check has to sit at the JSON layer before
jose.ParseJWSruns.Fix
Add a lightweight
rejectGeneralJWShelper in front ofparseJWSthat JSON-probes the body for a top-level"signatures"array (plural, the telltale General-form field). Hit → returnACME ErrorMalformedTypewith a message pointing back to RFC 8555. Bodies that aren't valid JSON fall through to the existingParseJWSpath so go-jose's own diagnostics still produce the familiarcompact JWS format must have three partserror for compact-serialization mistakes.Tests
TestHandler_parseJWS/fail/general-jwsdrives a General-form body throughparseJWSand asserts400 ErrorMalformedTypewith the RFC-8555-pointing message.fail/read-body-error,fail/parse-jws-error, andokcases stay green.go build ./acme/...,go vet ./acme/...,go test ./acme/api -run TestHandler_parseJWSall green.