{"id":"GHSA-vxf9-vwp6-2w43","summary":"openssl-encrypt sequential XOR cancels the last key-derivation stage","details":"## Summary\n\nFiles encrypted in **sequential XOR** composition mode (`--xor` / `--use-xor-composition`, on-disk `format_version` 8 or 10) derive a key in which the **last stage cancels out**. The weakness is only security-relevant for a **specific, non-default configuration** (see Exploitability below). In that case the key derivation collapses to a single cheap `SHA256(password ‖ salt)`, completely bypassing the configured memory-hard KDF (e.g. Argon2) and allowing offline password guessing at plain-SHA256 speed.\n\n## Exploitability — preconditions (important)\n\nThe flaw cancels **only the last stage** of the derivation. It is exploitable **only when BOTH** of the following hold:\n\n1. **Exactly one KDF** is configured (e.g. Argon2 alone), **and**\n2. **No prior hashing** stage precedes it.\n\nOnly then does the cancellation remove the sole expensive stage, leaving just the initial `SHA256(pw‖salt)`.\n\n**Neither condition is the default — so default-configured files are NOT exploitable:**\n\n- The default uses **3 chained KDFs**, and **chained hash stages** are also on by default.\n- With multiple stages the cancellation drops only the *last* one; the surviving earlier KDF/hash snapshots remain XOR'd into the key, so the derivation stays memory-hard. The work factor is marginally reduced (one trailing stage removed), **not** bypassed.\n\nA file is therefore only at real risk if it was deliberately encrypted with a **single KDF and no preceding hash** — both departures from the shipped defaults.\n\n## Affected configurations\n\n- **Affected (on-disk):** files written in sequential XOR mode — `format_version ∈ {8, 10}`, produced by the `--xor` / `--use-xor-composition` option, **and** configured with a single KDF and no prior hashing.\n- **Not affected:** the default sequential-XOR configuration (3 chained KDFs + chained hashes); the default `format_version 9`; Independent XOR (`v11`/`v13` with `xor_mode=independent`); streaming (`v12`); and any single-algorithm (non-XOR) configuration.\n\n## Root cause\n\nIn sequential XOR mode the key is the XOR of every stage's normalized output snapshot. The code additionally appended the chain's **final** value to that accumulator — but the final value is identical to the **last stage's own snapshot** already present in the accumulator, so the two XOR to zero and the last stage drops out of the key:\n\n```python\n# xor_accumulator already contains the last stage's snapshot, then:\nsequential_result = normalize(final_chain_value)   # == last stage's snapshot\nxor_accumulator.append(sequential_result)          # XORs to 0 -\u003e last stage cancels\n```\n\n## Impact\n\nThe surviving key material is the **initial** hash snapshot `SHA256(plaintext-password ‖ original-salt)` — computed *before* the chain runs (not a derived/chained value) — XOR'd with any earlier non-final stage snapshots.\n\n- **Single KDF, no prior hash (worst case, non-default):** the sole KDF is the last stage, so it cancels entirely. The key equals the cheap initial `SHA256(pw‖salt)`, **independent of the configured KDF time/memory cost**. Offline cracking proceeds at SHA-256 speed; the advertised memory-hardness provides no protection.\n- **Multiple stages (incl. the 3-KDF + hashes default):** only the last stage cancels. Earlier KDF/hash snapshots survive in the XOR, so the key still depends on memory-hard derivation. The cost is at most marginally reduced (one trailing stage removed), not eliminated.\n\nThis is a confidentiality weakness of data at rest: it does not expose plaintext directly, but for the affected non-default configuration it drastically lowers the work factor protecting weak/medium-strength passwords. \n## Fix\n\nResolved by introducing `format_version 13`, which carries an explicit `xor_mode` field and **omits the redundant final append** so every stage contributes to the key. `--xor` now writes `v13` with `xor_mode=sequential`. Decrypt routing is keyed on the on-disk `xor_mode` field rather than the version number. The legacy v8/v10 derivation is intentionally preserved (append-only) so existing files still decrypt, but they remain weak until re-encrypted.\n\n- 1.5.x fix: commit `fdf0c6fc`\n- 1.4.x backport: commit `1c122790`\n- Cross-line golden vector confirms v13-sequential keys match between the 1.4.x and 1.5.x implementations.\n- Note: v1.4.6 fixed the normal --xor v13 write path but the v1.4.8 fixes the residual library-write issue.\n\n## Mitigation / remediation\n\n1. **Re-encrypt** any `--xor` file that used a **single KDF with no prior hashing** — this is the only at-risk configuration. Re-encrypting with a patched build writes `v13`.\n2. Identify affected files with `openssl-encrypt info -i \u003cfile\u003e.enc`: look for `xor_mode: sequential` with `format_version` 8/10 **and** a single-KDF / no-hash derivation config.\n3. Default-configured files (3 chained KDFs + chained hashes), the default mode, and independent XOR were never at risk and need no action.\n4. For genuinely affected files, treat the password as having had reduced protection and rotate it where the at-rest file may have been exposed to an adversary.\n\n## Discovery\n\nFound during an internal review of the XOR composition modes; fixed before any third-party disclosure. See `SECURITY.md` (ADVISORY 2026-02) and `openssl_encrypt/docs/FORMAT.md` §7.3 / §15 for the format-level details.","aliases":["CVE-2026-74871","PYSEC-2026-3976"],"modified":"2026-12-03T23:00:03.996238800Z","published":"2026-12-03T22:52:57Z","database_specific":{"cwe_ids":["CWE-916"],"severity":"MODERATE","github_reviewed":true,"github_reviewed_at":"2026-12-03T22:52:57Z","nvd_published_at":null},"references":[{"type":"WEB","url":"https://github.com/jahlives/openssl_encrypt/security/advisories/GHSA-vxf9-vwp6-2w43"},{"type":"WEB","url":"https://github.com/jahlives/openssl_encrypt/commit/1c122790d6d914909514dbe026d051bc06c50844"},{"type":"WEB","url":"https://github.com/jahlives/openssl_encrypt/commit/a7d2c9054f5b4374561c82665b24adfe3fad360c"},{"type":"WEB","url":"https://github.com/jahlives/openssl_encrypt/commit/e1b6731fae6ed9d6b17ecdc3b72edc3b364ee339"},{"type":"PACKAGE","url":"https://github.com/jahlives/openssl_encrypt"},{"type":"WEB","url":"https://github.com/jahlives/openssl_encrypt/releases/tag/v1.4.8"},{"type":"WEB","url":"https://github.com/pypa/advisory-database/blob/main/vulns/openssl-encrypt/PYSEC-2026-3976.yaml"},{"type":"ADVISORY","url":"https://nvd.nist.gov/vuln/detail/cve-2026-74871"},{"type":"WEB","url":"https://www.vulncheck.com/advisories/openssl-encrypt-before-kdf-bypass-via-sequential-xor"}],"affected":[{"package":{"name":"openssl-encrypt","ecosystem":"PyPI","purl":"pkg:pypi/openssl-encrypt"},"ranges":[{"type":"ECOSYSTEM","events":[{"introduced":"0"},{"fixed":"1.4.8"}]}],"versions":["0.2.2","0.2.3","0.2.4","0.2.5","0.2.6","0.3.0","0.3.1","0.3.2","0.3.3","0.4.0","0.4.1","0.4.2","0.4.3","0.4.4","0.5.0","0.5.1","0.5.3","0.6.0rc1","0.7.0rc2","0.7.1","0.7.2","0.8.0","0.8.1","0.8.2","0.9.2","1.0.0","1.0.1","1.0.2","1.0.3","1.1.0","1.2.0","1.2.1","1.3.0","1.3.1","1.3.2","1.3.3","1.3.4","1.3.5","1.4.0","1.4.0b3","1.4.0b4","1.4.0b5","1.4.0b6","1.4.0b7","1.4.0b8","1.4.1","1.4.1rc2","1.4.2","1.4.4","1.4.5","1.4.6","1.4.7"],"database_specific":{"source":"https://github.com/github/advisory-database/blob/main/advisories/github-reviewed/2026/12/GHSA-vxf9-vwp6-2w43/GHSA-vxf9-vwp6-2w43.json"}}],"schema_version":"1.9.2","severity":[{"type":"CVSS_V3","score":"CVSS:3.1/AV:L/AC:L/PR:N/UI:N/S:U/C:H/I:N/A:N"}]}