Skip to content

Judge the invoking user's authorized keys when removing SSH access - #9573

Open
shaynhornik wants to merge 1 commit into
omacom:quattrofrom
shaynhornik:fix/sshd-remove-target-home
Open

Judge the invoking user's authorized keys when removing SSH access#9573
shaynhornik wants to merge 1 commit into
omacom:quattrofrom
shaynhornik:fix/sshd-remove-target-home

Conversation

@shaynhornik

Copy link
Copy Markdown

Fixes #9572

Problem

omarchy-remove-security-sshd promises to "optionally remove authorized keys" but resolves the file through $HOME. Under sudo/pkexec (the script carries requires-sudo=true, and pkexec is the SKILL.md-prescribed path for terminal-less callers) that is /root/.ssh/authorized_keys: the prompt is silently skipped when root has no keys — leaving the invoking user's keys authorized and live again the moment sshd is re-enabled — or, worse, targets root's keys when root has them.

Fix

The same target-user derivation omarchy-apply-lock uses (OMARCHY_INSTALL_USERSUDO_USERPKEXEC_UID via getent → $USER), then AUTHORIZED_KEYS points at that user's home. Direct invocation is unchanged.

Split from #9571 (the same $HOME-under-escalation class in the data-removal scripts) because this one changes a security decision rather than cleanup coverage; related hardening context: #9267, #9255.

Verification

  • bash -n clean; ./test/cli passes (116 ok).
  • The derivation resolves the invoking user's home under simulated PKEXEC_UID+HOME=/root, SUDO_USER+HOME=/root, and direct invocation.
  • Not run: a live sshd teardown (no Omarchy install in this environment).

🤖 Generated with Claude Code

https://claude.ai/code/session_01FTqr6ZjXfNthXT719ag7Qc

omarchy-remove-security-sshd resolved authorized_keys through $HOME,
but it carries requires-sudo and can arrive under sudo or pkexec,
where $HOME is root's. The key-removal prompt then keys off root's
usually-absent file: the invoking user's keys silently survive the
teardown and are live again if sshd is re-enabled. Derive the invoking
user the way omarchy-apply-lock does and judge that user's keys.

Fixes omacom#9572

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FTqr6ZjXfNthXT719ag7Qc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

1 participant