Skip to content

fix(update): stage and verify the pushed standalone in update --host #229

Closed

Description

@abruption

What happened

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

session-peer update --host pushes the standalone with base64 -d > "$D/session_peer.py", overwriting the installed program in place, and then reports updated: true without checking the version the new file reports.

In a synthetic HOME (remote script executed locally, no SSH), a truncated base64 stream left the installed file at 2,304 bytes. With a cleanly truncated stream the script exited 0; the truncated file ran --version with no output and exit 0, and update --host --json returned ok: true, updated: true, previous: 1.0.1, current: 1.0.2 with exit 0. With an invalid stream base64 -d exited 1 and the command failed, but the previous installation had already been replaced by the same 2,304-byte prefix.

Minor: update --host --check compares versions with !=, so a remote that is newer than the local client is reported as outdated ("1.0.3 → 1.0.2 available"), and a non-check update would push the older copy over it.

What you expected

Match the remote path of install.sh: decode into a same-filesystem mktemp staging file, verify that --version reports exactly the expected version, then atomically mv it into place. On any failure, keep the previous installation and report failure. Compare versions by order, not inequality.

Environment

  • Baseline: published session-peer v1.0.2, commit 2046836822b88e53246de73851186598604cb5ec.
  • Reproduction: remote script from push_to_remote run with sh under a synthetic HOME; ssh mocked in update --host. No host was contacted.
  • Audit environment: macOS arm64 (BSD base64), Python 3.14.7, OpenSSH 10.3p1.
  • No live message tests or production mutation.

Source evidence

Acceptance criteria

  • Fixtures for truncated stream, invalid base64, interrupted transfer, invalid artifact and success.
  • On failure the previous file and ~/.local/bin/session-peer link remain usable; only owned staging files are removed.
  • updated: true only when the installed copy reports exactly the pushed version.
  • --check and update never report a newer remote as outdated or downgrade it without an explicit choice.

Scope and limitations

Target: v1.0.3 hardening work. This issue does not authorize a release or operating-service changes.

Related, not duplicates: #204 fixed install.sh but not this code path; #16 and #27 introduced and adjusted update --host.

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