Skip to content

fix(docker): skip symlinked stage2 chown targets - #52789

Merged
benbarclay merged 1 commit into
NousResearch:mainfrom
harjothkhara:fix/stage2-skip-symlink-chown
Jun 26, 2026
Merged

benbarclay merged 1 commit into
NousResearch:mainfrom
harjothkhara:fix/stage2-skip-symlink-chown

Conversation

@harjothkhara

Copy link
Copy Markdown
Contributor

What does this PR do?

Prevents the Docker stage2 ownership repair from following symlinked $HERMES_HOME targets. Recursive repairs now skip symlinked Hermes-owned subdirectories such as home, profiles, and cron; allowlisted top-level state files also skip symlinked paths; and first-boot seed paths refuse to write through symlinks.

This keeps the existing targeted-ownership contract intact: Hermes repairs files and directories it owns, without recursively changing ownership of host-owned paths reached through symlinks.

Related Issue

Fixes #52781

Type of Change

  • Bug fix (non-breaking change that fixes an issue)
  • Security fix
  • Tests (adding or improving test coverage)

Changes Made

  • docker/stage2-hook.sh: add a symlink-aware recursive chown helper for Hermes-owned subtrees.
  • docker/stage2-hook.sh: skip symlinked allowlisted top-level files before chown/chmod.
  • docker/stage2-hook.sh: refuse first-boot seeding through dangling symlink paths.
  • tests/tools/test_stage2_hook_symlink_chown.py: cover real-directory repair and symlinked-directory refusal.
  • tests/tools/test_stage2_hook_toplevel_chown.py: cover symlinked allowlisted file refusal.
  • tests/tools/test_stage2_hook_gateway_bootstrap_state.py: cover gateway bootstrap symlink refusal.
  • tests/test_docker_home_override_scripts.py: update the profiles/cron repair contract for the helper.

How to Test

  1. scripts/run_tests.sh tests/tools/test_stage2_hook_symlink_chown.py tests/tools/test_stage2_hook_toplevel_chown.py tests/tools/test_stage2_hook_gateway_bootstrap_state.py tests/tools/test_stage2_hook_unraid_uid.py tests/tools/test_stage2_hook_log_dir_seed.py tests/tools/test_dockerfile_immutable_install.py tests/test_docker_home_override_scripts.py
  2. sh -n docker/stage2-hook.sh
  3. git diff --check

Duplicate-work checks

  • Exact issue search: gh pr list --repo NousResearch/hermes-agent --state all --search "52781" -> no PRs.
  • Broader keyword search: gh pr list --repo NousResearch/hermes-agent --state all --search "stage2-hook chown symlink destroy home directory docker" -> no PRs.

Checklist

Code

  • I've read the Contributing Guide
  • My commit messages follow Conventional Commits
  • I searched for existing PRs to make sure this isn't a duplicate
  • My PR contains only changes related to this fix
  • I've run focused tests and all tests pass
  • I've added tests for my changes
  • I've tested on my platform: macOS local shell harness; Docker runtime behavior is covered by stage2 script contract tests

Documentation & Housekeeping

  • Documentation update N/A
  • cli-config.yaml.example update N/A
  • CONTRIBUTING.md / AGENTS.md update N/A
  • Cross-platform impact considered
  • Tool descriptions/schemas N/A

Screenshots / Logs

Focused proof passed locally:

39 tests passed, 0 failed

@harjothkhara
harjothkhara force-pushed the fix/stage2-skip-symlink-chown branch from 5a37043 to e83ce11 Compare June 26, 2026 01:56
@alt-glitch alt-glitch added type/bug Something isn't working area/docker Docker image, Compose, packaging P1 High — major feature broken, no workaround sweeper:risk-security-boundary Sweeper risk: may affect sandboxing, auth, credentials, or sensitive data labels Jun 26, 2026
@harjothkhara
harjothkhara force-pushed the fix/stage2-skip-symlink-chown branch from e83ce11 to a998840 Compare June 26, 2026 02:06
@benbarclay
benbarclay marked this pull request as ready for review June 26, 2026 02:09
@benbarclay
benbarclay merged commit 233ef98 into NousResearch:main Jun 26, 2026
26 checks passed
pai-scaffolde pushed a commit to Scaffolde/hermes-agent that referenced this pull request Jun 28, 2026
Prevents stage2-hook.sh recursive chown from following a symlinked $HERMES_HOME/home (or profiles/cron) and destroying the host user's home directory. Also guards top-level state-file chowns and refuses first-boot seeding through symlinks. Fixes NousResearch#52781.

Co-authored-by: harjoth <harjoth.khara@gmail.com>
waefrebeorn pushed a commit to waefrebeorn/slermes that referenced this pull request Jul 2, 2026
Prevents stage2-hook.sh recursive chown from following a symlinked $HERMES_HOME/home (or profiles/cron) and destroying the host user's home directory. Also guards top-level state-file chowns and refuses first-boot seeding through symlinks. Fixes NousResearch#52781.

Co-authored-by: harjoth <harjoth.khara@gmail.com>
habarmc1223-sudo pushed a commit to habarmc1223-sudo/hermes-agent-fluxmem that referenced this pull request Jul 8, 2026
Prevents stage2-hook.sh recursive chown from following a symlinked $HERMES_HOME/home (or profiles/cron) and destroying the host user's home directory. Also guards top-level state-file chowns and refuses first-boot seeding through symlinks. Fixes NousResearch#52781.

Co-authored-by: harjoth <harjoth.khara@gmail.com>
santhreal pushed a commit to santhreal/hermes-agent that referenced this pull request Jul 13, 2026
Prevents stage2-hook.sh recursive chown from following a symlinked $HERMES_HOME/home (or profiles/cron) and destroying the host user's home directory. Also guards top-level state-file chowns and refuses first-boot seeding through symlinks. Fixes NousResearch#52781.

Co-authored-by: harjoth <harjoth.khara@gmail.com>
Gravezzz pushed a commit to Gravezzz/hermes-agent that referenced this pull request Jul 21, 2026
Prevents stage2-hook.sh recursive chown from following a symlinked $HERMES_HOME/home (or profiles/cron) and destroying the host user's home directory. Also guards top-level state-file chowns and refuses first-boot seeding through symlinks. Fixes NousResearch#52781.

Co-authored-by: harjoth <harjoth.khara@gmail.com>
leewenjie pushed a commit to leewenjie/hermes-agent that referenced this pull request Aug 7, 2026
Prevents stage2-hook.sh recursive chown from following a symlinked $HERMES_HOME/home (or profiles/cron) and destroying the host user's home directory. Also guards top-level state-file chowns and refuses first-boot seeding through symlinks. Fixes NousResearch#52781.

Co-authored-by: harjoth <harjoth.khara@gmail.com>
melon-xf added a commit to melon-xf/hermes-agent that referenced this pull request Sep 3, 2026
Prevents stage2-hook.sh recursive chown from following a symlinked $HERMES_HOME/home (or profiles/cron) and destroying the host user's home directory. Also guards top-level state-file chowns and refuses first-boot seeding through symlinks. Fixes NousResearch#52781.

Co-authored-by: harjoth <harjoth.khara@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/docker Docker image, Compose, packaging P1 High — major feature broken, no workaround sweeper:risk-security-boundary Sweeper risk: may affect sandboxing, auth, credentials, or sensitive data type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(docker): stage2-hook chown -R follows symlinks, can destroy user home directory

3 participants