Skip to content

Deny writes into SSH keys, sshd_config and disks by any common tool - #12

Merged
wintermeyer merged 3 commits into
mainfrom
wintermeyer/guard-key-writes
Sep 17, 2026
Merged

wintermeyer merged 3 commits into
mainfrom
wintermeyer/guard-key-writes

Conversation

@wintermeyer

Copy link
Copy Markdown
Owner

The taboo guard caught rm, mv, chmod and > on SSH keys. It let tee, cp, rsync, scp, dd of=, curl -o, sed -i and editors through, and several of those also reached sshd_config and raw disks.

A new writes_to check covers all three targets:

  • A copy is judged by its destination, so scp -i ~/.ssh/id_…, a backup of authorized_keys and cp /dev/sda disk.img still pass.
  • In-place edits count only when the key comes after the tool in the same invocation, so ssh -i key host "sed -i …" stays allowed.
  • One accepted false positive: rsync … -e "ssh -i key" with -e after the operands. It's listed in the header.

Every new deny case fails against the old guard, and no pass case does. No code block in rules/ or skills/ changes its verdict, and the guard costs about 2 ms more per call. This merges cleanly with #10 and #11, and all three together pass the matrix.

cc @oliverandrich, could you double-check this too, please?

An AI agent wrote this text in my name. I know that is problematic.

The taboo guard knew rm, mv, chmod and a redirect, so tee, cp, rsync, scp, dd of=, a download, sed -i or an editor could replace authorized_keys or a host key unnoticed, and several of those also reached sshd_config and raw disks. One writes_to check now covers all three targets and judges a copy by its destination, because scp -i with an identity file, a backup of authorized_keys and an image taken from a disk name the protected path as the source. In-place edits count only when the key follows the tool in the same invocation, so an ssh -i wrapper around a remote sed stays allowed.

An AI agent wrote this text in my name. I know that is problematic.
@wintermeyer wintermeyer self-assigned this Sep 17, 2026
ShellCheck reads $DEV[ and $EDITOR[ as array expansions and fails CI at error severity, although POSIX sh expands them as intended. Braces keep the meaning and the linter quiet.

An AI agent wrote this text in my name. I know that is problematic.
@wintermeyer
wintermeyer merged commit 75771c6 into main Sep 17, 2026
1 check passed
@wintermeyer
wintermeyer deleted the wintermeyer/guard-key-writes branch September 17, 2026 09:01
@wintermeyer

Copy link
Copy Markdown
Owner Author

@oliverandrich I merged this without waiting for your review, so it goes out with the next release. I'd still be glad if you took a look when you have time, especially at whether the destination check misses a copy you'd expect it to catch, or blocks one you need. I'll fix anything you spot in a follow-up.

An AI agent wrote this text in my name. I know that is problematic.

wintermeyer added a commit that referenced this pull request Sep 17, 2026
Three changes since 2.20.1, all around the taboo guard: it now catches writes into SSH keys, sshd_config and disks by the common tools (#12), rule files mark the blocks it is meant to deny (#11), and the key fingerprint probe runs in a call of its own (#10). A minor release because the guard now denies commands it used to let through; #10 and #11 close gaps Oliver Andrich found in #8.

Release notes in CHANGELOG.md; the reasoning per change is in the preceding commits.

An AI agent wrote this text in my name. I know that is problematic.
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.

1 participant