Repository navigation
fix(net): bound connection ingress buffer and enforce upfront parser caps - #6
Merged
Merged
Conversation
…caps - Enforce strict 64 MiB unread buffer cap across epoll (read_from), io_uring (feed_bytes), and decrypted TLS streams, returning NetError::BufferOverflow on overflow - Introduce CommandFrameDecoder in kachedb-proto-resp with two-pass incremental parsing and zero heap allocation during scanning - Reject oversized requests upfront on header lines using checked arithmetic: 64 MiB command wire cap, 2 MiB per-argument bulk string cap, and 65,536 argument count limit - Reset decoder state on frame boundaries to give each pipelined command an independent budget - Isolate historical AOF recovery with parse_command_frame_for_replay to restore large valid records up to 64 MiB without tripping client ingress limits - Fully resolves Finding H in ADR 6 Step 6
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
This PR resolves Finding H (Step 6) of Architecture Decision Record 6 (
improvements/improvement-6-design-decision.md), defending KacheDB against ingress and parser denial-of-service vectors.Key Deliverables
Connection::read_from(epoll),Connection::feed_bytes(io_uring), and decrypted TLS plaintext streams (TlsState::read_and_decrypt).NetError::BufferOverflow.CommandFrameDecoder:crates/kachedb-proto-resp/src/command_frame.rs.SmallVeconly after the entire command frame is verified complete.MAX_COMMAND_BYTES).MAX_ARGUMENT_BYTES), preventing memory amplification.MAX_ARGUMENTS).checked_add,checked_mul) to eliminate integer overflow attacks.parse_command_frame_for_replayallows historical AOF frames to restore without tripping the 2 MiB client argument cap, since AOF frames are already validated and bounded by the journal's 64 MiB record budget.Verification
cargo fmt --all -- --check: PASS (0 diffs)cargo clippy --workspace --all-targets --all-features -- -D warnings: PASS (0 warnings across all 11 crates)cargo test --workspace: PASS (100% test pass rate)prvStaff Review: APPROVE (11/11 dimensions passed)