All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: alistair23@gmail.com
Cc: linux-cxl@vger.kernel.org, linux-pci@vger.kernel.org, ojeda@kernel.org
Subject: Re: [PATCH v2 05/21] X.509: Parse Subject Alternative Name in certificates
Date: Tue, 23 Jun 2026 05:07:10 +0000	[thread overview]
Message-ID: <20260623050711.388941F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260623045406.2589547-6-alistair.francis@wdc.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:

Pre-existing issues:
- [High] The X.509 parser completely ignores the `critical` flag on certificate extensions, allowing certificates with unrecognized critical constraints to be successfully validated.
--

commit b12732c2d7a7dc077f0c1d3f0be7c0a415bae376
Author: Lukas Wunner <lukas@wunner.de>

X.509: Parse Subject Alternative Name in certificates

This commit adds support for parsing the Subject Alternative Name (SAN)
extension in X.509 certificates. It stores a pointer to the SAN for later
consumption by CMA-SPDM for PCI device authentication.

> diff --git a/crypto/asymmetric_keys/x509_cert_parser.c b/crypto/asymmetric_keys/x509_cert_parser.c
> index bfd10f0195e01..c3ec2846695a5 100644
> --- a/crypto/asymmetric_keys/x509_cert_parser.c
> +++ b/crypto/asymmetric_keys/x509_cert_parser.c
> @@ -596,6 +596,15 @@ int x509_process_extension(void *context, size_t hdrlen,
>  		return 0;
>  	}
>  
> +	if (ctx->last_oid == OID_subjectAltName) {
> +		if (ctx->cert->raw_san)
> +			return -EBADMSG;
> +
> +		ctx->cert->raw_san = v;
> +		ctx->cert->raw_san_size = vlen;
> +		return 0;
> +	}
> +
>  	if (ctx->last_oid == OID_keyUsage) {

[Severity: High]
This is a pre-existing issue, but while looking at how we process X.509
extensions here, does the parser ignore the critical flag on extensions?

Looking at the ASN.1 definition in crypto/asymmetric_keys/x509.asn1:

Extension ::= SEQUENCE {
    extnId      OBJECT IDENTIFIER ({ x509_note_OID }),
    critical    BOOLEAN DEFAULT,
    extnValue   OCTET STRING ({ x509_process_extension })
}

Because there is no action attached to the critical BOOLEAN field, its
value seems to be discarded during parsing.

At the end of x509_process_extension(), unrecognized extensions are
unconditionally ignored:

crypto/asymmetric_keys/x509_cert_parser.c:x509_process_extension() {
    ...
    if (ctx->last_oid == OID_basicConstraints) {
        ...
        return 0;
    }
    
    return 0;
}

Since X.509 certificates are supplied by potentially untrusted sources
(like during SPDM authentication), could an attacker bypass required
certificate constraints by presenting unrecognized extensions marked with
the critical flag that get silently ignored and treated as a success (0)?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260623045406.2589547-1-alistair.francis@wdc.com?part=5

  reply	other threads:[~2026-06-23  5:07 UTC|newest]

Thread overview: 43+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-23  4:53 [PATCH v2 00/21] lib: Rust implementation of SPDM alistair23
2026-06-23  4:53 ` [PATCH v2 01/21] rust: transmute: add `cast_slice[_mut]` functions alistair23
2026-06-23  5:05   ` sashiko-bot
2026-06-23  4:53 ` [PATCH v2 02/21] rust: create basic untrusted data API alistair23
2026-06-23  5:09   ` sashiko-bot
2026-06-23  4:53 ` [PATCH v2 03/21] rust: validate: add `Validate` trait alistair23
2026-06-23  5:10   ` sashiko-bot
2026-06-23  4:53 ` [PATCH v2 04/21] X.509: Make certificate parser public alistair23
2026-06-23  5:03   ` sashiko-bot
2026-06-23  4:53 ` [PATCH v2 05/21] X.509: Parse Subject Alternative Name in certificates alistair23
2026-06-23  5:07   ` sashiko-bot [this message]
2026-06-23  4:53 ` [PATCH v2 06/21] X.509: Move certificate length retrieval into new helper alistair23
2026-06-23  5:02   ` sashiko-bot
2026-06-23  4:53 ` [PATCH v2 07/21] rust: add bindings for hash.h alistair23
2026-06-23  7:01   ` sashiko-bot
2026-06-23  4:53 ` [PATCH v2 08/21] rust: error: impl From<FromBytesWithNulError> for Kernel Error alistair23
2026-06-23  5:01   ` sashiko-bot
2026-06-23  4:53 ` [PATCH v2 09/21] lib: rspdm: Initial commit of Rust SPDM alistair23
2026-06-23  5:09   ` sashiko-bot
2026-06-23  4:53 ` [PATCH v2 10/21] PCI/TSM: Rename pf0 to host alistair23
2026-06-23  5:12   ` sashiko-bot
2026-06-23  4:53 ` [PATCH v2 11/21] PCI/TSM: Support connecting to PCIe CMA devices alistair23
2026-06-23  5:16   ` sashiko-bot
2026-06-23  4:53 ` [PATCH v2 12/21] PCI/CMA: Add a PCI TSM CMA driver using SPDM alistair23
2026-06-23  5:07   ` sashiko-bot
2026-06-23  4:53 ` [PATCH v2 13/21] PCI/CMA: Validate Subject Alternative Name in certificates alistair23
2026-06-23  5:07   ` sashiko-bot
2026-06-23  4:53 ` [PATCH v2 14/21] lib: rspdm: Support SPDM get_version alistair23
2026-06-23  5:10   ` sashiko-bot
2026-06-23  4:54 ` [PATCH v2 15/21] lib: rspdm: Support SPDM get_capabilities alistair23
2026-06-23  5:09   ` sashiko-bot
2026-06-23  4:54 ` [PATCH v2 16/21] lib: rspdm: Support SPDM negotiate_algorithms alistair23
2026-06-23  5:17   ` sashiko-bot
2026-06-23  4:54 ` [PATCH v2 17/21] lib: rspdm: Support SPDM get_digests alistair23
2026-06-23  5:17   ` sashiko-bot
2026-06-23  4:54 ` [PATCH v2 18/21] lib: rspdm: Support SPDM get_certificate alistair23
2026-06-23  5:20   ` sashiko-bot
2026-06-23  4:54 ` [PATCH v2 19/21] lib: rspdm: Support SPDM certificate validation alistair23
2026-06-23  5:19   ` sashiko-bot
2026-06-23  4:54 ` [PATCH v2 20/21] rust: allow extracting the buffer from a CString alistair23
2026-06-23  5:13   ` sashiko-bot
2026-06-23  4:54 ` [PATCH v2 21/21] lib: rspdm: Support SPDM challenge alistair23
2026-06-23  5:21   ` sashiko-bot

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260623050711.388941F000E9@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=alistair23@gmail.com \
    --cc=linux-cxl@vger.kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=ojeda@kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.