Skip to content

Rules hardening#21

Merged
leogr merged 4 commits intomainfrom
rules-hardening
Apr 30, 2026
Merged

Rules hardening#21
leogr merged 4 commits intomainfrom
rules-hardening

Conversation

@leogr
Copy link
Copy Markdown
Member

@leogr leogr commented Apr 30, 2026

No description provided.

leogr added 4 commits April 30, 2026 17:49
Two distinct false-positive classes seen in the wild:

- string-literal context: "shutdown" matched inside echo labels like
  'echo "=== broker shutdown ==="'. Tighten to require flag/now/+ or
  start-of-command / chained-command position.
- search-pattern context: 'rg ... "rm -rf" file | head' triggered the
  rule because the destructive substring lived inside a regex pattern.
  Add an is_pure_search_or_print_command exemption macro guarded against
  command chaining (&&, ||, ;, $(, backticks). Pipes are allowed; the
  xargs rm -rf gap is documented and accepted.

Tightens 'sudo rm' -> 'sudo rm ' (trailing space) for consistency.
Static per build, derived from cfg!(target_os = ...). Lets rules
condition on the host OS without parsing the payload — needed by
upcoming self-protection rules whose path patterns differ between
Unix and Windows installs.
Three rule families in a new Section 7:

- Deny destructive premptictl subcommands (stop / restart / disable /
  uninstall / daemon / hook remove / mode <arg>); read-only subcommands
  stay allowed.
- Deny per-OS service-stop alternatives, gated on agent.os: systemd
  stop/disable on Linux, launchctl unload/bootout on macOS, taskkill /
  Stop-Service / Run-key delete on Windows, plus pkill/killall against
  falco.
- Deny Write/Edit under the Prempti install prefix and on
  ~/.claude/settings.json; ASK before Read of settings.json.

Prempti only sees agent-initiated tool calls; users invoke premptictl
in their own shell, so denying these patterns from the agent does not
block legitimate user operations.
…ings.local.json

Address findings on the rules-hardening branch:

- is_likely_destructive_command had been narrowed too far. Re-add
  coverage for sudo / absolute-path / systemctl wrappers around
  reboot/halt/shutdown (sudo reboot, /sbin/reboot, systemctl reboot,
  systemctl poweroff, etc.) while keeping the bare 'shutdown' echo
  prose out.
- is_prempti_install_path on Windows was overbroad ('/prempti/'
  matched any repo dir named prempti). Tighten to require
  '/AppData/Local/prempti/' (case-insensitive via icontains).
- is_claude_settings_path now matches both settings.json and
  settings.local.json — Claude Code reads hooks from either file,
  so the deny was bypassable via the .local variant.

Document the new agent.os field in CLAUDE.md, rules/README.md,
plugins/coding-agents-plugin/README.md, and the plugin SPEC.md.
@leogr leogr merged commit 1cb255f into main Apr 30, 2026
6 checks passed
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