Security #9085
closedtftp: unbounded transaction retention in one-way flows
b9cd2e37f90698816998f89137764e955745683a
Description
Summary¶
Suricata's TFTP parser creates every transaction with AppLayerTxData::new(),
which the FFI layer documents as being "for a transaction that covers both
directions" and which leaves the tx flags at 0.
AppLayerParserTransactionsCleanup() will only free a transaction once each
direction is either inspected or explicitly marked skip-inspect. On a flow
where Suricata never sees a TOCLIENT payload, the TOCLIENT bit can never be
set, so no TFTP transaction is ever freed and every subsequent packet
re-walks the whole list from transaction 0.
This is the same defect you fixed for DHCP and RDP in 8.0.6
(GHSA-m2vc-g65c-ph7m / CVE-2026-57224). Your own fix commit bac8a69ca states
the mechanism and lists the parsers that already use for_direction(). TFTP
is not in that list and was not changed. It still calls new() on main, on
main-8.0.x (= tag suricata-8.0.7) and on main-7.0.x.
The difference from the DHCP case is reachability, and it is what raises
the severity. TFTP runs over routable UDP/69, not link-local broadcast, so
any unauthenticated party who can get UDP datagrams across a monitored
segment can drive this. No TFTP server has to exist. The attacker sends
RRQ-shaped datagrams from one constant source port to any destination on
port 69; Suricata builds a transaction per datagram from the client side
alone. A destination that actively rejects with ICMP port-unreachable does
not help (measured). TFTP is enabled: yes in the shipped suricata.yaml.in and
in the official release image's /etc/suricata/suricata.yaml, so a default
build with the default config and zero rules loaded is affected.
Measured on stock jasonish/suricata:8.0.7, stock config, no rules: 10,000 ×
62-byte datagrams (620,000 bytes, 605 KiB) consumed 101.2 CPU-seconds on
the worker handling that flow. The identical 10,000 transactions delivered
with any traffic in the reverse direction on the same 5-tuple cost 0.698 s
— a 145× difference. Cost grows as roughly n³ (measured exponent 2.96–2.98
above N=3,000), so marginal cost keeps climbing: over the last 4,000
datagrams each cost 19.7 ms of CPU, after which ~3.1 KiB/s sustains a
pinned worker thread. Flows are steered to one thread by hash (
src/tmqh-flow.c:226-227, default cluster_flow / autofp-scheduler: hash), so
distinct source ports spread across workers; ~9.9 MB across 16 such flows
is the arithmetic for a 16-worker sensor (reasoning, not measured — see
"What I did not test").
The product prints the proof itself. On a --enable-debug build at the ref
below, a 200-datagram one-way TFTP flow yields 0 frees and
20,100 tx_skipped — exactly 200·201/2, which is only possible if min_id never
advances and every packet restarts the walk at transaction 0. The same
binary, same harness, frees all 200 for bidirectional TFTP and all 200 for
DHCP on the fixed parser.
Preconditions and privilege required¶
Stated up front, so nothing here is overclaimed:
- Privilege: none. No authentication, no credentials, no interaction
with any host — only the ability to emit UDP datagrams that traverse a
segment Suricata monitors. - Config: stock. tftp: enabled: yes — suricata.yaml.in:1109-1110 on
main, :1092-1093 at tag suricata-8.0.7,
/etc/suricata/suricata.yaml:1092-1093 inside the official release image. - Rules: none needed. Both measured arms ran with zero rules loaded.
Loading one rule changes txd->flags from 00 to 04 (
APP_LAYER_TX_INSPECTED_TS) and nothing else — frees stay at 0. - Detection engine must be on — the guard sits behind has_tx_detect_flags
= !g_detect_disabled (src/app-layer-parser.c:997). --disable-detection avoids
it; that is not a defensible sensor configuration, so I do not count it as
a workaround. - No TFTP server required, at the destination or anywhere. The one-way
TFTP pcaps (oneway_N, onewayn60_5000) contain no server-originated
packet at all. The only server-side frames anywhere in the set are the two
deliberate controls: bidir_N's DATA blocks and onewayicmp_3000's ICMP
errors. - AV:N depends on TFTP being routable UDP/69 rather than link-local. That
is the one assumption carrying the severity delta over your DHCP advisory,
stated plainly rather than buried. It is not a TFTP-semantics assumption:
the attacker never needs a reply, so RFC 1350 server behaviour is
irrelevant to whether the flow stays one-directional.
Mechanism¶
Verified by hand at origin/main = d996d85dcfbf1349acf54d942abc86a13f9e699f,
tip 2026-09-12 16:12:26 -0600 (fresh clone, 2026-09-17). Line numbers for
main first; suricata-8.0.7 in parentheses. Full ref list at the end.
1 — the transaction is born claiming both directions.
rust/ffi/src/applayer.rs:352-360 (8.0.7: rust/src/applayer.rs:184-205) —
AppLayerTxData::new(), doc-commented "Create new AppLayerTxData for a
transaction that covers both directions"; it sets updated_tc/ts: true and
leaves flags at its Default of 0. :364-375 (8.0.7: :207-…) —
for_direction(Direction::ToServer) instead sets APP_LAYER_TX_SKIP_INSPECT_TC
and updated_tc: false. rust/src/tftp/tftp.rs:73 (8.0.7 and 7.0.x: :72) —
TFTPTransaction::new() calls AppLayerTxData::new(), so every TFTP
transaction starts with flags == 0. (tftp.rs:224/:238 on main, :225/:239 on
8.0.7 and 7.0.x, also call new() but sit inside #[cfg(test)] mod test,
which begins at :189 on main and :193 on 8.0.7/7.0.x; :73/:72 is the only
production site.)
2 — cleanup refuses to free a transaction whose TOCLIENT side is neither
inspected nor skipped. src/app-layer-parser.c:1077-1085 (8.0.7: :981-989):
if (!IS_DISRUPTED(tc_disrupt_flags) &&
(f->sgh_toclient != NULL || (f->flags & FLOW_SGH_TOCLIENT) == 0)) {
if ((txd->flags & (APP_LAYER_TX_INSPECTED_TC |
APP_LAYER_TX_SKIP_INSPECT_TC)) == 0)
tx_skipped = true;
}
APP_LAYER_TX_INSPECTED_TC (BIT_U8(3) = 0x08, src/app-layer-parser.h:52) is
set by src/detect.c:2703 only after detection actually runs TOCLIENT, which
requires a TOCLIENT payload packet. APP_LAYER_TX_SKIP_INSPECT_TC (0x02,
rust/ffi/src/applayer.rs:70) is written by for_direction() at :366 and,
separately, by src/app-layer-dnp3.c:519 — TFTP goes through neither.
IS_DISRUPTED (:979) can only matter for TCP: FlowGetDisruptionFlags() (
src/flow.c:1170-1174) returns its flags unchanged for non-TCP, so that
escape never fires on a UDP flow. With no TOCLIENT packet ever seen,
FLOW_SGH_TOCLIENT is never set (src/detect.c:431-434), so (f->flags &
FLOW_SGH_TOCLIENT) == 0 is true and the guard always fires.
3 — the skip is unconditional and the free is unreachable. :1088-1092
(8.0.7: :992-996) if (tx_skipped) { skipped = true; goto next; }, so
p->StateTransactionFree(alstate,
i) at :1121 (8.0.7: :1025) is never reached and new_min at :1126-1127 is
never raised. alparser->min_id stays 0 for the life of the flow.
4 — that turns a linear walk into a cubic one. Each packet's cleanup
restarts at min_id and walks to total_txs via AppLayerDefaultGetTxIterator (
:748-773); each step calls SCTftpGetTx → TFTPState::get_tx_by_id (
rust/src/tftp/tftp.rs:53-55), itself a linear iter().find() over the
vector. One pass over k retained transactions therefore costs ~k²/2
comparisons, and n packets ~n³/6. TFTP registers no custom iterator and no
max-tx cap (src/app-layer-tftp.c:210-219), and
AppLayerParserRegisterStateProgressCompletionStatus(ALPROTO_TFTP,1,1) at
:214 plus TFTPGetStateProgress() returning a constant 1 (:150-153) makes
every transaction "parser-complete" the instant it is created, so the
progress guards at :1052/:1061 never hold it back — each transaction is
complete, freeable in principle, immortal in practice.
5 — why the attacker needs no server. TFTPProbingParser (
src/app-layer-tftp.c:77-89) accepts any UDP payload of ≥ 4 bytes whose
first byte is 0x00, on default detection port "69" (:38), registered
TOSERVER-only; TFTPParseResponse (:118-125) is a documented no-op
("Response parsing is not implemented"), so even a reply could not advance
TOCLIENT parser state — only detection running TOCLIENT sets the bit.
Reproduction¶
Benign, local, non-destructive: synthetic pcaps replayed through suricata -r in
a container, nothing sent to any network. Attached: the generators (
mkpcap130.py, mkpcap130b.py), the runners (run_stock.py, armA_freecount.sh,
armA_rules.sh) and the pcaps. Every TFTP frame in every pcap belongs to one
UDP flow — 10.0.0.2:40000 ↔ 10.0.0.1:69, client→server except for the
bidir_N server frames — spaced 1 ms apart. Frames are 62 bytes wherever the
filename is 11 characters, and 111 bytes in onewayn60_5000, whose filename
is 60. The non-TFTP frames deliberately differ: dhcp_200 is 291-byte frames
on 0.0.0.0:68 → 255.255.255.255:67, and the 60 ICMP frames inside
onewayicmp_3000 are 70 bytes between 10.0.0.1 and 10.0.0.2, carrying no
ports at all. artifacts/pcap_manifest.txt records frame counts and sizes
for twelve of the fourteen pcaps; onewayicmp_3000 (from mkpcap130b.py) and
oneway_5000 postdate that manifest and are not listed in it. oneway_N is N
RFC 1350 RRQs (0x0001 | 11-char filename | \0 | octet | \0) client→server
only; bidir_N adds a server DATA block on the same 5-tuple every 50th
packet; onewayicmp_3000 adds an ICMP type 3 code 3 from the target every
50th packet; dhcp_200 is one-directional DHCP DISCOVERs.
# stock release, stock config, zero rules docker run --rm -v $PWD/pcaps:/pcaps:ro -v $PWD/out:/out --entrypoint suricata \ jasonish/suricata:8.0.7 -r /pcaps/oneway_10000.pcap -l /out -c /etc/suricata/suricata.yaml -k none # instrumented build - where the counters come from ./configure --enable-debug && make SC_LOG_LEVEL=Debug ./src/suricata -r oneway_200.pcap -l log -c suricata.yaml --runmode single -k none \ 2>&1 | grep AppLayerParserTransactionsCleanup | grep -c ' freed \[' # -> 0
A suricata-verify test is the cleanest permanent form: replay
oneway_200.pcap and assert transactions freed equals transactions created.
I can supply one.
Arms, in the order I ran them¶
Host: Intel i9-10900X, 20 threads, 32 GB, AlmaLinux 9.8 container base.
Images jasonish/suricata@sha256:7ca2546f… (8.0.7) and
@sha256:d1d52d0e… (8.0.6).
CPU figures are ru_utime from os.wait4() on the suricata process only.
A — harness can see it (instrumented build at d996d85dc, DEBUG feature,
zero rules).
pcap freed tx_skipped "TC inspect not done" txd->flags max new_min oneway_200 *0* *20,100* 20,100 00 (never printed) bidir_200 200 1,275 1,275 00 200 dhcp_200 200 0 0 — 200
20,100 = 200·201/2 exactly. A triangular count is only produced if every
pass restarts at transaction 0, i.e. min_id never advances. flags = 00 means
neither SKIP_INSPECT_TC (0x02) nor INSPECTED_TC (0x08) is ever set — the
guard condition, verbatim. Re-run with one trivial rule (alert tftp any any> any any (msg:"r130 tftp rrq"; sid:1; rev:1;)), oneway_200 gives freed 0>flags 04 =
, tx_skipped 20,100, 200 alerts, and txd
APP_LAYER_TX_INSPECTED_TS; bidir_200 still frees 200. Retention does not
depend on the ruleset — only the flag value changes.
B (discriminating control) and C (target) — stock jasonish/suricata:8.0.7,
stock config, zero rules. Both arms create the identical number of
transactions; only the direction of the traffic differs.
N B: bidir CPU (s) C: one-way CPU (s) ratio app_layer.tx.tftp, both arms 1,000 0.369 0.500 1.4× 1,000 3,000 0.336 3.145 9.4× 3,000 6,000 0.505 22.572 44.7× 6,000 10,000 0.698 *101.203* *145×* 10,000
Two further controls: dhcp_200 on the parser you already fixed costs 0.238
s; onewayicmp_3000 costs 3.218 s against plain oneway_3000's 3.145 s — a
host actively rejecting the datagrams with ICMP port-unreachable does not
rescue the sensor, because an ICMP error is not TOCLIENT payload on the UDP
flow. The bidirectional arm stays flat, which is what makes this a
direction bug and not "TFTP is expensive". Subtracting a 0.336 s
engine-startup floor (note: dhcp_200 is lower still at 0.238 s, so this is
a representative floor rather than the smallest control value; subtracting
0.238 instead gives 2.94 for 3,000→6,000, so the derivation is robust
either way), the growth exponent is 1,000→3,000: 2.59; 3,000→6,000: 2.98;
6,000→10,000: 2.96 — cubic, as derived in mechanism §4. 8.0.6 reproduces
identically (oneway_3000 3.306 s vs bidir_3000 0.382 s), so the release
that fixed DHCP did not touch this. maxrss across the bidir series ran
135,616 → 157,228 kB.
Impact¶
- 620,000 bytes (605 KiB) of unauthenticated traffic → 101.2
CPU-seconds on one packet-processing thread. That is the whole cost to
the attacker for one flow. - Marginal cost rises without bound. Across the last 4,000 datagrams
of the 10,000-datagram run each one cost 19.7 ms of CPU (78.6 s / 4,000;
the cubic fit predicts 19.8 ms, and 30.3 ms instantaneously at n = 10,000).
Holding a worker at 100% from there needs 1/0.0197 ≈ 51 datagrams/s × 62 B
≈ 3.1 KiB/s. - Per-flow, so it scales by source port. Packets are steered to a
worker by flow hash (src/tmqh-flow.c:226-227; defaults cluster-type:
cluster_flow and autofp-scheduler: hash are both port-inclusive), so
distinct source ports generally land on distinct workers. Sixteen flows at
10,000 datagrams each is 16 × 620,000 = 9.92 MB of traffic. I did not
test this — see below. - The sensor is the target and the failure is loss of visibility. A
pinned worker drops traffic; in IPS mode it is worse. The UDP established timeout
is 300 s (suricata.yaml.in:1658-1660), so a trickle keeps the flow — and
its accumulated state — alive indefinitely. - Memory is structurally unbounded — each retained transaction holds
the attacker-supplied filename String plus its AppLayerTxData, with no
cap anywhere for TFTP. I deliberately attach no number to this: see
below.
Severity¶
Proposed: CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H = 7.5 HIGH — and
the same arithmetic with only AV changed reproduces your own published
score for the DHCP case:
ISS = 1 − (1−0)(1−0)(1−0.56) = 0.5600 Impact (S:U) = 6.42 × 0.5600 = 3.5952 Expl. AV:N = 8.22 × 0.85 × 0.77(AC:L) × 0.85 × 0.85 = 3.8870 -> Roundup(7.4822) = 7.5 Expl. AV:A = 8.22 × 0.62 × 0.77 × 0.85 × 0.85 = 2.8353 -> Roundup(6.4305) = 6.5
6.5 is exactly what you assigned CVE-2026-57224 (
CVSS:3.1/AV:A/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H). The only term that differs
between that vector and mine is the attack vector; every other metric is
identical. So the question is narrow: is TFTP on routable UDP/69
network-reachable where broadcast DHCP is adjacent? I believe it is, but
that is your call.
Your published anchors, given honestly because they straddle the answer:
Advisory Summary Vector Score GHSA-gjwr-75gq-877m / CVE-2026-63446 app-layer: passed flows can retain transactions AV:N/AC:L *7.5 HIGH* GHSA-m2vc-g65c-ph7m / CVE-2026-57224 dhcp/rdp: unbounded txs in unidirectional traffic AV:A/AC:L 6.5 MEDIUM GHSA-hvvj-c8xx-9g35 / CVE-2026-63448 smb: some SMB flows can cause resource exhaustion AV:N/AC:*H* 5.9 MEDIUM
You have scored this class MEDIUM twice and HIGH once; I am not pretending
otherwise. GHSA-gjwr is the closest structural match (same function, same
"transactions never freed", AV:N/AC:L, 7.5); GHSA-xjgq-3qw4-jp5f /
CVE-2026-71418 ("doh2: crafted HTTP/2 DATA frames can cause quadratic CPU
consumption", 2026-08-19) is the closest by harm — AV:N/AC:L, 7.5 HIGH.
What separates this from the AC:H SMB case is that there is no cap to reach
and no race to win: it is one constant-source-port stream.
Against SECURITY.md's wording: HIGH "affects Tier 1 features that are
enabled by default where the issue disrupts availability of the service,
leading to severe loss of visibility and/or availability", and explicitly
includes "Remotely triggerable traffic crashes, or evasions with a wide
scope". CRITICAL is reserved for "remotely triggerable traffic based code
execution" — this is not that and I am not claiming it. Your ladder also
keys on "enabled by default": TFTP is enabled by default in the shipped
config and in your release image. I assert no support tier for it —
doc/userguide/support-status.rst at this ref tiers distributions,
architectures, capture methods and operation modes but does not tier
individual application-layer protocols, so the tier is yours to assign.
What I did not test¶
- 7.0.x was inspected, not driven. origin/main-7.0.x =
872704f72fa445641624717b6f91eb8e2e171aae, tip 2026-07-08 16:06:56 +0530;
latest tag suricata-7.0.17 = f707f3208d…. There
rust/src/tftp/tftp.rs:72 still calls AppLayerTxData::new(); the equivalent constructors are at
rust/src/applayer.rs:152-176 (the 7.0 form uses detect_flags_ts/_tc with
APP_LAYER_TX_SKIP_INSPECT_FLAG rather than a single flags byte) and the
equivalent cleanup guard at src/app-layer-parser.c:1013-1034, free at
:1071; tftp: enabled: yes at suricata.yaml.in:1032-1033. I ran no 7.0.x
binary, so I claim inspection only. Note also that the DHCP fix was never
backported there: it is 3f86c56c8 on main and bac8a69ca on
origin/main-8.0.x (first tag suricata-8.0.6), and git branch -r
--contains puts each on that one branch alone — neither is on
origin/main-7.0.x, where rust/src/dhcp/dhcp.rs:90 still calls new(). You
may consider 7.0.x out of scope; I raise it so the decision is yours and
not an omission of mine. - Multi-worker saturation is reasoning, not measurement. Every run
above is a single flow through a single thread under suricata -r. The "N
source ports stall N workers" argument rests on the hash at
src/tmqh-flow.c:226-227 and the port-inclusive defaults; it is a hash,
so coverage is probabilistic, and a deployment using autofp-scheduler:
ippair (src/tmqh-flow.c:248-262) or ftp-hash (:270, declared :46,
selected :71-72) would collapse one source IP's ports onto one queue. I
ran no multi-worker or live-interface test. - Memory: my measurement failed, and I am reporting that. 5,000
transactions with 11-character filenames measured 145,996 kB maxrss against
5,000 with 60-character filenames at 145,416 kB — the larger payload
measured lower. RSS here is dominated by pool high-water, which drifts
with N even in the control arm where nothing is retained (135,616 → 157,228
kB). So I have no clean per-transaction memory figure and the memory
claim above is structural only. CPU is the measured harm; please do not let
me hand you an unsupported memory number. - I did not audit the other parsers. Grepping AppLayerTxData::new()
across rust/src at this ref returns applayertemplate, dcerpc, http2,
ldap, modbus, nfs, pgsql, pop3, rfb, smb and tftp; I checked only TFTP.
That register is also not complete — a grep for that constructor
structurally cannot see a parser that builds its tx via Default, e.g.
rust/src/enip/enip.rs:201 uses EnipTransaction::default(). Treat the
list as a starting point, not an inventory. - I did not test live-interface capture, IPS/inline mode, AF_PACKET,
--disable-detection, IPv6, VLAN, or a non-default
app-layer.protocols.tftp.detection-ports.
Remediation¶
The one-line fix mirrors your own DHCP change. In rust/src/tftp/tftp.rs,
thread the direction into TFTPTransaction::new() and construct with
AppLayerTxData::for_direction(Direction::ToServer) instead of
AppLayerTxData::new(). TFTP only ever parses TOSERVER (TFTPParseResponse is
a no-op), so ToServer is correct for every transaction this parser creates.
That sets APP_LAYER_TX_SKIP_INSPECT_TC, the guard at
src/app-layer-parser.c:1077-1085 stops firing, cleanup frees each
transaction, min_id advances, and the walk returns to O(1) amortised —
exactly what bac8a69ca ("dhcp: mark transactions single-directional to fix
tx leak") and ef035c760 did for DHCP and RDP. Defence in depth, if you want
it: a max-tx cap for TFTP — grepping max-tx at this ref finds one for at
least dcerpc, enip, ftp, ldap, mqtt, nfs, pgsql, pop3, smb,
applayertemplate, dnp3, htp and smtp, but none for TFTP — would bound the
damage from any future parser that regresses this way.
Interim workaround for operators: set app-layer.protocols.tftp.enabled: no.
I verified this key is present in the shipped config; I did not measure a
run with it disabled.
Verification refs¶
Fresh full clone with tags taken 2026-09-17. origin/main =
d996d85dcfbf1349acf54d942abc86a13f9e699f, tip 2026-09-12 16:12:26 -0600.
origin/main-8.0.x = tag suricata-8.0.7 =
d681600f3648030a67f7d618d30742bfd5fe7169, tip 2026-09-13 12:28:26 -0600.
origin/main-7.0.x = 872704f72fa445641624717b6f91eb8e2e171aae, tip
2026-07-08 16:06:56 +0530. Instrumented build: same tree at d996d85dc,
clean worktree, --enable-debug; banner 9.0.0-dev (d996d85dc 2026-09-12)
with DEBUG among the features.
Prior-art check re-run 2026-09-17: all 84 GitHub security advisories on
OISF/suricata fetched — the string "tftp" appears in none of them. No open
PR mentions tftp; GitHub Issues are disabled on the repo (has_issues: false).
Redmine #3877, the 2020 parent ticket "Transaction list grows without bound
on parsers that use unidirectional transactions", enumerates its children
as SNMP, DHCP, IKEv2, MQTT, SIP, RDP, KRB5, NTP and ENIP — TFTP is absent.
So this reads as an original omission from that 2020 sweep rather than a
regression.
Class: CWE-401 / CWE-770 / CWE-407 (unfreed state, unbounded allocation,
cubic complexity)
Proposed severity: CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H =
7.5 HIGH (arithmetic below)
Affected (tested): 8.0.6, 8.0.7 (latest release), origin/main.
Credit line if you use one: Mike Read (JP Morgan); GitHub handle on request.