Skip to content

fix: harden decoding and encrypted writes (2.5.0) - #8

Merged
kauri-off merged 1 commit into
masterfrom
fix/audit-hardening
Nov 8, 2026
Merged

kauri-off merged 1 commit into
masterfrom
fix/audit-hardening

Conversation

@kauri-off

Copy link
Copy Markdown
Owner

Fixes from the library audit. API-compatible; adds MAX_VEC_NESTING and MAX_DECODED_VEC_BYTES.

  • Limit Vec<T> nesting to 128 and decoded memory to 32 MiB per top-level Vec (a recursive type could abort the process; an 8 KiB frame could allocate 264 MiB).
  • Keep the sync CFB8 cipher in sync on writer errors; async write errors now resurface instead of duplicating on retry.
  • Without the compression feature, an active threshold now returns an error instead of misframing.
  • Cap frame preallocation at 64 KiB.
  • Reject frame prefixes over 3 bytes, non-zero data_length below the threshold, and trailing bytes after the zlib stream.
  • Checked length casts for String and Vec.
  • Derive: W/R generics compile; packet ID expressions are parenthesized.

Behaviour changes: stricter decoding can reject input previously accepted, notably peers that compress below the negotiated threshold. Tests: tests/hardening.rs.

- limit Vec<T> nesting and decoded memory per top-level Vec
- keep CFB8 cipher and stream in sync when the writer fails
- error instead of misframing when compression is unavailable
- cap frame preallocation at 64 KiB
- reject wide frame prefixes, below-threshold data_length, zlib trailing data
- checked length casts for String and Vec
- derive: allow W/R generics, parenthesize packet ID expressions
@kauri-off
kauri-off merged commit 565ba1e into master Nov 8, 2026
10 checks passed
@kauri-off
kauri-off deleted the fix/audit-hardening branch November 8, 2026 21:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant