Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.221.43 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796222693; b=avszT1n0xZ0bowpizyM8pptDfxqbmh+MOWFSbusauCmbUx7c2g4SLENg+vAYA5O+uz8r HvX1oaVauC6US/jRHtP5YfocGNT3U0eAUmMHymABHjU9pdXgDXRapVvKYjQfWP89sntH0 lGhZGULILC+6nJNB9PjApysRojy/KSRMRC/MVflJQyIfk9VuWKGOW2LLFj5z/+S6fjPMY 15utYmUOpFKbRZecJWB+Cs5PXSK2WEivOt9bhx1toRfhM2g/8m2ZUufFxY5vOwqmRy9Ta xEbKwOyzZvNLft6FOYOum8O4LsDbhWL1TwUqcarlr1ft+XUK0KjOY+uXsWWmyKV2sug== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796222693; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received: From:Date:Subject:MIME-Version:Content-Type:Content-Transfer-Encoding: Message-Id:X-B4-Tracking:X-Change-ID:To:Cc:X-Mailer; bh=WuB+DPlXs+JDxtm62gyDaeS3juuWkv0dqDBAoCyYu5M=; b=s8H46LqLiSXE48+Qiktm3Pw3SuF5G9VU5p6sMmh4T00kUAMpYaMqNhHs9azMVdIKrk6m ND4a8YCFr8IP14Aj1IjBf0B/SQJ02mZDgIbLUqcYDH8xk2ruJAh1yZEdGfLki1Ftow8xV J/vc7OTtOhXWcdmTB9LrqA1Cr+mZvptmXh7asgVQGBW9Wej6A5NxbQutLEaU9YEbHUAOA 8z/PXXTBRCeUEAciwGgMYPj06zCyZ7QVPMvdVBr3+MkE3OUGnU8zWSYX8+HMQ02Nze0YX ZKPL3XgN6ML47Uw0xlbsPq47oJZTnQCjXy1rdJhnIGrYy9aIg00JzOBn2yNoB9FkZbQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=pereq.eu; spf=pass smtp.mailfrom=cryspen.com; dkim=pass header.d=pereq.eu header.i=@pereq.eu header.a=rsa-sha256 header.s=google header.b=E+EiliGs; arc=none smtp.remote-ip=209.85.221.43 Received: from mail-wr1-f43.google.com (mail-wr1-f43.google.com [209.85.221.43]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id F04BC606A322 for ; Wed, 2 Dec 2026 14:44:52 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org F04BC606A322 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=pereq.eu Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=cryspen.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key, unprotected) header.d=pereq.eu header.i=@pereq.eu header.a=rsa-sha256 header.s=google header.b=E+EiliGs Received: by mail-wr1-f43.google.com with SMTP id ffacd0b85a97d-492690dd5daso10198019f8f.1 for ; Wed, 02 Dec 2026 06:44:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pereq.eu; s=google; t=1796222691; x=1796827491; darn=vger.kernel.org; h=cc:to:message-id:content-transfer-encoding:content-type :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to:content-type; bh=WuB+DPlXs+JDxtm62gyDaeS3juuWkv0dqDBAoCyYu5M=; b=E+EiliGsiSyEL2YmPsiS+vWiwUB6A0rVfaYGxuhz2xIj6s7KIwUsdElYXmoktqgO6r EjSckly+m3kfBtwdrjg/NgcynDS0LQBHRr8Ce53jJC9e/BYbjU3icSJb8Fsj45fKVD9Z 6o9lJSH9STUlC/iP2+QXJqNa2t2S8hyXoNnvT9MUVFArQIk0+A5EQaBYkZyMGDKiYZON QUYLBSI/66SBSh+L4nLr4LG7ywA0h3DO3gOvRMSjI9YLfkDHU+22/yvYtc/zeTxl13aA 6H2QVDfXI2NBQTUO4oeGuuC6fSQ1+RJg5g3OqVghgv611Rr3B1BIB5wyF+oF4zD+HsCv KZng== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796222691; x=1796827491; h=cc:to:message-id:content-transfer-encoding:content-type :mime-version:subject:date:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to:content-type; bh=WuB+DPlXs+JDxtm62gyDaeS3juuWkv0dqDBAoCyYu5M=; b=ayEOh0qJrM+bQQFutTAOhIcuf90OjQ45UtjBOnmvM5OhmfJNhhle7msX5XnknG8k4p QK/KHd0kXu+fSCVulS/CZTtXcJRp/2WVQlSLask/8EmGKclhe1DDcfNdlFMF3AQ7tf6U 9xJLkMIYufRv/MAHkz2Li3qgbXk2jr9QF8tsJRJaOLnuSXPYPrYUlk10HCBz9KOh9L7i EB7Qw1VfoU+/TFoRU0x8uX9REnwuCQxcTcQErE2gb0n3KoEiBGaoY7gyqQ8/QuA8rXFp S290J8oeckIHU2dobpuIEu98zCHwE1CDO5lhno+r8wcXtUcl/PF1HQ5ecPmvhy0oFsvc RMAQ== X-Forwarded-Encrypted: i=1; AL+hErEtHEfl7jkor5ozNbLquu1h4EsRoKRK3aFakKyIOyAMWYpNkyt+3+ABgQZJE1DO7UkNqjMK40bcJg==@vger.kernel.org X-Gm-Message-State: APuU4Z8f0kjeJW01OvpDXR7E7sauBovn28Q9ji2L7KVOjgwP8JAgYvBI qd/Z1DrhrJQq1/eQPAubxZ/e0vFY8IUXR+qsTCGNBl8k7YOvAfn1ZSuww7VrcOUwMQI= X-Gm-Gg: AZFdTZclEL0OgSG5paDS6Uoj5Xnm3XG1GHi3AAqeh3C03362Bx8AHbOWsrnCKQ5YXlu 31mSS+ZUNiaRkgtsksP5vezHigN10Z7yM6PQCWdLyJmgzg6WkUbld5cC+IBb71mV4cT8iqHI9wZ djC/eUbnCZIpj9hH6QmnNO5LP/QFEB96sbljEI7TN6Ydd/eKZLGfIYAtrck5VcaykETtJ3h6z5u Zf4LQ63L9tMHdmS/p5+pgelJdClHjV1dFsI1P9WohgpWuY2iuuXnxlzxonZaBNi4Gfz7TWjnma/ 38L2Bn4yH53JtsqAWFamtPlRBSObV/RqldqLlDKs87DPdXMJed19vZDPl71Vs/y5qJcdVdY8G11 N9NgRsSi2fdzGa+MYjSnqk9QhxN4Tozx46wH42sMDK6IQDTvLPYj48oVKdCE1YEFUPbvcxXK2ty ATvQ1tnIqSpShaB0RGl6W5riljvBRdBocWibpWyA25Y/ZHFD9StxeRmyAe1QfEkMWIlpIg7+UfF oMzhcADdHXny9ah5WdCPM7QmRSzapP2fTFwB9lJxSQD6w0aE9tIEgUQZUBNNFhAkxnSclaYR3xs zjC84gC5ro/w1U+Hnzk= X-Received: by 2002:adf:e011:0:10b0:48d:f99d:a0d2 with SMTP id ffacd0b85a97d-4abb2168f53mr57657487f8f.15.1796222691228; Wed, 02 Dec 2026 06:44:51 -0800 (PST) Received: from localhost ([2c0f:3d00:6be:8900:ce5e:9212:ea4b:f30]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-4ab69bf630esm79930333f8f.16.2026.12.02.06.44.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Dec 2026 06:44:50 -0800 (PST) From: Dan Carpenter Date: Wed, 02 Dec 2026 17:44:44 +0300 Subject: [PATCH RFC] pkcs7: Remove the [2] form of the signed attributes from the grammar X-Mailing-List: keyrings@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20261202-signed_attr2-v1-1-2147f8a79bc3@pereq.eu> X-B4-Tracking: v=1; b=H4sIAAAAAAAC/1WMTQrCMBCFr1JmbcBM1YVbwQO4LSLJdGzHRZSZK ELp3ZvUlZsH7++bwFiFDY7NBMofMXmmYvymARpDGthJXzzgFg++iDMZEve3kLOiQ+KWPO9w3xK Uy0v5Lt8V18HlfILrL7R3fDDlCqqzGIxd1JBorNEfsnYwzwt5cdTRmQAAAA== X-Change-ID: 20261202-signed_attr2-2ce3c1e4253c To: David Howells , Lukas Wunner , Ignat Korchagin , Herbert Xu , "David S. Miller" , Vivek Goyal Cc: Karthik Bhargavan , =?utf-8?q?Cl=C3=A9ment_Blaudeau?= , keyrings@vger.kernel.org, linux-crypto@vger.kernel.org, Dan Carpenter X-Mailer: b4 0.16.0 Hi David, At Pereq we're doing formal verification work and our tools flagged signed attributes with a [2] tag. The issue is that the [2] tag leaves attributes out of the signature check. So for example, someone who can modify the message could change the signingTime and make a correctly signed message be refused. It's obviously not the end of the world, but it's the sort of invariant violation that formal verification will complain about. The thing is that it looks like [2] was included by mistake. Can we just remove it? I don't think anything relies on it. The kernel only parses SignedData and nothing in the kernel produces the [2] form; openssl cms always uses the [0] tag. It's not clear that [3] should be included either but the kernel ignores them so the tool doesn't complain. -- >8 -- RFC 2315 section 9.2 and RFC 5652 section 5.3 give the signed attributes only the [0] tag, and the signature is made over them. pkcs7.asn1 also accepts a [2] tag, as an EXPLICIT SEQUENCE. Only the [0] alternative has the pkcs7_sig_note_set_of_authattrs() action, which records the attributes for the signature check, so with the [2] tag the signature is checked over the content alone. pkcs7_verify_one() still compares the unsigned signingTime with the signer's validity. Remove the [2] alternative from the grammar, so that the ASN.1 decoder refuses it. The kernel only parses SignedData and nothing in the kernel produces the [2] form; openssl cms always uses the [0] tag. Fixes: 2e3fadbf730f ("PKCS#7: Implement a parser [RFC 2315]") Signed-off-by: Dan Carpenter --- --- crypto/asymmetric_keys/pkcs7.asn1 | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/crypto/asymmetric_keys/pkcs7.asn1 b/crypto/asymmetric_keys/pkcs7.asn1 index 28e1f4a41c14..5e57288b4509 100644 --- a/crypto/asymmetric_keys/pkcs7.asn1 +++ b/crypto/asymmetric_keys/pkcs7.asn1 @@ -78,14 +78,8 @@ SignerInfo ::= SEQUENCE { version INTEGER ({ pkcs7_note_signerinfo_version }), sid SignerIdentifier, -- CMS variant, not PKCS#7 digestAlgorithm DigestAlgorithmIdentifier ({ pkcs7_sig_note_digest_algo }), - authenticatedAttributes CHOICE { - aaSet [0] IMPLICIT SetOfAuthenticatedAttribute - ({ pkcs7_sig_note_set_of_authattrs }), - aaSequence [2] EXPLICIT SEQUENCE OF AuthenticatedAttribute - -- Explicit because easier to compute digest on - -- sequence of attributes and then reuse encoded - -- sequence in aaSequence. - } OPTIONAL, + authenticatedAttributes [0] IMPLICIT SetOfAuthenticatedAttribute OPTIONAL + ({ pkcs7_sig_note_set_of_authattrs }), digestEncryptionAlgorithm DigestEncryptionAlgorithmIdentifier ({ pkcs7_sig_note_pkey_algo }), encryptedDigest EncryptedDigest, --- base-commit: b30891102b2099aac3dee3ce4cc9b5c0539b6ccd change-id: 20261202-signed_attr2-2ce3c1e4253c Best regards, -- Dan Carpenter