Repository navigation
Conversation
Starlette's receive_text raises KeyError on a binary message. On /agent/ws that was an unhandled exception, reachable before authentication (first frame, auth reply) and from any connected agent. A binary first frame now closes 4400, a binary auth reply closes 4401, and a binary frame on an established tunnel is dropped like any other unparseable frame. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01QcqxZNsBPqj6rX5XZujCNu
…nstant
collected_at was stored as whatever string the agent sent. One snapshot
with an unparseable value made GET /api/fleet and
/api/agent/{id}/availability answer 500 for every host (ValueError or
OverflowError in availability._parse on MIN(collected_at)); one without a
UTC offset made /api/agent/{id}, /api/fleet/trend and /api/today answer 500
(naive minus aware datetime in the health rules).
The telemetry frame now fails validation on such a value, so the tunnel
drops it and keeps the connection. Rows already stored are tolerated on
read: availability ignores an unusable first-seen candidate and the health
rules read an offset-less instant as UTC. docs/protocol.md states the
format; no frame shape changes.
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QcqxZNsBPqj6rX5XZujCNu
fs_read read the whole target into memory before applying READ_CAP and opened whatever the path named: a multi-GB file cost its full size, a character device such as /dev/zero grew until the agent was OOM-killed, and a FIFO blocked the call forever. It now refuses anything that is not a regular file (bad_args) and reads at most one byte past the cap. The cleanup sweep's reclaimed-byte total and web_activity's merged hit count summed values taken from the file system and from a user-writable browser database with unchecked addition, which panics in debug builds and wraps in release. Both saturate. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01QcqxZNsBPqj6rX5XZujCNu
…ropped The health_rules.py change in this branch moves no threshold and no status: it reads an offset-less evaluation instant as UTC. Nothing in the dashboard views or their screenshots changes. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01QcqxZNsBPqj6rX5XZujCNu
wait_times_out_while_another_process_runs_target copied /bin/sleep to a file named kenny-wait-test-<pid> and ran the copy. The Linux CI job fails that test on every run that reaches it (also on an unrelated dependency PR): the child is gone before the wait looks for it. Where sleep is an applet of a multi-call binary, the binary picks the applet by the name it is run as, so the renamed copy exits at once. The copy now keeps the name `sleep` inside a private directory, which runs the same on a standalone sleep and on a multi-call one. Test-only; no agent behaviour changes. [skip-doc-drift] Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01QcqxZNqpHNGk5hJzgn6CWt Signed-off-by: Claude <noreply@anthropic.com> (cherry picked from commit 3ab1a26)
|
The The same test already fails on the Linux runner for other PRs, and #364 carries a fix for it (the test copied Generated by Claude Code |
What & why
Scheduled crash-fuzzing run. This run targeted surfaces the earlier runs did not reach: hostile frames on
/agent/ws(binary messages, mutatedregister/telemetry/log/responseframes) followed by a sweep of everyGET /apiroute, the MCP tools with junk arguments and a fake agent answering with mutated fixtures, and the Rust agent's handlers, frame handling and parsers. The session may push to one branch only, so the three fixes share this PR, one commit each.1. A binary WebSocket message on
/agent/wsraisesKeyErrorStarlette's
receive_textassumes a text message:This is reachable before authentication (first frame, and the reply to the challenge) and from any connected agent. The exception left the endpoint unhandled.
Fix: a small
_receive_texthelper returnsNonefor a binary message. A binary first frame closes 4400, a binary auth reply closes 4401, and a binary frame on an established tunnel is dropped like any other unparseable frame.2. A
telemetryframe with a badcollected_atbreaks the fleet viewscollected_atwas stored as whatever string the agent sent." ","x","2026-02-30T00:00:00Z"), or one with no UTC equivalent ("0001-01-01T00:00:00+23:59"), madeGET /api/fleetandGET /api/agent/{id}/availabilityanswer 500 for every host:ValueError/OverflowErrorinavailability._parse, called onMIN(collected_at).GET /api/agent/{id},/api/fleet/trendand/api/todayanswer 500:TypeError: can't subtract offset-naive and offset-aware datetimesinhealth_rules._rule_win_update.Both last until the row ages out of retention.
Fix: the
Telemetrymodel fails validation unlesscollected_atis an RFC 3339 timestamp with an offset, so the tunnel drops the frame and keeps the connection (its existing behaviour for an invalid frame). Rows already stored are tolerated on read:availability.load_manyignores an unusable first-seen candidate, andevaluate_snapshotreads an offset-lessnowas UTC.docs/protocol.mdstates the format. The agent already emits this form (util::now_rfc3339), and no frame shape changes.3. Agent:
fs_readis unbounded; file-size sums overflowfs_readcalledstd::fs::readand appliedREAD_CAPafterwards. A 1 GiB file cost 1 GiB of memory to return 256 KiB./dev/zerogrew until the process was OOM-killed. A FIFO with no writer blocked the call forever. Fix: refuse anything that is not a regular file (bad_args) and read at most one byte past the cap.cleanup.rs(reclaimed bytes) andweb_activity.rs(merged hits) added values that come from the file system and from a user-writable browser database with unchecked+=. Three 8 EiB sparse files in a swept tmpfs root, or avisit_countneari64::MAX, panic in debug builds and wrap in release. Fix:saturating_add.Regression tests
Fixed inputs only; no fuzz harness is committed.
test_tunnel_malformed_frame.py: three binary-frame cases through the real ASGI app.test_hostile_input_no_500.py: rejected and acceptedcollected_atvalues, plus stored-row cases for both read paths.read_stops_at_the_cap_whatever_the_file_size,read_refuses_a_directory,read_refuses_a_device_that_never_ends,reclaimed_bytes_saturate_on_huge_sparse_files,merged_hits_saturate.The server tests and the two saturation tests were checked to fail without the fix. The
fs_readtests were not run against the old code, because there they exhaust memory.Found, not fixed here
fs_*,diag_*,net_config,screen_capture,telemetry_collect) run on tokio worker threads indispatch::run. As many blocked calls as the host has cores stall the heartbeat and the writer. Moving them tospawn_blockingtouches every dispatch arm, so it is left for a separate change.web_activityreads a browser history database without a row cap and drops the whole profile on one malformed row;browser_extensionsreads manifests without a size cap.policyframe's regexes are compiled on the tunnel read loop with no bound on count or size.webfilterfails on a hosts file that is not valid UTF-8.Fuzzing summary
GET /apiroute: no 5xx after the fixes. Targeted timestamp probe (20 values ×collected_at/log.at) and register-metadata probe: clean after the fixes. MCP tools: 1,500 calls with junk arguments and mutated agent answers, no unhandled exception.fs_*and cleanup dry runs. No panic in frame decoding or the parsers.cargo check --target x86_64-pc-windows-gnucould not run (no mingw toolchain). Those paths were read statically only.Checklist
pytest -q(server): 4274 passed, 7 skipped.cargo test(agent): 593 passedruff checkonkenny_serverand the touched tests,cargo fmt --check,cargo clippy --all-targets -- -D warningsPROTOCOL_VERSIONis not bumped.docs/protocol.mdgains one paragraph stating thecollected_atformat the fixtures and the agent already use./contract-checkwas not rundocs/protocol.mdGenerated by Claude Code