Skip to content
AppleGHSA-8q93-f6xh-4f6f

Double-free when parsing RSA public key fails

CriticalCVE-2026-43823 · Published Jul 16, 2026 · updated Aug 10, 2026

### Summary When initializing an RSA public key from DER or PEM bytes throws an error, the `EVP_PKEY*` is double-freed: first in the catch block, then in the `deinit`. This can lead to a crash on future memory allocations. This double-free manifests when BoringSSL cannot decode the public key from the bytes provided. ### PoC The following tests will reliably trigger an error when run with address sanitizer enabled: ```swift func test_invalidDERPublicKeyThrowsWithoutDoubleFree() throws { // SEQUENCE { INTEGER 0, INTEGER 0 } let badBase64 = "MAYCAQACAQ==" let badDER = Array(Data(base64Encoded: badBase64)!) XCTAssertThrowsError(try _RSA.Signing.PublicKey(derRepresentation: badDER)) } func test_invalidPEMPublicKeyThrowsWithoutDoubleFree() throws { // SEQUENCE { INTEGER 0, INTEGER 0 } let badPEM = """ -----BEGIN PUBLIC KEY----- MAYCAQACAQ== -----END PUBLIC KEY----- """ XCTAssertThrowsError(try _RSA.Signing.PublicKey(pemRepresentation: badPEM)) } ``` ### Impact Uses of `_RSA.Encryption.PublicKey`, `_RSA.Signing.PublicKey`, and `_RSA.BlindSigning.PublicKey` are af...

GitHub advisory

Affected versions

PackageAffectedFixed in
swift-crypto
Product
>= 3.2.0, < 4.5.14.5.1
Details and references

### Summary When initializing an RSA public key from DER or PEM bytes throws an error, the `EVP_PKEY*` is double-freed: first in the catch block, then in the `deinit`. This can lead to a crash on future memory allocations. This double-free manifests when BoringSSL cannot decode the public key from the bytes provided. ### PoC The following tests will reliably trigger an error when run with address sanitizer enabled: ```swift func test_invalidDERPublicKeyThrowsWithoutDoubleFree() throws { // SEQUENCE { INTEGER 0, INTEGER 0 } let badBase64 = "MAYCAQACAQ==" let badDER = Array(Data(base64Encoded: badBase64)!) XCTAssertThrowsError(try _RSA.Signing.PublicKey(derRepresentation: badDER)) } func test_invalidPEMPublicKeyThrowsWithoutDoubleFree() throws { // SEQUENCE { INTEGER 0, INTEGER 0 } let badPEM = """ -----BEGIN PUBLIC KEY----- MAYCAQACAQ== -----END PUBLIC KEY----- """ XCTAssertThrowsError(try _RSA.Signing.PublicKey(pemRepresentation: badPEM)) } ``` ### Impact Uses of `_RSA.Encryption.PublicKey`, `_RSA.Signing.PublicKey`, and `_RSA.BlindSigning.PublicKey` are affected. Calling these types initializers with a malformed key will trigger a double-free. Applications that parse untrusted RSA keys using these APIs are affected. ### Credits We would like to acknowledge Sujal Tuladhar for their assistance.

Severity from
GitHub (reviewed advisory)

More Apple advisories

All Apple

Critical advisories by email

Wednesdays: the week’s critical and high advisories in the AI and data stack, with the fixed versions. Only in weeks that have some.

Double opt-in. Unsubscribe any time.