Skip to content

fix(ssh): trust the remote in-band result before classifying stderr as a transport failure #228

Closed

Description

@abruption

What happened

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

When the SSH command exits nonzero, run_remote classifies stderr text as an SSH authentication, host-key or timeout failure before it parses stdout. A remote send that was already submitted but reports ok: false (for example a failed wake) exits 1, so any unrelated stderr line containing a marker such as permission denied hides the in-band result.

With a mocked subprocess.run, the remote returned a valid schemaVersion 1 send result (submitted: true, ok: false, wake present), exit status 1, and the stderr line bash: <home>/.env.local: Permission denied from a login-shell startup file. session-peer reported sshFailure: authentication_failed and dropped submitted: true. The same payload with empty stderr was returned correctly. A caller following the authentication hint and retrying would deliver the message twice.

Separately, the 120-second TimeoutExpired on the SSH send path is reported as sshFailure: timeout ("connection timed out"), without stating that the submission outcome is unknown or that automatic retry is unsafe. The Codex queue path and the adapter contract already report such cases as outcome unknown.

What you expected

  • A valid schemaVersion JSON result on stdout is trusted before any stderr classification.
  • Stderr markers are consulted only when ssh itself failed (exit 255) or stdout is empty.
  • A send that times out after the command was started reports the outcome as unknown with automatic retry disallowed.

Environment

  • Baseline: published session-peer v1.0.2, commit 2046836822b88e53246de73851186598604cb5ec.
  • Reproduction: standalone module imported with subprocess.run mocked; no SSH connection was made.
  • Audit environment: macOS arm64, Python 3.14.7, OpenSSH 10.3p1.
  • No live message tests or production mutation.

Source evidence

Acceptance criteria

  • Fixtures: nonzero exit with valid send JSON plus stderr containing each classifier marker; the in-band result, including submitted, is returned.
  • Exit 255 or empty stdout keeps the existing authentication, host-key and timeout classification and messages.
  • A send timeout reports outcome unknown, retryAllowed: false, and no submitted: false claim.
  • list, doctor and update remote paths keep their current behavior or are covered by equivalent tests.

Scope and limitations

Target: v1.0.3 hardening work. This issue does not authorize a release or operating-service changes. The mocked stderr line is illustrative; no historical incident is attributed to it.

Related, not duplicates: #62 introduced authentication-failure reporting, #181 covers explicit ACK/unknown outcomes for handoffs, #182 covers request-ID deduplication for ordinary sends.

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

  1. added this to the v1.0.3 milestone on Sep 28, 2026
  2. added
    bug
    on Sep 28, 2026
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

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions