Skip to content

fix(ssh): bind /etc/ssh from a sanitized copy - #11

Merged
sshine merged 1 commit into
mainfrom
fix/ssh-config
Jul 26, 2026
Merged

fix(ssh): bind /etc/ssh from a sanitized copy#11
sshine merged 1 commit into
mainfrom
fix/ssh-config

Conversation

@sshine

@sshine sshine commented Jul 26, 2026

Copy link
Copy Markdown
Member
  • Closes ssh fails in sandbox: root-owned /etc/ssh/ssh_config rejected under unmapped-uid userns #6
  • Binds /etc/ssh from a per-session copy owned by the invoking user, with every Include commented out.
  • The dropped includes cannot pass OpenSSH's ownership check while uid 0 is unmapped, so nothing is lost that could have worked; a host keeping real client policy in ssh_config.d does lose that.
  • Unreadable sources are skipped, keeping the root-owned host private keys out of the sandbox.
  • Verified ssh -G and git ls-remote inside a box on NixOS, where both aborted before.
  • The second commit is pre-existing mdformat drift; nix flake check fails without it.

- Closes #6

src/bubblebox.js:
- bwrap maps only the invoking uid, so root-owned host config reads as nobody(65534) in the box
- OpenSSH fatally rejects an Included config file owned by neither root nor the invoking user
- so the host's global ssh_config aborted ssh before it ever reached the mounted ~/.ssh
- copy /etc/ssh into the session dir with the Include lines commented out, bind that over /etc
- the includes are host glue (systemd-ssh-proxy, distro crypto policy) that cannot pass the check
- unreadable sources are skipped: the host private keys have no business in here anyway
- the session dir is now 0700 and holds both the sandbox home and the copy, so cleanup stays one rm

tests:
- assert the copy is bound read-only after the host /etc, else it would be shadowed by it
- feed the real ssh both configs: it rejects the fixture's include chain and accepts the copy
- the fixture poisons its include with group-write rather than root ownership, which needs no root
- a dry run now keeps the session dir, since that is where the copy the plan points at lives
@sshine
sshine merged commit edf084c into main Jul 26, 2026
@sshine
sshine deleted the fix/ssh-config branch July 26, 2026 01:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ssh fails in sandbox: root-owned /etc/ssh/ssh_config rejected under unmapped-uid userns

1 participant