Skip to content

fix(ssh): keep bulk sync extraction scoped to .hermes - #30172

Merged
teknium1 merged 2 commits into
mainfrom
hermes/hermes-02abec57
May 22, 2026
Merged

fix(ssh): keep bulk sync extraction scoped to .hermes#30172
teknium1 merged 2 commits into
mainfrom
hermes/hermes-02abec57

Conversation

@teknium1

Copy link
Copy Markdown
Contributor

Salvage of #10205 onto current main. Original author @Stark-X — commit authorship preserved via cherry-pick.

Summary

SSH backend bulk-upload no longer extracts its tar stream at /, eliminating the tar extract over SSH failed ... Cannot change mode ... Operation not permitted errors and the silent home-directory permission widening that breaks sshd StrictModes.

Root cause

_ssh_bulk_upload() mirrored absolute remote paths into the staging dir (home/<user>/.hermes/...) and ran tar xf - -C / on the remote. With a local umask of 002 the staging dirs are created 0775, and tar applies those modes to existing /home and /home/<user> on the remote on extract — even with --no-overwrite-dir, the failing chmod surfaces as the rc=2 error Bertl reported. On hosts with StrictModes yes (default on most OpenSSH builds) this also rejects the next login.

Changes

  • tools/environments/ssh.py: stage relative to $REMOTE_HOME/.hermes, reject paths that escape the base, extract with -C <base> instead of -C / (~20 LOC)
  • tests/tools/test_ssh_bulk_upload.py: updated 2 expectations + new regression test test_bulk_upload_never_stages_remote_home_prefix
  • scripts/release.py: AUTHOR_MAP entry for @Stark-X

Validation

  • scripts/run_tests.sh tests/tools/test_ssh_bulk_upload.py tests/tools/test_ssh_environment.py → 46/46 pass
  • E2E with real _ssh_bulk_upload calls (subprocess mocked at the boundary):
    • legit upload /home/testuser/.hermes/cache/foo.txt → staging tree is cache/foo.txt only, no home/ prefix
    • /etc/passwd → rejected: remote path '/etc/passwd' escapes sync base '/home/testuser/.hermes'
    • bare base path → rejected

Closes #10205.

@teknium1
teknium1 merged commit 4e2c66a into main May 22, 2026
16 of 17 checks passed
@teknium1
teknium1 deleted the hermes/hermes-02abec57 branch May 22, 2026 02:17
@github-actions

Copy link
Copy Markdown
Contributor

🔎 Lint report: hermes/hermes-02abec57 vs origin/main

ruff

Total: 0 on HEAD, 0 on base (➖ 0)

🆕 New issues: none

✅ Fixed issues: none

Unchanged: 0 pre-existing issues carried over.

ty (type checker)

Total: 9011 on HEAD, 9011 on base (➖ 0)

🆕 New issues: none

✅ Fixed issues: none

Unchanged: 4762 pre-existing issues carried over.

Diagnostics are surfaced as warnings — this check never fails the build.

@alt-glitch alt-glitch added type/bug Something isn't working backend/ssh SSH remote execution backend/file-sync File sync across remote backends type/security Security vulnerability or hardening P2 Medium — degraded but workaround exists and removed type/bug Something isn't working labels May 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backend/file-sync File sync across remote backends backend/ssh SSH remote execution P2 Medium — degraded but workaround exists type/security Security vulnerability or hardening

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants