Internet-Draft | EUF-CMA for CMS SignedData | December 2024 |
Van Geest & Strenzke | Expires 8 June 2025 | [Page] |
The Cryptographic Message Syntax (CMS) has different signature verification behaviour based on whether signed attributes are present or not. This results in a potential existential forgery vulnerability in CMS and protocols which use CMS. This document describes the vulnerability and lists a number of potential mitigations for LAMPS working group discussion.¶
This note is to be removed before publishing as an RFC.¶
The latest revision of this draft can be found at https://danvangeest.github.io/cms-euf-cma-signeddata/draft-vangeest-lamps-cms-euf-cma-signeddata.html. Status information for this document may be found at https://datatracker.ietf.org/doc/draft-vangeest-lamps-cms-euf-cma-signeddata/.¶
Discussion of this document takes place on the Limited Additional Mechanisms for PKIX and SMIME Working Group mailing list (mailto:spasm@ietf.org), which is archived at https://mailarchive.ietf.org/arch/browse/spasm/. Subscribe at https://www.ietf.org/mailman/listinfo/spasm/.¶
Source for this draft and an issue tracker can be found at https://github.com/danvangeest/cms-euf-cma-signeddata.¶
This Internet-Draft is submitted in full conformance with the provisions of BCP 78 and BCP 79.¶
Internet-Drafts are working documents of the Internet Engineering Task Force (IETF). Note that other groups may also distribute working documents as Internet-Drafts. The list of current Internet-Drafts is at https://datatracker.ietf.org/drafts/current/.¶
Internet-Drafts are draft documents valid for a maximum of six months and may be updated, replaced, or obsoleted by other documents at any time. It is inappropriate to use Internet-Drafts as reference material or to cite them other than as "work in progress."¶
This Internet-Draft will expire on 8 June 2025.¶
Copyright (c) 2024 IETF Trust and the persons identified as the document authors. All rights reserved.¶
This document is subject to BCP 78 and the IETF Trust's Legal Provisions Relating to IETF Documents (https://trustee.ietf.org/license-info) in effect on the date of publication of this document. Please review these documents carefully, as they describe your rights and restrictions with respect to this document. Code Components extracted from this document must include Revised BSD License text as described in Section 4.e of the Trust Legal Provisions and are provided without warranty as described in the Revised BSD License.¶
The Cryptographic Message Syntax (CMS) [RFC5652] signed-data content type allows any number of signers in parallel to sign any type of content.¶
CMS gives a signer two options when generating a signature on some content:¶
Generate a signature on the whole content; or¶
Compute a hash over the content, place this hash in the message-digest attribute in the SignedAttributes type, and generate a signature on the SignedAttributes.¶
The resulting signature does not commit to the presence of the SignedAttributes type, allowing an attacker to influence verification behaviour. An attacker can perform two different types of attacks:¶
Take an arbitrary CMS signed message M which was originally signed with SignedAttributes present and remove the SignedAttributes, thereby crafting a new message M' that was never signed by the signer. M' has the DER-encoded SignedAttributes of the original message as its content and verifies correctly against the original signature of M.¶
Let the signer sign a message of the attacker's choice without SignedAttributes. The attacker chooses this message to be a valid DER-encoding of a SignedAttributes object. He can then add this encoded SignedAttributes object to the signed message and change the signed message to the one that was used to create the messageDigest attribute within the SignedAttributes. The signature created by the signer is valid for this arbitrary attacker-chosen message.¶
This vulnerability was presented by Falko Strenzke at IETF 121 [LAMPS121] and is detailed in [Str23].¶
Due to the limited flexibility of either the signed or the forged message in either attack variant, the fraction of vulnerable systems can be assumed to be small. But due to the wide deployment of the affected protocols, such instances cannot be excluded.¶
The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "NOT RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be interpreted as described in BCP 14 [RFC2119] [RFC8174] when, and only when, they appear in all capitals, as shown here.¶
Potential mitigations are described in the following sub-sections as input to the working group discussion. If this draft is adopted and the working group has taken a decision which measure(s) should be realized, we'll describe the chosen measures in detail.¶
The mitigations in this section make use of a context string which is passed to the signature algorithm's sign and verify functions.¶
ML-DSA [FIPS204], SLH-DSA [FIPS205], Composite ML-DSA [I-D.ietf-lamps-pq-composite-sigs], and Ed448 [RFC8032] take a context string during signing and verification. The context string may be up to 255 bytes long. By default the context string is the empty string.¶
Sign(sk, M, ctx="") Verify(sk, M, ctx="")¶
RSA, ECDSA and Ed25519 signatures do not take a context string and would not be helped by these mitigations.¶
Ed448 can take a context string but does not currently in CMS [RFC8419].¶
Ed25519ctx [RFC8032] takes a context string but is not specified for use in CMS.¶
Immediately update [I-D.ietf-lamps-cms-ml-dsa], [I-D.ietf-lamps-cms-sphincs-plus], and [I-D.ietf-lamps-pq-composite-sigs] to require a context string, with a different value for use with and without signated attributes.¶
When signed attributes are present:¶
Sign(sk, M, "signed-attributes") Verify(sk, M, "signed-attributes")¶
When signed attributes are absent:¶
Sign(sk, M, "no-signed-attributes") Verify(sk, M, "no-signed-attributes")¶
Unlike the following mitigations, Ed448 cannot be addressed by this mitigation because it is already published and in use.¶
Like Section 3.1, but the use of the signature context string is indicated by a new, empty (or attribute value ignored), sign-with-context-implicit unsigned attribute.¶
[I-D.ietf-lamps-cms-ml-dsa], [I-D.ietf-lamps-cms-sphincs-plus], and [I-D.ietf-lamps-pq-composite-sigs] can be published using the default signature context string. ML-DSA, SLH-DSA, Composite-ML-DSA, and Ed448 only use the non-default context string when the new attribute is used.¶
When signed attributes are present:¶
unsigned-attributes.add(sign-with-context-implicit) Sign(sk, M, "signed-attributes")¶
When signed attributes are absent:¶
unsigned-attributes.add(sign-with-context-implicit) Sign(sk, M, "no-signed-attributes")¶
When signed attributes are present:¶
IF unsigned-attributes.contains(sign-with-context-implicit) THEN Verify(sk, M, "signed-attributes") ELSE Verify(sk, M, "")¶
When signed attributes are absent:¶
IF unsigned-attributes.contains(sign-with-context-implicit) THEN Verify(sk, M, "no-signed-attributes") ELSE Verify(sk, M, "")¶
Like Section 3.2 but the new unsigned attribute (sign-with-context-explict) contains a semi-colon-delimited list of keyword (and optional value) strings. This addresses the possibility of future CMS features that require context parameters.¶
ctx = "<keyword_1>[=value1];...;<keyword_n>[=value]"¶
The list is ordered alphabetically by type string. This list is validated by the verifier and used as the signature context string. (alternative: the SHA-256 hash of the list is used as the signature context string to avoid it getting too long)¶
A proposed list of initial signature context string keywords follows:¶
keyword | value | comment |
---|---|---|
"IETF/CMS" | REQUIRED to be in the sign-with-context-implicit attribute, to differentiate a signature in CMS from a signature with the same private key over some other data. | |
"signed-attrs" | Present if signed attributes are used, not present if signed attributes are not used. Alternative: always present, value = 0/1, yes/no depending on whether signed attributes are present or not. | |
"app-ctx" | base64( SHA-256( protocol_context ) ) | Allows the protocol using CMS to specify a context. SHA-256 is applied so that the length available to the protocol context isn't dependent on the other context values used in CMS. (alternative: no SHA-256 here, apply SHA-256 to the whole CMS context). base64-encoding is applied so the app context doesn't introduce semi-colons to mess up CMS' parsing of this string. |
When a verifier processes a SignerInfo containing the sign-with-context-explicit attribute, it MUST perform the following consistency checks:¶
If the "signed-attrs" keyword is present and SignedAttributes is not present in the SignerInfo, fail verification.¶
If the "signed-attrs" keyword is not present and SignedAttributes is present in the SignerInfo, fail verification.¶
If the consistency checks pass, the signature is verified using the string in the sign-with-context-explicit attribute as the signature context (alternative: using SHA-256 of the string in the sign-with-context-explicit attribute).¶
When a verifier processes a SignerInfo without the sign-with-context-explicit attribute, they MUST verify the signature using the default signature context value ("").¶
[I-D.ietf-lamps-cms-ml-dsa], [I-D.ietf-lamps-cms-sphincs-plus], and [I-D.ietf-lamps-pq-composite-sigs] can be published using the default signature context string. ML-DSA, SLH-DSA, Composite-ML-DSA, and Ed448 only use the non-default context string when the new attribute is used.¶
The following mitigations might not be good ideas but are included just in case there's a seed of genius in them.¶
If SignedAttributes is not present, check if the signed message is a valid DER-encoded SignedAttributes structure and fail if it is. The mandatory contentType and messageDigest attributes, with their respective OIDs, should give a low probability of a legitimate message being flagged.¶
If an application protocol deliberately uses such a signed messages, verification would fail.¶
This mitigation does not address the inverse problem where a protocol doesn't used SignedAttributes but for some reason often sends messages which happen to be formatted like valid SignedAttributes encodings, with attacker-controlled bytes where the message digest attribute would be.¶
Individually update each protocol which use CMS to always require or forbid signed attributes.¶
Section 4.1 but specified in the protocol that uses CMS rather than CMS itself.¶
TODO Security¶
The vulnerability is not present in systems where the use of SignedAttributes is mandatory, for example: SCEP, Certificate Transparency, RFC 4018 firmware update, German Smart Metering CMS data format. However, this security relies on a correct implementation of the verification routine that ensures the presence of SignedAttributes.¶
The vulnerability is also not present when the message is signed and then encrypted, as the attacker cannot learn the signature.¶
Conceivably vulnerable systems (TODO: describe these better):¶
This document has no IANA actions.¶
TODO acknowledge.¶