← Back to Leaderboard
IZazel-pixel

Zazel-pixel/injection-guard

Local Python hooks that flag prompt injection and block common download-to-shell commands

View on GitHub ↗
Engineering Health (Methodology)
B · 59/100
Maintenance Activity
● Updated 26d ago
Latest Release
Rolling commits (main)
Commercial License Check
MIT · Commercial Friendly

Automated SPDX check for reference only — not legal advice. Disclaimer

Maintenance31/35
Fork Adoption2/25
Release Cadence6/20
License Clarity20/20
CLISelf-Hosted
Total Stars
★ 195
24h Growth
+0
7d Growth
+195
Forks
1

GitHub Star History

Tracked from daily D1 telemetry snapshots. Hover any data point for exact daily star counts.

Zazel-pixel/injection-guard Star History (2026-11-28 - 2026-12-04) DAILY STAR HISTORY (7-DAY D1 TELEMETRY) +194 in 6d · avg +32/day 206 103 0 2026-11-28: ★ 12026-11-29: ★ 1942026-11-30: ★ 1952026-12-01: ★ 1952026-12-02: ★ 1952026-12-03: ★ 1952026-12-04: ★ 195 ★ 195 11-28 12-01 12-04

Evidence-Backed Technical Brief

AI Deep Review

Architecture & Core Mechanics

injection-guard is a single-file Python extension for Claude Code and Codex hooks. PostToolUse inspects returned text from files, web pages, command output, and MCP responses; it can warn the agent but never vetoes the completed call. PreToolUse is the enforcement point: it parses shell quoting and blocks supported download-and-execute patterns without rejecting a command merely because it quotes an example.

The scanner uses regular expressions and Unicode heuristics rather than a trained model. It strips invisible characters for matching and assigns severity based on the pattern and its context. Short citations can be logged without surfacing an alert, while strings in structured value positions remain eligible for alerting. Repeated findings are logged but not shown again within the same session. There is no network dependency.

Key Capabilities & Differentiators

The scanner flags patterns such as instruction overrides, fake authority, credential bait, and tool coercion. The public evaluation counts documents with at least one alert shown to the agent, not all matches. Current results are 1.6% on unmodified InjecAgent attacker instructions versus 100% with an explicit override prefix, 45.5% on 112 held-out Lakera Gandalf prompts, and 4.0% on the English deepset injections. None of the 399 benign deepset prompts surfaced an alert.

Replay of about 86,400 private tool outputs from one person's sessions reduced surfaced alerts from 323 to 53; no genuine injection was identified among the reviewed alerts. This is evidence of lower alert noise on that workload, not a measure of attack recall. For ongoing review, the local JSONL log records redacted excerpts, and tools/audit_log.py --list displays them.

Trade-offs & Limitations

The main advantage is inspectability: one standard-library file, no model to operate, and no remote API. The cost is narrow coverage. English-only patterns miss paraphrases, the German deepset subset produced no alerts, and citation handling trades fewer false alarms for missed detections. The shell gate covers only selected execution forms; it is not a general command policy or sandbox. After a post-tool warning, the agent still decides what to do.

Classifier-based alternatives such as Llama Prompt Guard 2 and LLM Guard are worth evaluating for paraphrase coverage, with additional model runtime and licensing considerations. Azure Prompt Shields and Lakera Guard offer hosted scanning, changing the data boundary. Choose this hook for local visibility and narrow enforcement, while keeping sandboxing, least-privilege credentials, and human approval for consequential actions independent of it.

Hardware & Deployment Guide

Install from a checkout with python3 install.py on Python 3.10 or newer. It copies injection_guard.py to ~/.local/share/injection-guard/, links detected Claude Code and Codex hook directories to the shared copy, and backs up replaced files. The installer does not edit settings: use python3 install.py --config to print the entries to add to ~/.claude/settings.json and ~/.codex/hooks.json as applicable.

Run python3 install.py --check to confirm that both installed hooks, where present, resolve to the shared script and that it matches the checkout. There is no published release to pin; for a repeatable rollout, select a specific revision and validate it with python3 -m unittest discover -s tests and python3 evaluate.py before installing. The runtime is entirely local and reads no model weights.

