fix: audit round 3 deferred items (S1, C2) - #28
Merged
Conversation
S1 (LOW, defense-in-depth): AuthManager::is_valid now compares the session token against every stored entry in constant time (subtle::ConstantTimeEq), so validation latency does not leak how much of a guessed token matched. Tokens are 48 random alphanumeric chars behind a SipHash-keyed HashMap, so this is hardening rather than a practical fix, but it keeps the auth gate branch-free. C2 (reachable, reclassified from dormant): SerialPane::spawn is wired into Window::add_serial_pane, so serial panes are live. Previously make_full_refresh returned a blank grid and pre-attach output was lost, leaving serial panes blank until the next byte. Mirror the PTY Pane snapshot design: the reader maintains a latest_grid via Grid::apply_dirty_row, and serial panes are now threaded through the attach and lag-resync full-refresh paths via Window::focused_pane_full_refresh / all_full_refreshes. DA/DSR write-back is intentionally not added (serial devices lack the PSReadLine handshake). Tests: existing auth adversarial tests cover the constant-time path; cargo test (267 passed) / clippy -D warnings / fmt --check green. Generated with [Claude Code](https://claude.ai/code) via [Happy](https://happy.engineering) Co-Authored-By: Claude <noreply@anthropic.com> Co-Authored-By: Happy <yesreply@happy.engineering>
Coverage reportGenerated by |
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.
Addresses two deferred findings from the round 3 audit (docs/plans/audit-round3-2026h2.md).
S1 — constant-time session token comparison (LOW, defense-in-depth)
AuthManager::is_validcompared the token via aHashMaplookup. It now compares against every stored entry withsubtle::ConstantTimeEq, so validation latency does not reveal how much of a guessed token matched. Tokens are 48 random alphanumeric chars behind a SipHash-keyed map, so this is hardening rather than a practical fix, but it keeps the auth gate branch-free.C2 — serial pane blank-grid bug (reachable, reclassified)
SerialPane::spawnis wired intoWindow::add_serial_pane, so serial panes are live — C2 is not dormant. Previouslymake_full_refreshreturned a blank grid and any output emitted before a client attached was dropped (broadcast has no receivers), leaving the pane blank until the next byte.Fix mirrors the PTY
Panesnapshot design (v1.9.3):latest_gridviaGrid::apply_dirty_row(the P1 incremental pattern).Window::focused_pane_full_refresh(attach, serial-aware) andWindow::all_full_refreshes(P4 resync, includes serial).DA/DSR write-back is intentionally not added — serial devices lack the PSReadLine handshake that required it for ConPTY.
Tests
cargo test -p nexterm-server(267 passed),cargo clippy --all-targets -- -D warnings,cargo fmt --checkall green.Remaining deferred
P3, P6 (need profiling), P5, R5/A5 (require a
PROTOCOL_VERSIONbump), P7 (large lock-architecture refactor) stay tracked in the audit report.