cvelo
P3 · MediumCVSS 6.2EPSS <0.1%

openssl-encrypt sequential XOR cancels the last key-derivation stage

  • CVE-2026-74871
  • GHSA-vxf9-vwp6-2w43
  • PYSEC-2026-3976
  • EUVD-2026-60090

Description

Show the whole description

## Summary Files 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. ## Exploitability — preconditions (important) The flaw cancels **only the last stage** of the derivation. It is exploitable **only when BOTH** of the following hold: 1. **Exactly one KDF** is configured (e.g. Argon2 alone), **and** 2. **No prior hashing** stage precedes it. Only then does the cancellation remove the sole expensive stage, leaving just the initial `SHA256(pw‖salt)`. **Neither condition is the default — so default-configured files are NOT exploitable:** - The default uses **3 chained KDFs**, and **chained hash stages** are also on by default. - 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. A 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. ## Affected configurations - **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. - **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. ## Root cause In 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: ```python # xor_accumulator already contains the last stage's snapshot, then: sequential_result = normalize(final_chain_value) # == last stage's snapshot xor_accumulator.append(sequential_result) # XORs to 0 -> last stage cancels ``` ## Impact The 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. - **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. - **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. This 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. ## Fix Resolved 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. - 1.5.x fix: commit `fdf0c6fc` - 1.4.x backport: commit `1c122790` - Cross-line golden vector confirms v13-sequential keys match between the 1.4.x and 1.5.x implementations. - Note: v1.4.6 fixed the normal --xor v13 write path but the v1.4.8 fixes the residual library-write issue. ## Mitigation / remediation 1. **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`. 2. Identify affected files with `openssl-encrypt info -i <file>.enc`: look for `xor_mode: sequential` with `format_version` 8/10 **and** a single-KDF / no-hash derivation config. 3. Default-configured files (3 chained KDFs + chained hashes), the default mode, and independent XOR were never at risk and need no action. 4. 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. ## Discovery Found 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.

Text from the GitHub Advisory record.

Recommendation

Taken from the version ranges the sources state. Check the vendor advisory: nothing is said about versions the ranges do not list. Breaking-change risk is read from the version numbers only.

Affected

  • jahlives openssl_encrypt

    Affected versionsFixed in
    before 1.4.61.4.6
  • openssl-encryptPyPI

    Affected versionsFixed in
    before 1.4.81.4.8

Product versions from the ENISA EUVD record.

Timeline

  1. Published

Related news

No article from the followed outlets names this vulnerability.