fix(web): re-validate stored session name + exact-match tmux target#65
Merged
Conversation
handleKill validated the incoming agent_id with sanitize.ValidIdentifier but accepted the projection-read sessionName at face value before shelling out to `tmux kill-session -t <sessionName>`. ValidIdentifier allows `.` (story IDs use it for split-depth notation), and tmux's target syntax treats `session.0` as "pane 0 of that session" — killing the wrong thing if the projection ever contained a tampered or migrated row with a dot. - Add sanitize.ValidTmuxTarget: stricter than ValidIdentifier — excludes `.` (pane separator) and `:` (window separator). Documented why. - handleKill re-validates the read-back sessionName; refuses + logs on failure rather than running tmux. - Switch the tmux invocation to `tmux kill-session -t =<sessionName>`. The leading `=` is tmux's exact-match prefix — even substring-match cases that slipped past ValidTmuxTarget can no longer target adjacent sessions. 3 new tests: - TestValidTmuxTarget — table-driven, covers session.0 / session:1 / empty / shell metachars / happy paths. - TestHandleKill_RejectsUnsafeStoredSessionName — seeds an agent with a "nxd-session.0" SessionName (passes ValidIdentifier on insert, fails the new ValidTmuxTarget on read) and asserts handleKill refuses without running tmux. Surfaced by the 2026-06-11 security audit (SEC-H3).
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
handleKillvalidated the incomingagent_idwithsanitize.ValidIdentifierbut accepted the projection-readsessionNameat face value before shelling out totmux kill-session -t <sessionName>.ValidIdentifierpermits.(story IDs use it for split-depth notation), and tmux's target syntax treatssession.0as "pane 0 of that session" — killing the wrong thing if the projection ever contained a tampered or migrated row with a dot.Changes
sanitize.ValidTmuxTarget: stricter thanValidIdentifier— excludes.(pane separator) and:(window separator). Documented why.handleKillre-validates the read-backsessionName; refuses + logs on failure rather than running tmux.tmux kill-session -t =<sessionName>. The leading=is tmux's exact-match prefix — even substring-match cases that slipped pastValidTmuxTargetcan no longer target adjacent sessions.Test plan
TestValidTmuxTargettable-driven (session.0,session:1, empty, shell metachars, happy paths).TestHandleKill_RejectsUnsafeStoredSessionNameseeds an agent with"nxd-session.0"SessionName (passesValidIdentifier, fails the newValidTmuxTarget), assertshandleKillrefuses.go build ./...,go vet ./...,go test ./... -count=1 -timeout 240sall green locally.Audit traceability
Security finding SEC-H3 (2026-06-11 sweep).