---
title: "Hash function security (preimage, second-preimage, PRF)"
description: "SHA-2 and SHA-3 cannot be inverted, and no second input with the same output as a given input can be found. Schemes that rely on it, evidence of hardness, and best known attacks."
url: "https://pqt-19a6ffd695e12a.pages.dev/assumptions/hash-functions/"
site: "PQ Tracker, maintained by zkSecurity"
reviewed: "2026-11-25"
license: "https://creativecommons.org/licenses/by/4.0/"
---

# Hash function security (preimage, second-preimage, PRF)

Hash functions · Hardness assumption

SHA-2 and SHA-3 cannot be inverted, and no second input with the same output as a given input can be found.

**zkSecurity** · Reviewed 2026-11-25

## Statement

For a hash function H with n-bit output:

- **Preimage resistance.** Given y, it is infeasible to find x with H(x) = y.
- **Second-preimage resistance.** Given x, it is infeasible to find x′ ≠ x with H(x′) = H(x). Hash-based signatures require the multi-target form.
- **Pseudorandomness.** Keyed with a secret, H is indistinguishable from a random function.

Collision resistance is not required. SLH-DSA and XMSS are constructed so that a collision chosen by the attacker does not yield a forgery.

## Use in schemes

- **SLH-DSA.** Security reduces to multi-target second-preimage-type properties of a tweakable hash, PRF security, and interleaved target subset resilience of the message hash.
- **XMSS.** Proof in the standard model from second-preimage resistance and PRF security.
- **LMS.** Proof in the [random oracle model](https://pqt-19a6ffd695e12a.pages.dev/assumptions/random-oracle-model/).
- Every other scheme in this tracker also uses a hash function, in its transform or for message hashing. Hash-based signatures require no further assumption.

## Evidence of hardness

SHA-2 has been public since 2001 and Keccak (SHA-3) since 2008. No attack approaches the preimage resistance of either.

## Best known attacks

- **Generic search.** About 2^n evaluations for a preimage or second preimage.
- **Quantum.** Grover's algorithm requires about 2^n/2 sequential evaluations and parallelizes poorly. Hash outputs of 128, 192 and 256 bits correspond to NIST categories 1, 3 and 5.

## Limitations

- **Instantiation.** In 2022 the category 5 SPHINCS+ parameter sets using SHA-256 were shown to fall about 40 bits short of their claim, owing to SHA-256's 256-bit internal state. FIPS 205 uses SHA-512 at categories 3 and 5.
- **Instantiation, 2026.** Two preprints apply herding to SHA-256's chaining state to obtain multi-target second-preimage attacks on the message hashing of LMS and XMSS. With 2^64 signatures the estimated cost for SHA-256 parameter sets falls from 2^256 to about 2^160. The attacks are infeasible and unreviewed. SHAKE256 parameter sets are not affected.
- **State.** LMS and XMSS are secure only if each one-time key is used once. A restored backup, a cloned machine or a crash between signing and state update is a complete break.
- **Faults.** A single induced fault during signing can cause reuse of a one-time key and permit forgery. Demonstrated with Rowhammer against SLH-DSA in OpenSSL and by laser against XMSS verification on a microcontroller.

## Other uses

Hash-based proof systems (STARKs and other FRI-based arguments) rest on the same family of assumptions, including collision resistance, together with the random oracle model. Pairing-based proof systems rest on discrete-logarithm assumptions and are not post-quantum.

## Record

2 entries · [Feed](https://pqt-19a6ffd695e12a.pages.dev/feed/)

- 2026-10-24 · Reduced security margin · Action: monitor · [Preprints: herding attacks lower security of SHA-256 LMS/HSS and XMSS parameter sets](https://pqt-19a6ffd695e12a.pages.dev/feed/2026-10-24-preprints-herding-attacks-lower-security-of-sha/)
- 2022-08-15 · Reduced security margin · No action required · [Forgery attack on category-5 SPHINCS+ SHA-256 parameter sets, about 40 bits under target](https://pqt-19a6ffd695e12a.pages.dev/feed/2022-08-15-forgery-attack-on-category-5-sphincs-sha-256-par/)

- **Status**: Standing
- **Studied since**: 1979 (Hash-based signatures: Lamport and Merkle, 1979. SHA-2: 2001. SHA-3: 2015)
- **Exploitable structure**: None
- **Worst-case reduction**: Not applicable
- **Quantum speedup**: Quadratic at most (Grover)

### Relied on by

- **[ML-KEM](https://pqt-19a6ffd695e12a.pages.dev/algorithms/ml-kem/)** (SHA-3 / SHAKE used as XOF, PRF and KDF)
- **[ML-DSA](https://pqt-19a6ffd695e12a.pages.dev/algorithms/ml-dsa/)** (SHAKE used for sampling, hashing and the challenge)
- **[SLH-DSA](https://pqt-19a6ffd695e12a.pages.dev/algorithms/slh-dsa/)** (Security reduces to second-preimage-type properties and PRF security of SHA-2 or SHAKE; no number-theoretic or lattice assumption)
- **[FN-DSA](https://pqt-19a6ffd695e12a.pages.dev/algorithms/fn-dsa/)** (SHAKE256 hash-to-point)
- **[HQC](https://pqt-19a6ffd695e12a.pages.dev/algorithms/hqc/)** (SHAKE256 used as XOF and KDF)
- **[LMS / HSS](https://pqt-19a6ffd695e12a.pages.dev/algorithms/lms-hss/)** (Security reduces to second-preimage resistance of SHA-256 / SHAKE256 (proof in the random oracle model))
- **[XMSS / XMSS^MT](https://pqt-19a6ffd695e12a.pages.dev/algorithms/xmss/)** (Security reduces to (multi-target) second-preimage resistance and PRF security of the hash, in the standard model)
- **[X25519MLKEM768](https://pqt-19a6ffd695e12a.pages.dev/algorithms/hybrid-tls-x25519mlkem768/)** (The TLS 1.3 key schedule (HKDF) combines both shared secrets)
- **[FrodoKEM](https://pqt-19a6ffd695e12a.pages.dev/algorithms/frodokem/)** (SHAKE or AES used to expand the public matrix)
- **[NTRU+](https://pqt-19a6ffd695e12a.pages.dev/algorithms/ntru-plus/)** (SHAKE and SHA-3 in the transforms)
- **[SMAUG-T](https://pqt-19a6ffd695e12a.pages.dev/algorithms/smaug-t/)** (SHAKE as XOF and in the samplers)
- **[HAETAE](https://pqt-19a6ffd695e12a.pages.dev/algorithms/haetae/)** (SHAKE for sampling and the challenge)
- **[AIMer](https://pqt-19a6ffd695e12a.pages.dev/algorithms/aimer/)** (SHAKE-based hashes modelled as random oracles; PRF security of one of them)
- **[FAEST](https://pqt-19a6ffd695e12a.pages.dev/candidates/#faest)** (AES as a one-way function, plus hash security)
- **[MQOM](https://pqt-19a6ffd695e12a.pages.dev/candidates/#mqom)** (Plain MQ, no trapdoor)
- **[SDitH](https://pqt-19a6ffd695e12a.pages.dev/candidates/#sdith)** (Plain syndrome decoding, no trapdoor)

### Consequence of failure

Every scheme in this tracker is affected, since all use a hash function. Hash-based signatures are the schemes that require nothing else.

### Related

[Random oracle model](https://pqt-19a6ffd695e12a.pages.dev/assumptions/random-oracle-model/)

**References (6)**

- [Bernstein et al.: The SPHINCS+ signature framework](https://eprint.iacr.org/2019/1086)
- [Bernstein, Hülsing: Decisional second-preimage resistance: when does SPR imply PRE?](https://eprint.iacr.org/2019/492)
- [Hülsing, Rijneveld, Song: Mitigating multi-target attacks in hash-based signatures](https://eprint.iacr.org/2015/1256)
- [Buchmann, Dahmen, Hülsing: XMSS, a practical forward secure signature scheme based on minimal security assumptions](https://eprint.iacr.org/2011/484)
- [Perlner, Kelsey, Cooper: Breaking category five SPHINCS+ with SHA-256](https://eprint.iacr.org/2022/1061)
- [A Kelsey-Kohno attack variant against SHA-2 message digests in HSS/LMS and XMSS (2026 preprint)](https://eprint.iacr.org/2026/2635)

### Data

[data.json](https://pqt-19a6ffd695e12a.pages.dev/assumptions/hash-functions/data.json)
