szn

Bug 312 — Use-after-free in Server.processInput when action destroys active pane or session

312. Use-after-free in Server.processInput when action destroys active pane or session

File: src/server/server.zig:1694-1834 Severity: CRITICAL Status: ✅ FIXED

In Server.processInput, pointers for session, window, and pane were resolved at the top of the function.

If an input sequence triggered a key binding action (such as kill-pane or kill-session), self.executeAction(action) executed the command and deallocated the target pane or session. However, the byte processing loop continued to reference the dangling pane pointer in subsequent iterations and trailing pane.writeInput calls.

Root Cause

Static pointer resolution prior to byte-by-byte processing without re-validating pane validity after command execution dispatch.

Fix

Added self.isPaneValid(pane) guards in Server.processInput after executeAction dispatch and before any PTY input writing calls. If the pane is invalid/destroyed, the loop aborts processing and clears esc_buf.