Skip to content

fix: audit round 3 deferred items (S1, C2) - #28

Merged
mizu-jun merged 1 commit into
masterfrom
fix/audit-round3-s1-c2
Jul 5, 2026
Merged

fix: audit round 3 deferred items (S1, C2)#28
mizu-jun merged 1 commit into
masterfrom
fix/audit-round3-s1-c2

Conversation

@mizu-jun

@mizu-jun mizu-jun commented Jul 5, 2026

Copy link
Copy Markdown
Owner

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_valid compared the token via a HashMap lookup. It now compares against every stored entry with subtle::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::spawn is wired into Window::add_serial_pane, so serial panes are live — C2 is not dormant. Previously make_full_refresh returned 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 Pane snapshot design (v1.9.3):

  • The serial reader maintains a latest_grid via Grid::apply_dirty_row (the P1 incremental pattern).
  • Serial panes are threaded through the attach and lag-resync refresh paths: new Window::focused_pane_full_refresh (attach, serial-aware) and Window::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

  • Existing auth adversarial tests (tampered / random / empty / expired) exercise the constant-time path.
  • cargo test -p nexterm-server (267 passed), cargo clippy --all-targets -- -D warnings, cargo fmt --check all green.

Remaining deferred

P3, P6 (need profiling), P5, R5/A5 (require a PROTOCOL_VERSION bump), P7 (large lock-architecture refactor) stay tracked in the audit report.

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>
@github-actions

github-actions Bot commented Jul 5, 2026

Copy link
Copy Markdown

Coverage report


Generated by cargo llvm-cov (workspace minus nexterm-client-gpu and nexterm-i18n).

@mizu-jun
mizu-jun merged commit 709d80b into master Jul 5, 2026
12 checks passed
@mizu-jun
mizu-jun deleted the fix/audit-round3-s1-c2 branch July 5, 2026 11:57
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