Accessing bytes of non-string SAN can lead to out-of-bounds memory read
CriticalCVE-2026-43820 · Published Jul 15, 2026
### Summary `NIOSSLCertificate._subjectAlternativeNames` provides access to the raw bytes for a cert's SANs. NIOSSL provides access to a buffer assumed to be backed by an `ASN1_STRING`, but not all SANs are backed by `ASN1_STRING`, so accessing the buffer for such a type can lead to out-of-bounds memory access. ### Details When building the byte view of a subject alternative name, NIOSSL reads the `ASN1_STRING` member of the BoringSSL `GENERAL_NAME` union for every entry without checking the name's type. The union only holds an `ASN1_STRING` for the string-shaped GeneralName types (`dNSName`, `rfc822Name`, `uniformResourceIdentifier`, `iPAddress`). For the other types (`otherName`, `x400Address`, `directoryName`, `ediPartyName`, `registeredID`) the union holds a different structure, so this reads the buffer's base pointer and length out of unrelated memory. The SAN list is parsed from an X.509 certificate, which is untrusted in the usual TLS/mTLS case, and `contents` is reachable through the public, albeit underscored, `_subjectAlternativeNames()` API. NIOSSL should only interpret the union as an `ASN1_STRING` for the string-shaped types and expose empty contents for the rest....
Affected versions
| Package | Affected | Fixed in |
|---|---|---|
| swift-nio-ssl Product | >= 2.18.0, < 2.37.2 | 2.37.2 |
Details and references
### Summary `NIOSSLCertificate._subjectAlternativeNames` provides access to the raw bytes for a cert's SANs. NIOSSL provides access to a buffer assumed to be backed by an `ASN1_STRING`, but not all SANs are backed by `ASN1_STRING`, so accessing the buffer for such a type can lead to out-of-bounds memory access. ### Details When building the byte view of a subject alternative name, NIOSSL reads the `ASN1_STRING` member of the BoringSSL `GENERAL_NAME` union for every entry without checking the name's type. The union only holds an `ASN1_STRING` for the string-shaped GeneralName types (`dNSName`, `rfc822Name`, `uniformResourceIdentifier`, `iPAddress`). For the other types (`otherName`, `x400Address`, `directoryName`, `ediPartyName`, `registeredID`) the union holds a different structure, so this reads the buffer's base pointer and length out of unrelated memory. The SAN list is parsed from an X.509 certificate, which is untrusted in the usual TLS/mTLS case, and `contents` is reachable through the public, albeit underscored, `_subjectAlternativeNames()` API. NIOSSL should only interpret the union as an `ASN1_STRING` for the string-shaped types and expose empty contents for the rest. ### PoC ```swift // A certificate whose SAN extension carries a non-string GeneralName (an `otherName`) // followed by a `dNSName`. Created with: // openssl req -x509 -newkey ec -pkeyopt ec_paramgen_curve:prime256v1 -sha256 -days 3650 -nodes \ // -keyout key.pem -out cert.pem -subj '/CN=example.com' \ // -addext 'subjectAltName=otherName:1.3.6.1.4.1.311.20.2.3;UTF8:upn@example.com,DNS:example.com' let certWithOtherNameSAN = """ -----BEGIN CERTIFICATE----- MIIBvTCCAWKgAwIBAgIUG5kO7W4Q1Iegri+QiAVHM/U31kEwCgYIKoZIzj0EAwIw FjEUMBIGA1UEAwwLZXhhbXBsZS5jb20wHhcNMjYwNzA3MTcyNDUxWhcNMzYwNzA0 MTcyNDUxWjAWMRQwEgYDVQQDDAtleGFtcGxlLmNvbTBZMBMGByqGSM49AgEGCCqG SM49AwEHA0IABLiGGM7RdaZShwg6MY//g7ir6KBD+mdSAurHLKNCk0st89Gto1ab zzOWNaRFy5D851aF+xDxo6t3tlAXvFhKEW2jgY0wgYowHQYDVR0OBBYEFOCHFhfI biL4d3CFvgMxL88RiUE5MB8GA1UdIwQYMBaAFOCHFhfIbiL4d3CFvgMxL88RiUE5 MA8GA1UdEwEB/wQFMAMBAf8wNwYDVR0RBDAwLqAfBgorBgEEAYI3FAIDoBEMD3Vw bkBleGFtcGxlLmNvbYILZXhhbXBsZS5jb20wCgYIKoZIzj0EAwIDSQAwRgIhAPC/ NL85+5HvlzDn6BFkG8MEEfFM+tIi1Bc00qcNWr3lAiEAszKnEc5QUNdoRbagZOGs b7zWUh0L+LBUmEO6a6XsJp0= -----END CERTIFICATE----- """ let cert = try NIOSSLCertificate(bytes: .init(certWithOtherNameSAN.utf8), format: .pem) for name in cert._subjectAlternativeNames() { _ = Array(name.contents) // OOB read for the otherName entry } ``` ### Impact All uses of this API internally are unaffected, because they first switch over the `type` property and only access the `contents` of specific types, all of which are string-backed. Users of this underscored API who are accessing the byte views of the subject alternative names directly, without switching on `type` are affected. Such users should either upgrade to a NIOSSL version that contains a fix, or switch on the `type`.
- Severity from
- GitHub (reviewed advisory)
More Apple advisories
All Apple| Date | Advisory | Severity | Fixed in |
|---|---|---|---|
| Jul 17 | Unauthenticated out-of-bounds stack write via oversized ECDSA signature in swift-nio-ssh | Critical | 0.14.1 |
| Jul 16 | Double-free when parsing RSA public key fails | Critical | 4.5.1 |
| Jul 9 | Apple FileMaker Server: code execution | Medium4.9 | 26.0.1 |
| Jul 9 | DoS via WebSocket frame with oversize 64-bit payload length field (Int trap in WebSocketFrameDecoder) | High7.5 | 2.101.0 |
| Jul 8 | Packages can be read/written outside the configured cache directory | Medium | 0.32.0 |
| Jul 8 | Remote packages can read files past a local package dependency root | Low | 0.32.0 |