fix(broker): audit a request whose descriptors do not fit on macOS
Problem
On macOS, a worker can make the broker drop its connection with no audit event, which RFC 0011 and the threat model say cannot happen: every refusal is one request event with malformed_frame.
It takes one request that attaches more descriptors than the broker's descriptor table can hold. Under launchd's default soft limit of 256, one request with 253 descriptors is enough. Linux reports that message truncated (MSG_CTRUNC), which the broker already refuses and audits. macOS can fail recvmsg instead, with EMSGSIZE or EMFILE. Neither errno has a framing reason, so the connection ended without an event. macOS can also deliver only the descriptors that fit, which the broker already refused and audited as attached descriptors.
It still failed closed: nothing was served and no descriptor stayed open.
Found in an internal review.
Change
read_frame, when it refuses descriptors (the broker's side), treatsEMFILEandEMSGSIZEfromrecvmsglikeMSG_CTRUNC: the connection fails with the samemalformed_frameerror and message. Only attached descriptors cause either, and a request carries none. The client's side, which accepts one descriptor per response, is unchanged.a_request_whose_descriptors_cannot_be_received_fails_the_connection_closedwas Linux only. It now runs on macOS too, checks for exactly onerequest/deny/malformed_frameevent, and runs with no free descriptor slot and with half a message's worth free. It accepts either refusal message, "more descriptors than could be received" or "requests carry none", because which one macOS reaches depends on the table. Both are the samemalformed_framerefusal, and the test still checks that nothing was served and every descriptor was closed.- RFC 0003, the threat model row (no longer "Linux only"), and the changelog.
Verification
- The test went first. On macOS, before the change:
An earlier run with no free slot failed withassertion `left == right` failed: room 0: Message too long (os error 40) left: Uncategorized right: InvalidDataToo many open files (os error 24), so macOS gives either errno for a full table. After the change it passed three runs in a row. - On CI's macOS 26 runner, the first push failed the test's message check with half a message's worth free:
room 126: peer attached a file descriptor to a request; requests carry none. There, macOS delivered the descriptors that fit with no error, and the broker refused them as attached descriptors. The second commit accepts that message too. cargo test --lockedon macOS: 122 passed, 0 failed.cargo fmt --all --checkpassed.cargo clippy --locked --all-targets -- -D warningsis clean on macOS and, with Rust 1.100, forx86_64-unknown-linux-gnuandaarch64-unknown-linux-gnu.cargo +1.85.0 check --locked --all-targetspassed.
Not verified locally: Linux, where the test now also checks the audit event. That is this PR's CI.
Documentation and release
RFC 0003, the threat model, and the changelog. No version change.