Skip to content

Commit a31738b

Browse files
authored
Merge pull request #2142 from HackTricks-wiki/update_We_beat_Google_s_zero-knowledge_proof_of_quantum_c_20260417_131709
We beat Google’s zero-knowledge proof of quantum cryptanalys...
2 parents 03a97f7 + d8e6de1 commit a31738b

1 file changed

Lines changed: 80 additions & 8 deletions

File tree

  • src/blockchain/blockchain-and-crypto-currencies

src/blockchain/blockchain-and-crypto-currencies/README.md

Lines changed: 80 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -210,14 +210,76 @@ erc-4337-smart-account-security-pitfalls.md
210210
../smart-contract-security/mutation-testing-with-slither.md
211211
{{#endref}}
212212

213-
## References
213+
## ZK Proof / zkVM Guest Integrity
214214

215-
- [https://en.wikipedia.org/wiki/Proof_of_stake](https://en.wikipedia.org/wiki/Proof_of_stake)
216-
- [https://www.mycryptopedia.com/public-key-private-key-explained/](https://www.mycryptopedia.com/public-key-private-key-explained/)
217-
- [https://bitcoin.stackexchange.com/questions/3718/what-are-multi-signature-transactions](https://bitcoin.stackexchange.com/questions/3718/what-are-multi-signature-transactions)
218-
- [https://ethereum.org/en/developers/docs/transactions/](https://ethereum.org/en/developers/docs/transactions/)
219-
- [https://ethereum.org/en/developers/docs/gas/](https://ethereum.org/en/developers/docs/gas/)
220-
- [https://en.bitcoin.it/wiki/Privacy](https://en.bitcoin.it/wiki/Privacy#Forced_address_reuse)
215+
When a prover uses a **zkVM** or an application-specific proof circuit to attest a claim, the verifier is only learning that the **guest program executed as written**. If the guest contains **unsafe deserialization**, **undefined behavior**, or **missing semantic constraints**, a malicious prover may generate a proof that verifies while the **public metrics or claimed invariant are false**.
216+
217+
### Unsafe deserialization inside proof guests
218+
219+
- Treat private witness/circuit bytes as **untrusted attacker input** even if they are hidden by the proof.
220+
- Avoid deserializing them with unchecked helpers such as `rkyv::access_unchecked` unless the bytes were already validated out-of-band.
221+
- Enum discriminants, relative pointers, lengths, and indexes loaded from untrusted serialized data must be validated before they influence control flow or memory access.
222+
223+
Practical audit pattern:
224+
225+
```rust
226+
let private_circuit_bytes = sp1_zkvm::io::read_vec();
227+
let ops = unsafe {
228+
rkyv::access_unchecked::<rkyv::Archived<Vec<Op>>>(&private_circuit_bytes)
229+
};
230+
```
231+
232+
If a field such as `op.kind` is an enum and an attacker can inject an **out-of-range discriminant**, every downstream `match` on that value becomes suspicious.
233+
234+
### Jump-table / UB counter bypass
235+
236+
If Rust lowers a large `match` into a **jump table**, an invalid enum discriminant may produce **undefined control flow**. A dangerous pattern is:
237+
238+
1. One `match` updates **security-critical counters/constraints**.
239+
2. A second `match` performs the **real instruction semantics**.
240+
3. An out-of-range discriminant indexes past the first jump table and lands in code associated with the second one.
241+
242+
Result: the operation still executes, but the accounting path is skipped. In a zkVM this can forge proofs that report impossible metrics such as fewer gates, fewer expensive operations, or other falsified bounded resources.
243+
244+
Review checklist:
245+
246+
- Look for attacker-controlled enums deserialized from witness/private input.
247+
- Inspect repeated `match` statements over the same opcode/kind field.
248+
- Treat `unsafe` + unchecked deserialization + large opcode dispatch as a high-risk combination.
249+
- Reverse engineer the emitted binary when needed; jump-table layout can matter more than the source.
250+
251+
### Missing semantic constraints in reversible/specialized interpreters
252+
253+
Do not just validate memory safety; also validate the **semantic rules** that the proof is meant to enforce.
254+
255+
For reversible/quantum-like instruction sets, ensure operands that must be distinct are actually constrained to be distinct. A Toffoli/CCX-like operation implemented as:
256+
257+
```rust
258+
let v = cond & self.qubit(op.q_control1) & self.qubit(op.q_control2);
259+
*self.qubit_mut(op.q_target) ^= v;
260+
```
261+
262+
becomes unsafe if the guest does not reject:
263+
264+
```text
265+
op.q_control1 == op.q_control2 == op.q_target
266+
```
267+
268+
In that case the transition collapses into:
269+
270+
```text
271+
q = q ^ (q & q) = 0
272+
```
273+
274+
This creates a **deterministic reset primitive**, breaking reversibility assumptions and enabling cheaper non-intended computations. In proof systems that attest resource usage, this can let attackers satisfy functional checks while bypassing the cost model the verifier believes is being enforced.
275+
276+
### What to test in ZK systems
277+
278+
- Fuzz all guest parsers with malformed witness/private-input encodings.
279+
- Assert enum range validation before opcode dispatch.
280+
- Add semantic checks for operand aliasing and other invalid instruction forms.
281+
- Compare reported/public counters against an independent reference implementation.
282+
- Remember that a valid proof can still prove the **wrong statement** if the guest program is buggy.
221283

222284
## DeFi/AMM Exploitation
223285

@@ -233,6 +295,16 @@ For multi-asset weighted pools that cache virtual balances and can be poisoned w
233295
defi-amm-virtual-balance-cache-exploitation.md
234296
{{#endref}}
235297

236-
{{#include ../../banners/hacktricks-training.md}}
298+
## References
237299

300+
- [https://en.wikipedia.org/wiki/Proof_of_stake](https://en.wikipedia.org/wiki/Proof_of_stake)
301+
- [https://www.mycryptopedia.com/public-key-private-key-explained/](https://www.mycryptopedia.com/public-key-private-key-explained/)
302+
- [https://bitcoin.stackexchange.com/questions/3718/what-are-multi-signature-transactions](https://bitcoin.stackexchange.com/questions/3718/what-are-multi-signature-transactions)
303+
- [https://ethereum.org/en/developers/docs/transactions/](https://ethereum.org/en/developers/docs/transactions/)
304+
- [https://ethereum.org/en/developers/docs/gas/](https://ethereum.org/en/developers/docs/gas/)
305+
- [https://en.bitcoin.it/wiki/Privacy](https://en.bitcoin.it/wiki/Privacy#Forced_address_reuse)
306+
- [Trail of Bits - We beat Google's zero-knowledge proof of quantum cryptanalysis](https://blog.trailofbits.com/2026/04/17/we-beat-googles-zero-knowledge-proof-of-quantum-cryptanalysis/)
307+
- [Google patched paper version](https://arxiv.org/abs/2603.28846v2)
308+
- [Trail of Bits proof-of-concept repository](https://github.com/trailofbits/quantum-zk-proof-poc)
238309

310+
{{#include ../../banners/hacktricks-training.md}}

0 commit comments

Comments
 (0)