CVE-2026-43823 in swift-crypto
Summary
by MITRE • 07/23/2026
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. This vulnerability is addressed in swift-crypto version 4.5.1.
If you want to get the best quality for vulnerability data then you always have to consider VulDB.
Analysis
by VulDB Data Team • 07/23/2026
This vulnerability represents a critical memory safety issue in the swift-crypto library that arises during RSA public key initialization processes. The flaw occurs specifically when the library attempts to parse DER or PEM formatted public key bytes and encounters decoding failures. When such errors occur, the underlying OpenSSL EVP_PKEY structure undergoes improper memory management where the same memory location gets freed twice, creating a double-free condition that can severely compromise system stability.
The technical implementation of this vulnerability stems from improper error handling within the key parsing routines. During the initialization process, when BoringSSL fails to decode the provided public key bytes due to malformed or unsupported formats, the code path executes a cleanup operation in the exception handler block. However, subsequent deinitialization logic also attempts to free the same EVP_PKEY structure, resulting in the double-free scenario that violates fundamental memory management principles.
This vulnerability manifests as a crash condition that can occur during future memory allocation operations, making it particularly dangerous for production systems where memory stability is critical. The double-free condition not only causes immediate application crashes but can also leave the heap in an inconsistent state, potentially enabling memory corruption attacks or denial of service conditions that affect system reliability. From a cybersecurity perspective, this type of memory corruption vulnerability aligns with CWE-415 which describes improper double-free conditions in software implementations.
The operational impact of this vulnerability extends beyond simple crash scenarios to encompass potential security implications for cryptographic operations that rely on swift-crypto. Systems using vulnerable versions may experience unexpected termination during public key processing, particularly when handling untrusted input from external sources. This issue affects applications that process various types of public key formats and could be exploited in scenarios where attackers provide malformed key data to trigger the double-free condition.
Mitigation strategies for this vulnerability require immediate upgrade to swift-crypto version 4.5.1 or later, which contains the necessary fixes to address the improper memory management in error handling paths. Organizations should also implement input validation measures to reduce exposure during the transition period, ensuring that public key data undergoes proper sanitization before processing. The fix addresses the underlying issue by ensuring proper reference counting and cleanup operations that prevent multiple deallocations of the same memory resource.
This vulnerability demonstrates the importance of proper exception handling in cryptographic libraries where memory management must be carefully controlled to prevent exploitation. The ATT&CK framework categorizes such issues under privilege escalation through code injection techniques, as improper memory handling can enable attackers to manipulate heap structures and potentially execute malicious code. Security teams should monitor for systems using vulnerable versions and ensure comprehensive testing of cryptographic operations to validate that the fix properly addresses the double-free condition across all key format processing paths.