Skip to content

fix(ssh): accept a successful version preflight before classifying stderr #55

Closed

Description

@abruption

What happened

Security and stability hardening audit finding TS-07 / Low (2026-09-28). Priority is an audit recommendation, not a claim of a production incident. Same class as abruption/session-peer#228, but limited to the preflight.

sshPreflightFailure() checks stderr patterns before the exit code and version line. A preflight that exits 0 and prints the exact expected version is still refused as ssh_unreachable / ssh_authentication_refused when the remote login shell (rc file, motd, a failing helper) happens to write text such as Connection refused or Permission denied ( to stderr.

Reproduced with a stub ssh returning exit 0, the correct version line on stdout and curl: (7) Failed to connect ... Connection refused on stderr: the request was refused as ssh_unreachable.

What you expected

Exit 0 with the exact version line passes the preflight. stderr classification is applied only when the preflight actually failed (for example OpenSSH exit 255).

Environment

  • Baseline: published session-peer 0.2.0 (npm latest), repository commit 38a1300369443e064f58bb18e8bda70f31af0fbb.
  • Audit environment: macOS arm64, Node 22.14.0.
  • No live message tests or production mutation.
  • Reproduction: stub ssh executable on a temporary PATH; no network connection.

Source evidence

  • src/cli.ts#L97-L111 — stderr patterns evaluated before code === 0 and the version comparison

Acceptance criteria

  • Successful preflight with noisy stderr is accepted.
  • Existing host-key / authentication / unreachable classification still applies on failure exits.

Scope and limitations

Fails closed: the preflight sends nothing, so there is no duplicate-delivery risk, only a false refusal. The main send request does not use stderr and already maps abnormal exits to outcome_unknown.

Checked

  • Searched existing issues in this repository and in abruption/session-peer for duplicates.
  • Removed credentials, conversation contents, private paths and real device/session identifiers.
  • Used isolated fixtures without weakening inbound permissions.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions