# Malicious Conflux Endpoint Can Leave Stale Global OOO Queue Accounting After Teardown

Malicious Conflux exit relay queues OOO cells then forces teardown, leaving freed memory counted in Tor's global OOO byte counter, inflating allocation toward OOM.

- Payout: $100
- Severity: low
- Program: Tor
- Found by: mudiddyt
- Disclosed: 2026-06-16
- Write-up quality: 7/10
- Original: https://hackerone.com/reports/3701692
- Library page: https://bugbountylibrary.com/r/h1%3A3701692
- Tags: area:devices domain:network impact:dos kind:bounty platform:hackerone sev:low tech:linux technique:source-review vuln:dos

**Target:** Tor Conflux OOO queue accounting (conflux.c / conflux_pool.c)
**Root cause:** conflux_free_() frees queued OOO messages without subtracting their cost from total_ooo_q_bytes and cfx->ooo_q_alloc_cost, unlike the normal dequeue path, leaving stale accounting after teardown.
**Steps:**
1. Build clean Tor at a66e072d and a patched attacker-exit Tor that emits real CONFLUX_SWITCH gap + RELAY_DATA cells on the negotiated Conflux leg.
2. Run a private Chutney network with the patched binary as exit relays and clean binary as client.
3. Attacker exit sends CONFLUX_SWITCH gap followed by RELAY_DATA cells, causing client to enqueue OOO messages (`TOR_CONFLUX_OOO_CELLS=900`).
4. Restart/replace attacker exits with clean exits to force conflux_free_() teardown before normal dequeue.
5. Read `conflux_get_total_bytes_allocation()` via gdb on the clean client; observe counter stays non-zero (e.g. 1441452) after teardown.
6. Repeat rounds to accumulate stale bytes against MaxMemInQueues.
**How found:** Code review of Conflux OOO accounting: noticed enqueue and normal dequeue both adjust total_ooo_q_bytes and ooo_q_alloc_cost symmetrically, but conflux_free_() frees queued messages without the matching subtraction, leaving a stale counter that feeds cell_queues_check_size().
**Exploitation:** Attacker-controlled Conflux-capable exit relay sends a real CONFLUX_SWITCH gap then RELAY_DATA cells through Tor's normal relay-cell send path, forcing the victim client to queue out-of-order messages. When the circuit/set is torn down before dequeue, conflux_free_() frees the messages but leaves total_ooo_q_bytes inflated. Stale bytes persist until Tor restart and count against MaxMemInQueues, potentially triggering circuits_handle_oom().
**Escalation:** Repeated rounds accumulate stale accounting; if enough accumulates, Tor's OOM recovery path (circuits_handle_oom) can close circuits. No default-config OOM PoC demonstrated.
**Insight:** When auditing memory accounting, compare every free/teardown path against the enqueue/dequeue invariant — cleanup paths that bypass the normal dequeue often skip counter decrements, leaving stale global accounting that feeds OOM logic.

## Proof of concept (copied exactly from the original report)

**PoC build and run commands**

```
mkdir -p ~/conflux-ooo-oom-check
cd ~/conflux-ooo-oom-check

git clone https://gitlab.torproject.org/tpo/core/tor.git tor-clean
git clone https://gitlab.torproject.org/tpo/core/tor.git tor-attacker-exact
git clone https://gitlab.torproject.org/tpo/core/chutney.git chutney

cp /path/to/poc-files/attacker-relay.diff ~/
cp /path/to/poc-files/chutney-network ~/
cp /path/to/poc-files/run-poc.sh ~/

Build the clean victim/network binary:

cd ~/conflux-ooo-oom-check/tor-clean
git checkout a66e072d7f3752fe98d4e59129b35b0942d4399b
./autogen.sh
./configure --disable-asciidoc
make -j"$(nproc)"

Build the attacker-exit binary:

cd ~/conflux-ooo-oom-check/tor-attacker-exact
git checkout a66e072d7f3752fe98d4e59129b35b0942d4399b
git apply ~/attacker-relay.diff
./autogen.sh
./configure --disable-asciidoc
make -j"$(nproc)"

Install Chutney dependencies if needed:

cd ~/conflux-ooo-oom-check/chutney
python3 -m venv .venv
. .venv/bin/activate
python3 -m pip install -U 'typing_extensions' 'typeguard==4.3.0' \
  'tomli-w~=1.2.0' 'paramiko~=4.0' 'cryptography~=3.4'

Allow local counter inspection with `gdb`:

# Measurement only. This does not change Tor behavior or the attack path.
sudo sysctl -w kernel.yama.ptrace_scope=0

Run the proof script:

cd ~
. ~/conflux-ooo-oom-check/chutney/.venv/bin/activate

ROUNDS=4 \
TARGET_COUNTER=1000000 \
TRAFFIC_PASSES=1 \
TRAFFIC_TIMEOUT=35 \
TOR_CONFLUX_OOO_CELLS=900 \
TOR_CONFLUX_OOO_PROBES=60 \
  bash ~/run-poc.sh
```

