Skip to content

CVE-2025-0343: Swift ASN.1 can crash when parsing maliciously formed BER/DER

Low severity GitHub Reviewed Published Jan 14, 2025 in apple/swift-asn1 • Updated Jan 15, 2025

Package

swift github.com/apple/swift-asn1 (Swift)

Affected versions

<= 1.3.0

Patched versions

1.3.1

Description

Swift ASN.1 can be caused to crash when parsing certain BER/DER constructions. This crash is caused by a confusion in the ASN.1 library itself which assumes that certain objects can only be provided in either constructed or primitive forms, and will trigger a preconditionFailure if that constraint isn't met.

Importantly, these constraints are actually required to be true in DER, but that correctness wasn't enforced on the early node parser side so it was incorrect to rely on it later on in decoding, which is what the library did.

These crashes can be triggered when parsing any DER/BER format object. There is no memory-safety issue here: the crash is a graceful one from the Swift runtime. The impact of this is that it can be used as a denial-of-service vector when parsing BER/DER data from unknown sources, e.g. when parsing TLS certificates.

Many thanks to @baarde for reporting this issue and providing the fix.

References

@Lukasa Lukasa published to apple/swift-asn1 Jan 14, 2025
Published to the GitHub Advisory Database Jan 14, 2025
Reviewed Jan 14, 2025
Published by the National Vulnerability Database Jan 15, 2025
Last updated Jan 15, 2025

Severity

Low

EPSS score

0.043%
(11th percentile)

Weaknesses

CVE ID

CVE-2025-0343

GHSA ID

GHSA-w8xv-rwgf-4fwh

Source code

Credits

Loading Checking history
See something to contribute? Suggest improvements for this vulnerability.