Repository navigation
Description
What happened
Security and stability hardening audit finding H12 / P4 (2026-09-28). Priority is an audit recommendation, not a claim of a production incident.
Human-readable output writes values that come from another machine directly to the terminal: remote session names and working directories in list, remote error strings, and up to 2,000 characters of SSH stderr in transport errors. None of them are stripped of ESC, C0 or C1 control characters.
In an offline fixture, a session name containing ESC ] 52 (OSC 52 clipboard write) and ESC ] 8 (OSC 8 hyperlink) sequences, and a cwd containing C1 CSI (U+009B), were emitted unchanged by the listing renderer; the same sequences passed through ssh_failure_error into the message printed to stderr. On terminals that honor these sequences, a destination host could set the operator's clipboard or show a link whose visible text differs from its target.
JSON output is not affected: json.dumps escapes control characters.
What you expected
Human-mode output escapes or replaces control characters (C0 except the renderer's own newlines, DEL, C1, and ESC-introduced sequences) in every externally sourced field before printing, for example as \x1b / \u009b. JSON output stays byte-for-byte unchanged.
Environment
- Baseline: published session-peer v1.0.2, commit
2046836822b88e53246de73851186598604cb5ec. - Reproduction: rendering functions called in-process with synthetic session rows and error details; no terminal was driven and no host contacted.
- Audit environment: macOS arm64, Python 3.14.7.
- No live message tests or production mutation.
Source evidence
- session_peer_core/output.py#L6-L22 — session table
- session_peer_core/registry.py#L150-L160 — multi-agent listing and discovery errors
- session_peer_core/ssh.py#L114-L116 — remote stderr in transport errors
- session_peer_core/ssh.py#L218-L219 — remote error string
- session_peer_core/cli.py#L181 — printed to stderr
Acceptance criteria
- One helper neutralizes control characters for human output; used by list, doctor, send, update and error paths.
- Tests cover OSC 52, OSC 8, CSI, bare C1 and BEL in names, cwd, discovery errors and SSH stderr.
- Column alignment still works with escaped values; JSON output unchanged.
Scope and limitations
Target: v1.0.3 hardening work. This issue does not authorize a release or operating-service changes. Terminal behavior varies; the fixture shows the bytes reaching stdout/stderr, not a specific terminal's reaction.
Checked
- Searched existing issues for duplicates.
- Removed credentials, conversation contents, private paths and real device/session identifiers.
- Used isolated fixtures without weakening inbound permissions.
Activity