Skip to content

fix(approval): recognize wrapper-prefixed kill spellings in self-host guard - #165

Merged
OmarB97 merged 1 commit into
mainfrom
fix/self-host-kill-wrapper-prefixes
Jun 11, 2026
Merged

fix(approval): recognize wrapper-prefixed kill spellings in self-host guard#165
OmarB97 merged 1 commit into
mainfrom
fix/self-host-kill-wrapper-prefixes

Conversation

@OmarB97

@OmarB97 OmarB97 commented Jun 11, 2026

Copy link
Copy Markdown
Owner

Why

Upstream review on NousResearch#43157 (the mirror of #128) found a bypass: command kill <pid> and builtin kill <pid> are plain shell spellings that still execute kill, but _KILL_CMD_RE only matched kill as the first word of a command segment, so both returned approved.

What changed

  • tools/approval.py: _KILL_CMD_RE now anchors kill at command position via the shared _CMDPOS fragment, and _CMDPOS's wrapper inventory gains command [-p] and builtin. Wrapper chains (sudo, env, exec, nohup, setsid, time, command, builtin) are consumed before the anchor, so all those spellings hit the guard. command -v/-V stays unmatched — it resolves a name without executing it. The _CMDPOS extension also hardens the shutdown/reboot hardline patterns for free (command shutdown was the same class of bypass).
  • tests/tools/test_hardline_blocklist.py: 5 new cases — the reported probes end-to-end through check_all_command_guards, wrapper chains, foreign-PID allow via wrappers, and command -v precision.

Verification

tests/tools/test_hardline_blocklist.py — 115 passed (110 pre-existing + 5 new) on this branch and on the upstream mirror branch. Full approval cluster (6 files) — 370 passed. The reviewer's exact probe (command kill <own-pid> / builtin kill <own-pid> via _check_self_host_kill + check_all_command_guards) now blocks both forms.

Notes

Fork-side mirror of the review fix pushed to upstream PR NousResearch#43157 (branch mirror/self-host-kill-guard, commit 2f05e2b9c cherry-picked here). Follow-up to #128.

… guard

Review follow-up on upstream PR NousResearch#43157: `command kill <pid>` and
`builtin kill <pid>` execute kill but bypassed _KILL_CMD_RE, which only
matched kill as the first word of a command segment. Anchor the kill
guard at command position via _CMDPOS and add `command [-p]` / builtin
to the shared wrapper inventory, so wrapper chains (sudo, env, exec,
nohup, setsid, time, command, builtin) are consumed before the anchor.
`command -v/-V` stays unmatched — it resolves a name without executing.

tests/tools/test_hardline_blocklist.py: 5 new cases covering the
reported bypass probes end-to-end, wrapper chains, foreign-PID allow,
and command -v precision. 115 passed; approval cluster 370 passed.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown

🔎 Lint report: fix/self-host-kill-wrapper-prefixes 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: 10630 on HEAD, 10630 on base (➖ 0)

🆕 New issues: none

✅ Fixed issues: none

Unchanged: 5558 pre-existing issues carried over.

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

@OmarB97
OmarB97 merged commit 59a7a1b into main Jun 11, 2026
29 checks passed
@OmarB97
OmarB97 deleted the fix/self-host-kill-wrapper-prefixes branch June 11, 2026 00:20
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