Repository navigation
Conversation
…tion poisoning
- `idevice/src/sni.rs`: replace raw `(device_cert, host_cert, host_key)`
bytes in `TlsConfigKey` with a constant-time-compared, domain-separated,
length-prefixed SHA-256 digest (`[u8; 32]`) using a zero-dependency
FIPS 180-4 hasher that volatile-zeroizes its state and block buffer on
drop. Raw `host_private_key` PEM bytes are no longer retained in the
process-global `OnceLock` TLS config cache.
- `idevice/src/xpc/http2/mod.rs`:
- Persist outbound frame bytes in a cancel-safe `write_buf` / `write_pos`
buffer drained via `AsyncWriteExt::write`, so cancelling `pump()` /
`read()` (e.g. poll ticks or flow-control timeouts) mid-write never
tears a control frame (`SETTINGS` ACK, `PING` ACK, `WINDOW_UPDATE`) on
the wire.
- Track `poisoned: bool` on `Http2Client`: once a multi-frame payload
starts queuing chunks, any flow-control timeout, external cancellation,
or error before completion (as well as any transport write/read error,
EOF, malformed frame, or flow-control window overflow) poisons the
connection so subsequent calls fail fast with `BrokenPipe` instead of
appending onto a truncated stream. Pre-send timeouts at `offset == 0`
leave the connection clean and reusable once the window recovers.
- Record `finished_file_transfer_streams` only when `END_STREAM` is
actually queued.
- Add unit tests covering NIST SHA-256 vectors, length-prefix isolation and
host key rotation cache misses, partial-send timeout poisoning, zero-byte
timeout recovery, external multi-frame cancellation poisoning, and
cancel-safe mid-frame `pump()` write resumption.
Co-Authored-By: Claude Code <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Implements Track F4 hardening in
Derrors/idevicewithout adding any new dependencies or breaking public APIs:idevice/src/sni.rs):(device_cert, host_cert, host_key)byte buffers inTlsConfigKeywith a constant-time-compared, domain-separated, length-prefixed SHA-256 digest ([u8; 32]).aws-lc,ring,rustcrypto, andwasm32without couplingrustlsto optionalsha2) that volatile-zeroizes its state and message block buffers on drop.host_private_keyPEM bytes are no longer cloned into or retained by the process-globalOnceLockTLS config cache.sha256_matches_nist_vectorsandtls_config_key_isolates_fields_and_distinguishes_host_key_rotation.idevice/src/xpc/http2/mod.rs):write_buf/write_posbuffer drained viaAsyncWriteExt::writeso cancellingpump()/read()mid-write (e.g. poll ticks or flow-control timeouts) never tears aSETTINGSACK,PINGACK, or coalescedWINDOW_UPDATEframe on the wire.poisoned: boolonHttp2Client: once a multi-frame payload starts queuing chunks, any flow-control timeout, external future cancellation, or error before completion — as well as any transport write/read error, EOF, malformed frame, or flow-control window overflow — poisons the connection so all subsequent calls fail fast withBrokenPiperather than corrupting the peer stream.offset == 0non-poisoning (zero payload bytes sent, cancel-safewrite_bufkeeps framing intact) so the connection remains reusable once the peer replenishes its window.finished_file_transfer_streamsonly whenEND_STREAMis actually queued.partial_send_timeout_poisons_connection_against_subsequent_calls,zero_byte_send_timeout_keeps_connection_usable_after_window_recovers,cancelled_multi_frame_send_poisons_connection, andcancelled_pump_write_preserves_partial_frame_without_tearing.Test plan
cargo fmt -p idevice -- --checkcargo clippy -p idevice --no-default-features --features "ring,full" --tests -- -D warnings(0 warnings)cargo test -p idevice --no-default-features --features "ring,full" --lib(115 passed / 0 failed)cargo check -p idevice --no-default-features --features "ring,full" --tests&--features "ring"🤖 Generated with Claude Code