Hook model: Claude Code and Codex use separate post-tool alerting and pre-shell enforcement hooks.
Execution control: Shell-aware parsing distinguishes supported download-to-shell commands from quoted mentions.
Local audit: JSONL records redacted finding excerpts; tools/audit_log.py summarizes them and --list displays them.
Detection coverage: InjecAgent alert rates were 1.6% for unmodified attacker instructions and 100% with an explicit override prefix; the German deepset subset yielded no alerts.
Regression gates: tests/test_corpus.py checks detection and false-alarm thresholds; evaluate.py --guard OLD.py enables direct comparison against another version.
Installation: One shared local script backs both agents through symlinks; settings registration remains manual.
Best For

Claude Code or Codex teams that want an offline, auditable warning layer for explicit prompt injection and a narrow shell gate alongside existing sandbox and approval controls.

Skip If

You need reliable multilingual or paraphrase detection, comprehensive shell enforcement, or a standalone security boundary for agents with sensitive credentials or broad write access.

Reviewed on 2026-12-02 · Grounded in GitHub README, root file tree & releasesMethodology

Quick Start & Installation

CLISelf-Hosted
python3 install.py

Comparison vs. Top Coding, Skills & MCP Alternatives

Full comparison →
RepositoryStars7d TrendStackLicenseCore Positioning
injection-guard ★195+195PythonMITLocal Python hooks that flag prompt injection and block common download-to-shell
obsidian-skills56.2k+1.7kShellMITAgent Skills plugins for editing Obsidian files and working with vaults
spec-kit153.7k+1.3kPythonMITA Python CLI for spec-driven coding-agent workflows and reviewable handoffs
academic-research-skills59.6k+694Python—Claude Code plugin for human-reviewed research, manuscript writing, and peer rev

AI Context Briefing (for Claude / Cursor / Windsurf)

Standardized architecture summary & quickstart commands ready to paste into coding agents.

Raw .md ↗
curl -sL https://repoforai.com/repo/Zazel-pixel/injection-guard.md

Embed Star History Chart & Badges in README.md

Full-history Star History SVGs and velocity cards on GitHub Camo: drop-in replacement for OSSInsight and Star History widgets.

Zazel-pixel/injection-guard Star History on RepoForAI

Active README embeds unlock Hot-Tier 6h Telemetry Refresh automatically (zero pay-to-rank).

Frequently Asked Questions about injection-guard

How does it integrate, and does it run an MCP server?

It is a local hook extension, not an MCP server. Register PostToolUse and PreToolUse in Claude Code or Codex to inspect returned content and gate supported shell commands, respectively. MCP responses are one kind of tool output the post-tool hook can inspect.

What hardware and runtime budget does it need?

It needs Python 3.10 or newer and the standard library. There are no model weights, GPU or VRAM requirements, or network calls. Processing is described as taking a few milliseconds per tool output; measure latency and log growth with your own output sizes and tool-call volume before a wider rollout.

Can a commercial team self-host it, and what data remains on disk?

Yes. The guard is MIT-licensed and runs locally without sending tool output to a service. However, its JSONL log retains redacted excerpts. Set host-level access and retention policies for that file, and review the notices in corpus/external/NOTICE.md separately if you plan to redistribute evaluation data.

When should I choose a classifier or hosted service instead?

Consider classifier-based tools such as Llama Prompt Guard 2 or LLM Guard if detection needs to extend beyond fixed wording; benchmark them on your own tool outputs and account for model deployment and licensing. Hosted services such as Azure Prompt Shields or Lakera Guard add a remote API and a data-governance decision. A text classifier or service should not be assumed to replace the separate pre-shell execution control.

Upstream README & Documentation

This profile focuses on independent engineering analysis and live telemetry. Read the full upstream README, changelog, and examples directly on GitHub.

Maintaining Zazel-pixel/injection-guard? Pin to Homepage + competitor /alternatives pages with a custom Cloud/Demo CTA.Feature Zazel-pixel/injection-guard on Homepage & Alternatives ($19)
WEEKLY BREAKOUT DIGEST

Top 10 Breakout Open-Source AI Repos, Every Thursday

Signal-only digest of fast-growing AI repos, SPDX license alerts, and architecture picks. Zero spam.

Zero spam · 1-click unsubscribe · Privacy Policy

Saved in your browser · Export Markdown RFC tables or jump into /vs compare