CVE-2025-0343: CVE-2025-0343 Swift ASN.1 Can Crash When Vulnerability

LOW
Advisory Identifier: GHSA-w8xv-rwgf-4fwh
CWE-228
Published
Advisory Summary

CVE-2025-0343 is a LOW swift asn.1 can crash when vulnerability (CWE-228: Improper Handling of Syntactically Invalid Structure) affecting CVE-2025-0343 libraries in the SwiftURL ecosystem. The issue involves swift asn.1 can crash when parsing maliciously formed ber/der. Remediation is available by upgrading affected packages to version 1.3.1.

CVE-2025-0343 at a Glance

CVE Identifier CVE-2025-0343
GHSA Identifier GHSA-w8xv-rwgf-4fwh
Severity LOW
CVSS v3.1 Base Score N/A
CWE Classification CWE-228: Improper Handling of Syntactically Invalid Structure
Affected Product CVE-2025-0343
Package Ecosystem SwiftURL
Published Date
Last Updated

How to Fix CVE-2025-0343

To remediate this vulnerability, upgrade all affected CVE-2025-0343 dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.

github.com/apple/swift-asn1 fixed: 1.3.1
Upgrade github.com/apple/swift-asn1 to 1.3.1
Verify Direct and Transitive Dependencies

Run the following command in your project directory to verify that all resolved dependencies use the patched release:

inspect dependencies for github.com/apple/swift-asn1

How to Check if You Are Affected

To determine whether your application is affected by CVE-2025-0343, inspect your project dependencies for CVE-2025-0343:

inspect dependencies for github.com/apple/swift-asn1

Analyze the terminal output to locate any version of CVE-2025-0343 in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 1.3.1), your application is affected.

Note: Verify declared build manifests and deployed runtime container environments.

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-228: Improper Handling of Syntactically Invalid Structure, where the product does not handle or incorrectly handles input that is not syntactically well-formed with respect to the associated specification. In CVE-2025-0343, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.

Source Advisory Statement

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.

CVE-2025-0343 Affected CVE-2025-0343 Versions

1 component(s)
Fixed Versions:
1.3.1
Product / Package Ecosystem Affected Versions Fixed Version
github.com/apple/swift-asn1
SwiftURL
< 1.3.1
1.3.1

References

Frequently Asked Questions

What is CVE-2025-0343?
CVE-2025-0343 is a security vulnerability in CVE-2025-0343 involving Swift ASN.1 can crash when parsing maliciously formed BER/DER under CWE-228: Improper Handling of Syntactically Invalid Structure.
Which CVE-2025-0343 versions are affected?
Affected versions include releases prior to 1.3.1 across affected packages: github.com/apple/swift-asn1.
What version fixes CVE-2025-0343?
Upgrading to 1.3.1 (or the latest patched release for your respective branch) resolves the vulnerability.
Is github.com/apple/swift-asn1 affected?
Yes, github.com/apple/swift-asn1 is affected in releases prior to 1.3.1. Upgrade your dependency to 1.3.1 or later.
What CWE is associated with CVE-2025-0343?
CVE-2025-0343 is classified under CWE-228: Improper Handling of Syntactically Invalid Structure (The product does not handle or incorrectly handles input that is not syntactically well-formed with respect to the associated specification.).
How can I check SwiftURL dependencies for CVE-2025-0343?
Run the dependency tree command: 'inspect dependencies for github.com/apple/swift-asn1'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "schema_version" : "1.4.0",
  "id" : "GHSA-w8xv-rwgf-4fwh",
  "modified" : "2025-01-15T15:26:01Z",
  "published" : "2025-01-14T16:32:07Z",
  "aliases" : [ "CVE-2025-0343" ],
  "summary" : "CVE-2025-0343: Swift ASN.1 can crash when parsing maliciously formed BER/DER",
  "details" : "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.\n\nImportantly, 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.\n\nThese 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.\n\nMany thanks to @baarde for reporting this issue and providing the fix.",
  "severity" : [ ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "SwiftURL",
      "name" : "github.com/apple/swift-asn1"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "1.3.1"
      } ]
    } ],
    "database_specific" : {
      "last_known_affected_version_range" : "<= 1.3.0"
    }
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/apple/swift-asn1/security/advisories/GHSA-w8xv-rwgf-4fwh"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2025-0343"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/apple/swift-asn1/commit/ae33e5941bb88d88538d0a6b19ca0b01e6c76dcf"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/apple/swift-asn1"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-228" ],
    "severity" : "LOW",
    "github_reviewed" : true,
    "github_reviewed_at" : "2025-01-14T16:32:07Z",
    "nvd_published_at" : "2025-01-15T01:15:13Z"
  }
}