cryptofreemedium

Untrusted Node

HackTheBox

The challenge simulates an attack on a BB84-like Quantum Key Distribution (QKD) protocol. We play the role of a compromised Trusted Node between Transmitter (Alice) and Receiver (Bob). The goal is to intercept the quantum key, encrypt the command `TX|FETCH|SECRET`, and send it to the Receiver to obt

$ ls tags/ techniques/
bb84_mitm_attackdual_basis_measurementbasis_reconciliation_exploitationphoton_number_splitting

$ cat /etc/rate-limit

Rate limit reached (20 reads/hour per IP). Showing preview only — full content returns at the next hour roll-over.

Untrusted Node — HackTheBox

Description

The challenge simulates an attack on a BB84-like Quantum Key Distribution (QKD) protocol. We play the role of a compromised Trusted Node between Transmitter (Alice) and Receiver (Bob). The goal is to intercept the quantum key, encrypt the command TX|FETCH|SECRET, and send it to the Receiver to obtain the flag.

Protocol

  1. Transmitter generates 128 random bits and 128 random bases (gates: 0=Z, 1=X)
  2. For each bit, k identical copies of the qubit are created (k = Poisson(λ=2) + 2, i.e., k ≥ 2, average ~4)
  3. Qubits are sent through the Trusted Node (us) to the Receiver
  4. We can measure any qubits in a chosen basis or pass them through (-1) to the Receiver
  5. Receiver measures the received qubits in random bases
  6. Basis reconciliation phase: TX compares its bases with the ones we pass (we can substitute them)
  7. Where bases match — those bits form the key, hashed with SHA256
  8. The key is used for XOR encryption of commands

Source Files

  • server.py — TrustedNode: accepts our gates, measures/passes qubits
  • transmitter.py — Alice: generates qubits, checks basis matches
  • receiver.py — Bob: measures qubits, processes commands, stores FLAG
  • util.py — XOR, validate_entropy (≥64 bits, binomial test p > 0.01)

Analysis

Key Vulnerability: Photon Number Splitting (PNS)

In real BB84, each qubit is a single photon, and measurement destroys the state. Here TX creates k ≥ 2 identical copies of each qubit. This is the classic PNS vulnerability — we can take some copies for ourselves while forwarding the rest to Bob without distortion.

Dual Measurement in Both Bases

...

$ grep --similar

Similar writeups