Real-time terminal guard for the AI era.
Stops rm -rf /, curl | bash traps, and homograph attacks β before they run.
~23.5 Β΅s latency. Zero config. Local-only.
Get Started β’ Features β’ Demo β’ Performance β’ Config
We've all been there. A misplaced space in rm -rf / tmp/, a copyβpaste from a malicious site, or a curl | bash that looked safe but used a Cyrillic 'Ρ' instead of a Latin 'i'.
Your browser catches these attacks. Your terminal doesn't. ShellShield does.
ShellShield is a highβperformance, intelligent shell hook that tokenizes every command with a real shell parser to intercept destructive actions, homograph attacks, and terminal injections before they execute.
ShellShield intercepting rm -rf / and blocking a homograph attack before execution.
- ContextβAware: Uses
shell-quoteto distinguishrmas a command vs. a string ingrep. - Recursive Analysis: Dives into subshells (
sh -c "...") up to 5 levels. - Smart Suggestions: Blocks
rm -rf folder/and suggeststrash folder/. - Critical Path Guard: Prevents
mv,cp, orrmon/etc,/usr,/,C:\Windows.
- Interpreter RCE Defense: Blocks
python -c "$(curl ...)",node -e,ruby -e,perl,php. - Homograph Defense: Catches visually identical malicious domains (
Ρnstall.com). - Injection Protection: Blocks ANSI escapes and zeroβwidth characters.
- Safe PipeβtoβShell: Flags
curl | bashunless domain is trusted. - Encoded Payload Guard: Blocks
base64 -d | shandxxd -r -p | sh. - Credential Guard: Detects plainβtext passwords in URLs.
- Git Workflow Safety: Prevents deleting files with uncommitted changes.
- Volume Threshold: Intercepts accidental globs that target too many files.
- Permissive Mode: Logβonly mode for audits and CI.
- Rotated Audit Log: JSON trace in
~/.shellshield/audit.log(autoβrotated at 1MB).
- 42,573 ops/sec benchmark throughput
- ~23.5Β΅s latency per command (imperceptible to humans)
- 117 tests covering bypasses, edge cases, and advanced attacks
- Local-only execution: runs as a shell hook on your machine.
- No daemon required: checks happen at command time.
- Transparent audit log: records decisions to
~/.shellshield/audit.log. - Open ruleset: all detection logic lives in
src/parser/rules/. - Extensive tests: security and bypass cases covered in
tests/. - ReDoS Protection: All regex patterns use bounded quantifiers and input validation to prevent catastrophic backtracking attacks.
If you believe you have found a security issue, please report it privately. Preferred: open a GitHub Security Advisory with clear reproduction steps and impact. If private reporting is not possible, open a GitHub issue without exploit details.
ShellShield uses regex patterns for threat detection. To prevent Regular Expression Denial of Service (ReDoS) attacks:
- Input length limits: All regex operations are limited to 10,000 character inputs
- Bounded quantifiers: Patterns use
{0,10}instead of*or+where possible - Character class negation: Uses
[^|]*instead of.*to prevent backtracking - Lazy quantifiers: Uses
.*?instead of.*where unbounded matching is necessary - Performance testing: All patterns are tested against malicious inputs
See src/security/patterns.ts for implementation details and tests/regex_security.test.ts for security test cases.
| Feature | ShellShield | Basic Aliases | shellcheck |
|---|---|---|---|
| Contextβaware parsing | β | β | |
| Homograph detection | β | β | β |
| Subshell recursion | β | β | β |
| Zero config needed | β | β | β |
| AI agent safe | β | β | β |
| Performance | 42.6k ops/sec | N/A | ~10k ops/sec |
- Download the installer
curl -fsSL https://hevlyo.github.io/ShellShield/install.sh -o /tmp/shellshield-install.sh- Verify integrity
echo "c92fe9ac968e5e7c421130b50981c4bdd715b51117390e936e1d122a82c00e3c /tmp/shellshield-install.sh" | sha256sum --check- Run only if OK
SHELLSHIELD_INSTALL_SHA256="c92fe9ac968e5e7c421130b50981c4bdd715b51117390e936e1d122a82c00e3c" \
bash /tmp/shellshield-install.shThatβs it. ShellShield is now guarding your terminal.
SHA256 (install.sh): c92fe9ac968e5e7c421130b50981c4bdd715b51117390e936e1d122a82c00e3c
GPG verification (optional):
curl -fsSL https://hevlyo.github.io/ShellShield/install.sh.asc -o /tmp/shellshield-install.sh.asc
gpg --keyserver keys.openpgp.org --recv-keys 744857708F52A3F4885EDA5CF38DA114834A9FA0
gpg --verify /tmp/shellshield-install.sh.asc /tmp/shellshield-install.shTry:
rm -rf /tmp/testgit clone https://github.com/hevlyo/ShellShield
cd ShellShield
bun install
bun run src/index.ts --initnpm i -g .
shellshield --initWhen the published package exposes the shellshield binary:
npm i -g @shellshield/shellshield
shellshield --initRun:
shellshield --initChoose your protection mode (recommended after install):
shellshield --select-modePaste the output into your shell profile. Supported shells: bash, zsh, fish, PowerShell (PSReadLine). The installer auto-wires bash/zsh/fish profiles by default.
Common profile locations:
- bash:
~/.bashrc - zsh:
~/.zshrc - fish:
~/.config/fish/config.fish - PowerShell:
$PROFILE
Optional: zsh bracketed paste hook (auto-checks pasted blocks):
export SHELLSHIELD_PASTE_HOOK=1Paste mode checks multi-line paste buffers before execution:
shellshield --pasteExamples:
- macOS:
pbpaste | shellshield --paste - Linux (xclip):
xclip -o -selection clipboard | shellshield --paste - PowerShell:
Get-Clipboard | shellshield --paste
Score potentially risky URLs:
shellshield --score https://example.com/install.shJSON output:
shellshield --score https://example.com/install.sh --jsonSafer replacement for curl | bash: download, inspect, score, and confirm.
shellshield --run https://example.com/install.shUseful flags:
--dry-run: review only, do not execute--yes: execute without interactive confirmation--force: allow execution in enforce mode even with risky findings
shellshield --run https://example.com/install.sh --dry-runInspect the latest audit entry that triggered a rule:
shellshield --whyShow the latest shellshield --run audit receipt:
shellshield --receiptList recent receipts:
shellshield --receipt --list --count 10If your installed package version includes the shellshield binary:
- bunx:
bunx @shellshield/shellshield --init - npx:
npx @shellshield/shellshield --init - pnpm:
pnpm dlx @shellshield/shellshield --init - Standalone binary (local build):
bun run build->dist/shellshield
Remove the hook line from your shell config (~/.zshrc or ~/.bashrc) and
restart your shell. Then delete local data:
rm -rf ~/.shellshieldπ¦ Manual Install
curl -fsSL https://bun.sh/install | bash
git clone https://github.com/hevlyo/ShellShield
cd ShellShield
bun install
bun run src/index.ts --initEarly adopters are welcome. Want your team listed here? Open a PR or issue with your logo/name.
See ROADMAP.md for public priorities and upcoming work.
ShellShield works out of the box. Create .shellshield.json to customize:
{
"blocked": ["rm", "shred", "custom-killer"],
"allowed": ["ls", "cat"],
"trustedDomains": ["github.com", "my-company.com"],
"threshold": 100,
"mode": "enforce",
"maxSubshellDepth": 5,
"contextPath": "~/.shellshield/shell-context.json"
}enforce(default): blocks dangerous commandspermissive: logs warnings but allows executioninteractive: prompts for confirmation
Set or inspect mode from CLI:
shellshield --mode
shellshield --mode enforce
shellshield --mode interactive
shellshield --mode permissive
shellshield --select-mode| Mode | What it does | When to use |
|---|---|---|
enforce |
Blocks dangerous commands | Daily use |
permissive |
Logs only | First days / CI |
interactive |
Prompts for confirmation | When AI-generated commands are uncertain |
SHELLSHIELD_THRESHOLD: max files per delete (default: 50)SHELLSHIELD_MODE: setpermissiveorinteractiveSHELLSHIELD_SKIP: bypass checks for next command (values:1,true,yes,on,enable,enabled)SHELLSHIELD_MAX_SUBSHELL_DEPTH: max nestedsh -canalysis depth (default: 5)- Recommended: keep between
3and6for low overhead; raise only if you rely on deep nested shells.
# All of these work:
SHELLSHIELD_SKIP=1 rm -rf /tmp/test
SHELLSHIELD_SKIP=true rm -rf /tmp/test
SHELLSHIELD_SKIP=yes rm -rf /tmp/test
SHELLSHIELD_SKIP=on rm -rf /tmp/test
SHELLSHIELD_SKIP=enable rm -rf /tmp/test
SHELLSHIELD_SKIP=enabled rm -rf /tmp/test
# Or set globally (not recommended for daily use):
export SHELLSHIELD_SKIP=1
rm -rf /tmp/testShellShield analyzes the raw command string. Your shell aliases/functions are not automatically expanded.
Optional safety check (recommended if you use lots of aliases):
# Generate a snapshot of `type <cmd>` for common commands
bun run src/index.ts --snapshot
# Enable checks (blocks if a seemingly-safe command resolves to an alias/function
# that references a blocked primitive like rm/shred)
export SHELLSHIELD_CONTEXT_PATH="$HOME/.shellshield/shell-context.json"
# Optional: auto-refresh snapshot when your shell loads the hook
export SHELLSHIELD_AUTO_SNAPSHOT=1You can also inspect your current shell resolution with:
bun run src/index.ts --doctorFor AI coding assistants
{ "mode": "interactive", "trustedDomains": ["github.com", "githubusercontent.com"] }For CI/CD pipelines
{ "mode": "permissive", "threshold": 1000 }For junior onboarding
{ "mode": "enforce", "blocked": ["rm", "mv", "dd", "shred"] }Want to add a new security rule? Itβs fast:
- Create a class in
src/parser/rules/implementingSecurityRule - Add TSDoc explaining the threat
- Write tests in
tests/ - Run
bun testandbun run benchmark.ts
- claude-rm-rf by Zach Caceres β original inspiration for the project
- Tirith by @sheeki03 β inspiration for
curl | bashprotection after seeing their X post; great work on supply chain security
β Star this repo if ShellShield saved you from a disaster.
π‘οΈ Built for those who roll the boulder every day. Ship safe.
