#21136: fix(security): harden agent autonomy controls
gateway
docker
agents
size: M
Cluster:
OpenClaw Plugin Enhancements
## Summary
- **Rate guard + audit logging for `elevated=full` exec bypass** — Adds a fixed-window rate limiter (30 cmds/60s) and immutable stderr audit trail for every command run under `elevated=full` mode, mitigating abuse of the unrestricted exec path (CWE-250)
- **Restricted tool set for external untrusted content** — Adds `EXTERNAL_CONTENT_RESTRICTED_TOOLS` and `isToolRestrictedForExternalContent()` to `external-content.ts`, providing structural enforcement primitives beyond advisory text markers for prompt injection defense
- **Audit logging for plugin hook prompt/tool modifications** — Logs when `before_prompt_build` replaces the system prompt and when `before_tool_call` modifies tool parameters, making silent plugin mutations visible
- **Block auto-discovered plugins when allowlist is empty** — Non-bundled, non-operator-configured plugins from global/workspace directories are now blocked when `plugins.allow` is empty, preventing untrusted code from auto-loading with full main-process access
- **Defense-in-depth audit logging for dangerous ACP tool calls** — Server-side translator now logs when tools in `DANGEROUS_ACP_TOOLS` are invoked over ACP, complementing the existing client-side approval gate
## Test plan
- [x] All 17 `loader.test.ts` tests pass (including the 3 that initially failed due to over-aggressive blocking of operator-configured plugins)
- [x] Full test suite: 6419 passed, 8 failed (all 8 failures are pre-existing Windows symlink EPERM issues unrelated to these changes)
- [x] Build succeeds with no type errors
- [ ] Manual verification of audit log output for elevated exec and ACP dangerous tool invocations
- [ ] Verify non-bundled plugins in global/workspace dirs are blocked when `plugins.allow` is empty
- [ ] Verify operator-configured plugins (`plugins.load.paths`) still load normally
🤖 Generated with [Claude Code](https://claude.com/claude-code)
<!-- greptile_comment -->
<h3>Greptile Summary</h3>
This PR implements comprehensive security hardening for agent autonomy controls across five key areas. The changes add multiple layers of defense-in-depth protection against abuse of privileged operations.
**Key changes:**
- **Rate limiting for `elevated=full` exec**: Adds 30 commands/60s rate limit with immutable stderr audit logging for every elevated command execution
- **Plugin auto-load blocking**: Blocks auto-discovered plugins (global/workspace) when `plugins.allow` is empty, while correctly allowing operator-configured plugins via `plugins.load.paths`
- **External content tool restrictions**: Introduces `EXTERNAL_CONTENT_RESTRICTED_TOOLS` set and helper function to provide structural enforcement against prompt injection attacks
- **Plugin hook audit logging**: Logs when plugins modify system prompts or tool parameters via `before_prompt_build` and `before_tool_call` hooks
- **ACP dangerous tool logging**: Server-side audit trail when dangerous tools are invoked over the Agent Client Protocol
**Issues found:**
- The `elevated=full` rate limiter at `bash-tools.exec.ts:61-62` uses module-level mutable state with non-atomic increment operations, creating potential race conditions under concurrent load
<h3>Confidence Score: 4/5</h3>
- This PR is largely safe to merge with one notable concurrency issue in the rate limiter that should be addressed
- The PR implements multiple defense-in-depth security hardening measures (audit logging, rate limiting, plugin blocking). All implementations are sound except for the rate limiter which uses non-atomic module-level state that could have race conditions under concurrent load. The plugin loader fix correctly distinguishes between operator-configured (`config`) and auto-discovered plugins. The audit logging additions are properly placed and immutable (stderr). The external content restrictions are well-designed structural primitives.
- Pay close attention to `src/agents/bash-tools.exec.ts` - the rate limiter implementation needs review for concurrency safety
<sub>Last reviewed commit: 75b5c5e</sub>
<!-- greptile_other_comments_section -->
<!-- /greptile_comment -->
Most Similar PRs
#16320: security: harden default tool policies and secure shell execution
by SuccessSoham · 2026-02-14
82.1%
#21964: Security: harden gateway and plugin trust boundaries
by Elormyevu · 2026-02-20
81.3%
#15757: feat(security): add hardening gap audit checks
by saurabhsh5 · 2026-02-13
80.5%
#23574: security: P0 critical remediation — plugin sandbox, password hashin...
by lumeleopard001 · 2026-02-22
79.6%
#17273: feat: add security-guard extension — agentic safety guardrails
by miloudbelarebia · 2026-02-15
79.5%
#6095: feat(gateway): support modular guardrails extensions for securing a...
by Reapor-Yurnero · 2026-02-01
79.1%
#8846: fix(tools): block LLM writes to hooks directories
by yubrew · 2026-02-04
78.9%
#20435: fix(exec): prioritize user 'always allow' config over tool defaults...
by ChisomUma · 2026-02-18
78.9%
#6405: feat(security): Add HTTP API security hooks for plugin scanning
by masterfung · 2026-02-01
78.6%
#23175: feat(security): runtime safety — transcript retention, tool call bu...
by ihsanmokhlisse · 2026-02-22
78.5%