Skip to content

fix(ssh): propagate the verified remote exit code instead of collapsing usage refusals to 1 #52

Closed

Description

@abruption

What happened

Security and stability hardening audit finding TS-04 / Low (2026-09-28). Priority is an audit recommendation, not a claim of a production incident.

README documents exit codes as 0/1/2 for success/error/usage. For SSH requests the remote exit code is validated ([0, 1, 2] and consistent with ok), but the local process then sets process.exitCode = result.ok === false ? 1 : 0. A remote usage refusal such as ambiguous_target (remote exit 2) becomes local exit 1, while the same refusal produced locally exits 2.

Reproduced with a fake ssh on a scratch PATH returning a valid refusal JSON with exit 2: the local exit code was 1.

What you expected

When the remote response is verified, the verified remote exit code is propagated, so local and SSH invocations of the same refusal return the same exit code.

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

Acceptance criteria

  • SSH refusal with verified remote exit 2 exits 2 locally.
  • Contract test comparing local and SSH exit codes for the same refusal.

Scope and limitations

Contract consistency only; the JSON result already carries the correct error code.

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