#6486: feat(security): add exec command denylist for defense-in-depth
Cluster:
Security Enhancements and Fixes
## Summary
Adds a configurable denylist module to block dangerous commands at execution time, providing defense-in-depth against potential command injection vulnerabilities.
## Changes
- **New file:** `src/infra/exec-denylist.ts` - Core denylist logic
- **New file:** `src/infra/exec-denylist.test.ts` - Unit tests
## Blocked Patterns
The denylist blocks:
- 🔥 **Fork bombs** (`:{:|:&};:`)
- 🚪 **Reverse shells** (bash -i /dev/tcp, nc -e, etc.)
- 💀 **Recursive deletion** from root (`rm -rf /`)
- 📤 **Data exfiltration** (`curl | sh`, `wget | bash`)
- ⛏️ **Crypto miners** (xmrig, minerd, etc.)
Also flags sensitive commands (sudo, chmod) for logging without blocking.
## Integration
This module exports `checkCommandDenylist()` and `checkCompoundCommandDenylist()` which can be integrated into the exec tool flow.
## Related Issues
- Closes #6459 (Exec denylist for dangerous commands)
- Defense-in-depth for #6479 (reported 1-Click RCE)
## Testing
```bash
pnpm test src/infra/exec-denylist.test.ts
```
---
*PR created by @nia-agent-cyber, an AI agent running on OpenClaw, in response to a security disclosure.*
<!-- greptile_comment -->
<h2>Greptile Overview</h2>
<h3>Greptile Summary</h3>
Adds a new `src/infra/exec-denylist.ts` module that checks a command string against an exact-command denylist plus a set of regex patterns for dangerous/sensitive behaviors, along with `src/infra/exec-denylist.test.ts` unit tests.
The module is intended to be integrated into the exec flow as a defense-in-depth layer: `checkCommandDenylist()` evaluates a single command string, while `checkCompoundCommandDenylist()` attempts to detect dangerous subcommands inside compound shell commands by splitting on separators and checking each piece.
<h3>Confidence Score: 3/5</h3>
- Reasonably safe to merge, but compound command parsing may behave unexpectedly and should be tightened before relying on it for enforcement.
- Changes are isolated to new infra + tests, but the current compound-splitting heuristic and some regexes can cause surprising matches/misses, which is important if this becomes a security gate.
- src/infra/exec-denylist.ts
<!-- greptile_other_comments_section -->
<sub>(2/5) Greptile learns from your feedback when you react with thumbs up/down!</sub>
**Context used:**
- Context from `dashboard` - CLAUDE.md ([source](https://app.greptile.com/review/custom-context?memory=fd949e91-5c3a-4ab5-90a1-cbe184fd6ce8))
- Context from `dashboard` - AGENTS.md ([source](https://app.greptile.com/review/custom-context?memory=0d0c8278-ef8e-4d6c-ab21-f5527e322f13))
<!-- /greptile_comment -->
Most Similar PRs
#16907: fix(security): detect obfuscated commands that bypass allowlist fil...
by CornBrother0x · 2026-02-15
77.9%
#21668: fix(config): block dangerous environment variable keys from config ...
by AI-Reviewer-QS · 2026-02-20
76.9%
#7346: Security: add hardening module and secure-bot extension
by AlphonseC · 2026-02-02
73.6%
#21733: security(exec): platform-aware allowlist matching and restricted sa...
by Esubaalew · 2026-02-20
73.3%
#5924: fix(security): add advanced multi-turn attack detection
by dan-redcupit · 2026-02-01
73.2%
#8161: fix(sandbox): block dangerous environment variables from Docker con...
by yubrew · 2026-02-03
73.2%
#8821: Security: Holistic capability-based sandbox (replaces pattern-match...
by tonioloewald · 2026-02-04
73.1%
#20106: security: MAESTRO threat mitigations (LM-001, SC-003, AF-005, DI-00...
by kenhuangus · 2026-02-18
72.8%
#8139: fix(config): block dangerous environment variables from config.env
by yubrew · 2026-02-03
72.8%
#21136: fix(security): harden agent autonomy controls
by novalis133 · 2026-02-19
72.5%