Files
DomiStream/docs/MUTATION.md

94 lines
11 KiB
Markdown

# Mutation pass
Each row puts back one bug a test is meant to guard against (an exact edit to `crates/domistream/src`), runs the
test binary that should catch it, and reverts the edit. "Caught by" lists the tests that failed. All 24 rows were
caught; none failed to compile, so every row is a real behaviour change the tests saw.
- **When:** 2026-11-26, QA, on `feature/client` at `d62aa8f`. The baseline was 242/242 tests passing.
- **Driver:** [`tools/mutation/mutate.py`](../tools/mutation/mutate.py) holds the exact edits, so the pass can be
rerun: `python tools/mutation/mutate.py [M1 ...]`. Every cargo run goes through the resource gate (CPU, RAM and
drives below 90 %, `-j 2`).
| # | Area | Mutation | Test binary | Caught by | Result |
| :-- | :-- | :-- | :-- | :-- | :-- |
| M1 | XML cap | size cap off by one (refuses exactly `MAX_XML_BYTES`) | http | `xml_size_boundaries`, `applist_caps` | caught |
| M2 | XML cap | depth cap off by one (allows depth 9) | http | `xml_depth_cap`, `xml_depth_bomb_does_not_recurse` | caught |
| M3 | RTSP cap | header cap off by one (allows 65 headers) | rtsp | `response_header_flood` | caught |
| M4 | ENet cap | command cap off by one (allows 33 commands) | enet | `hostile_sizes` | caught |
| M5 | Input cap | message size cap removed | input | `hostile_sizes` | caught |
| M6 | Video cap | packet size cap off by one (accepts 4097 bytes) | media | `video_packet_hostile_sizes` | caught |
| M7 | Audio cap | packet size cap removed | media | `audio_packet_hostile` | caught |
| M8 | Lying length | control frame: a length field that claims less is accepted | control | `frame_parser_lying_lengths` | caught |
| M9 | Lying length | RTSP: bytes after `Content-Length` kept instead of refused | rtsp | `response_lying_content_length` | caught |
| M10 | Lying length | INPUT_DATA: the big-endian size field not checked | input | `lying_length_and_size_fields` | caught |
| M11 | ENet wrap | reliable delivery does not wrap at 0xFFFF (saturating "next") | enet | `reliable_sequence_wraps_at_0xffff` | caught |
| M12 | Control replay | a repeated sequence number accepted (`<` instead of `<=`) | control | `replayed_and_old_host_frames_are_dropped` | caught |
| M13 | Control replay | the replay check removed | control | `replayed_and_old_host_frames_are_dropped`, `host_sequence_at_u32_wrap` | caught |
| M14 | Nonce | direction bytes swapped (`'H'` client to host) | control | `nonce_layout`, `nonce_matches_the_definition`, `seal_matches_dotnet_vectors`, `wrong_direction_and_wrong_key_are_refused` | caught |
| M15 | GCM tag | control `open` ignores a failed tag check | control | `tampering_is_refused`, `tampered_and_reflected_frames_are_dropped`, `open_never_accepts_random_frames`, `wrong_direction_and_wrong_key_are_refused` | caught |
| M24 | GCM tag | video `decrypt` ignores a failed tag check | media | `video_decrypt_refuses` | caught |
| M16 | FEC index | a video parity shard stored one index too high | video | 12 tests, e.g. `random_loss`, `all_data_lost_but_recoverable`, `recovered_shard_headers_are_not_trusted`, `generated_patterns` | caught |
| M17 | Video header | bytes 0-31 of a rebuilt shard trusted (whole-packet shards, start-of-frame flag read from a rebuilt shard) | video | 9 tests, e.g. `recovered_shard_headers_are_not_trusted`, `all_data_lost_but_recoverable`, `random_loss` | caught |
| M18 | Audio parity | parity keyed by its own RTP sequence instead of the FEC header's base | audio | 9 tests, e.g. `every_loss_pattern_of_a_block`, `sequence_wraps`, `hostile_parity_never_corrupts` | caught |
| M19 | Pairing skip | no `pairingsecret`: proof and signature skipped, straight to step 4 | pairing | `a_bare_paired_answer_cannot_skip_any_step`, `out_of_order_answers_fail`, `replaying_the_same_answer_twice_fails` | caught |
| M20 | Signature | the host's signature over its secret not checked | pairing | `bad_host_signatures` | caught |
| M21 | Signature | `ServerCert::verify` accepts any signature | pairing | `bad_host_signatures`, `server_cert_verify_refuses` | caught |
| M22 | Sans-I/O | `std::time::Instant::now()` added in `src/time.rs` | hygiene | `src_is_sans_io` | caught |
| M23 | OS randomness | `getrandom` added as a dependency and used in `src/entropy.rs` | hygiene | `src_is_sans_io` | caught |
## Notes
- **M17.** The video receiver keeps only the payloads (bytes 32 on) of each shard and rebuilds from those, so as
written it cannot read a rebuilt shard's header. The mutation therefore first switches it to whole-packet shards,
then makes it trust one header field of a rebuilt shard. `recovered_shard_headers_are_not_trusted` and the other
loss tests catch it.
- **M23.** The mutation compiled, against the cached getrandom 0.4.3, and the guard caught the source use. Since
27b26a9 the dependency tree has no getrandom at all.
- **Missing tests.** No mutation got through, so none were added.
## Host side (stream-v0.2.0)
27 rows for the host modules: **26 caught, 1 equivalent** (M39). M36 first survived and now has a test.
- **When:** 2026-12-04, on `feature/host-session` (the session engineer wrote M25-M51; the lead finished the run,
added the M36 test and re-ran M36). Rows may name several test binaries; the tool now runs with `--no-fail-fast`.
- **Driver:** as above, `python tools/mutation/mutate.py M25 ... M51`, output on E: through the resource gate.
| # | Area | Mutation | Test binary | Caught by | Result |
| :-- | :-- | :-- | :-- | :-- | :-- |
| M25 | host pairing phase | phase 4 accepted while phase 3 is expected (a skipped step) | host_pairing, session | `out_of_order_phases_are_refused` | caught |
| M26 | host pairing proof | the client's proof H_c is not compared (any PIN pairs) | host_pairing | `the_right_pin_but_a_forged_proof_is_a_wrong_pin`, `wrong_pin_is_caught_by_the_host_when_the_client_carries_on` | caught |
| M27 | host pairing phase 5 | phase 5 accepts any HTTPS client certificate | host_pairing | `phase_5_needs_https_with_the_phase_1_certificate` | caught |
| M28 | host HTTP cap | query parameter cap off by one (allows 33) | host_http | `query_caps` | caught |
| M29 | host HTTP body | a GET with Content-Length other than 0 accepted | host_http | `heads_that_are_refused` | caught |
| M30 | host HTTP answer | PairStatus 1 over plain HTTP too | host_http, session | `serverinfo_pair_status_per_scheme` | caught |
| M31 | RTSP order | PLAY accepted before ANNOUNCE | rtsp_server | `order_violations_get_455_and_change_nothing`, `server_random_sequences` | caught |
| M32 | RTSP order | a second SETUP of the same stream accepted | rtsp_server | `options_at_any_time_and_setup_once_each` | caught |
| M33 | RTSP session | a Session header with another id accepted once issued | rtsp_server | `session_id_is_random_hex_and_checked` | caught |
| M34 | ANNOUNCE | a known attribute given twice accepted (the first value kept) | rtsp_server | `announce_duplicates_and_unknowns`, `announce_hostile_lines` | caught |
| M35 | DESCRIBE | the refPicInvalidation line written exactly when not offered | rtsp_server, session | `client_and_server_negotiate_in_memory`, `describe_follows_the_offer`, `describe_lines_and_order`, `a_whole_session_between_our_client_and_our_host` | caught |
| M36 | ENet host ack | pings acknowledged before the verify is acknowledged | enet_host | `ping_before_the_verify_ack_is_not_acknowledged` | caught |
| M37 | ENet host ack | a datagram without sent time goes on after an acknowledged command | enet_host | `acknowledged_commands_need_the_sent_time` | caught |
| M38 | ENet host session id | host session ids taken from the wrong offered field | enet_host | `session_ids_follow_stock_enet` | caught |
| M39 | ENet host session id | the slot's previous session id not skipped | enet_host | none (see notes) | **equivalent** |
| M40 | ENet client session id | verify's session ids swapped again (the bug fixed for v0.2.0) | enet | `verify_session_ids_are_taken_as_stock_enet_takes_them` | caught |
| M41 | control host replay | a repeated client sequence number accepted (< instead of <=) | control_host | `replays_and_forgeries_are_dropped` | caught |
| M42 | control host replay | the client replay check removed | control_host | `client_sequence_at_u32_wrap`, `replays_and_forgeries_are_dropped` | caught |
| M43 | control host message | extended termination code written little-endian | control_host, session | `close_from_either_side`, `host_message_layouts`, `host_messages_reach_the_client`, `a_whole_session_between_our_client_and_our_host` | caught |
| M44 | control host stop | a PERIODIC_PING does not move the stop deadline | control_host, session | `no_periodic_ping_ends_the_session`, `stop_deadline_rules`, `a_whole_session_between_our_client_and_our_host` | caught |
| M45 | video parity order | parity computed after the parity headers are written (headers become parity) | video_packetizer, session | `a_whole_session_between_our_client_and_our_host`, `every_data_shard_lost_is_rebuilt_when_parity_covers_it`, `fixed_vector_cauchy_parity_k3_m1`, `fixed_vector_one_small_frame` and 9 more | caught |
| M46 | video parity | the client's minimum parity count ignored | video_packetizer | `fec_plan_properties`, `minimum_parity_raises_the_written_percentage` | caught |
| M47 | video parity | parity shard index written one too high | video_packetizer | `every_data_shard_lost_is_rebuilt_when_parity_covers_it`, `fixed_vector_cauchy_parity_k3_m1`, `fixed_vector_one_small_frame`, `encrypted_stream_round_trips_with_loss` and 8 more | caught |
| M48 | video nonce | the GCM nonce counter does not advance per datagram (nonce reuse) | video_packetizer | `encrypted_stream_round_trips_with_loss` | caught |
| M49 | audio IV | the host encrypts with the IV of the next sequence number | audio_packetizer, session | `audio_cipher_encrypt_matches_openssl_vectors`, `fixed_vector_encrypted`, `lost_packets_are_reported_and_the_rest_arrive`, `round_trip_encrypted_across_sequence_and_timestamp_wrap` and 3 more | caught |
| M50 | audio IV | IV counter written little-endian (both sides) | media, audio_packetizer | `audio_cipher_encrypt_matches_openssl_vectors`, `fixed_vector_encrypted`, `audio_iv_and_decrypt_match_openssl_vectors`, `audio_round_trip_through_the_oracle` | caught |
| M51 | audio block start | a first sequence number that is not a block start accepted | audio_packetizer | `config_refusals` | caught |
### Notes on the host rows
- **M36.** A ping that the client asks to have acknowledged, sent before it acknowledged the verify, was answered
with an ACK in the mutant and no test noticed. `ping_before_the_verify_ack_is_not_acknowledged` (enet_host) now
catches it.
- **M39, equivalent.** `next_session` skips "the value the slot used last", as stock ENet does when a slot is
reused. An `EnetHostPeer` is always a fresh slot, so it is called with `current` = 0xFF while the result is in
0..3: the branch can never run and removing it changes nothing. It is kept so the function matches stock ENet if
a peer slot is ever reused.