The Context Firewall
for AI Workflows

Stop secrets, PII, and credentials from reaching your LLM — at the git commit, in MCP tool results, and in CI. Zero dependencies. No proxy. No data leaves your environment.

25
Built-in detectors
0
External deps
3
Enforcement layers
0ms
Added latency
The Problem

AI assistants are accelerating data leakage

Developers paste configs into Cursor. Agents read tool results with connection strings. CI logs get fed to LLMs for debugging. Every step is a chance for secrets to leave your environment.

83%
of orgs had a secret leak in 2024
GitGuardian State of Secrets
10M+
secrets exposed on GitHub
per year, growing
$4.9M
avg cost of a data breach
IBM Security Report 2024
The new attack surface: LLM context windows — prompts, tool results, RAG chunks — are now a direct exfiltration vector. No existing tool was built for this.
What We Built

A policy firewall at the context assembly boundary

ContextDuty intercepts sensitive data at three layers that no existing tool covers — before anything reaches an LLM, a prompt, or git history.

Not a proxy. Runs in-process, locally, with zero network hops. Policy-as-code in your repo. Every enforcement decision is auditable.
📁
Layer 1 — Source files
Pre-commit hook blocks secrets before they enter git history
BEFORE GIT
🔌
Layer 2 — MCP context
Tool results are scanned before entering the LLM context window
BEFORE LLM
⚙️
Layer 3 — CI/CD
Every PR diff is scanned; violations fail the pipeline before merge
BEFORE MERGE
📊
Audit Dashboard
Local web UI — findings by detector, 30-day timeline, blocked commits
OBSERVABILITY
Live Demo

Pre-commit hook catches an Anthropic API key

# Developer stages llm_config.py with real keys accidentally
$ git add llm_config.py
$ git commit -m "add LLM integration config"

  🚫 BLOCKED  llm_config.py  (3 finding(s) detected)

❌ Commit rejected — ContextDuty detected sensitive data.
   Run: contextduty redact --in llm_config.py --out llm_config.py

# Developer redacts and retries
$ contextduty redact --in llm_config.py --out llm_config.py
$ cat llm_config.py
ANTHROPIC_API_KEY = "<ANTHROPIC_KEY_aee1b6dbb8>"
OPENAI_API_KEY   = "<OPENAI_KEY_275dd184c2>"
DATABASE_URL     = "<DB_DSN_ed71028c16>"

$ git commit -m "add LLM integration config (redacted)"
[main a1b2c3d] add LLM integration config (redacted)

✅ Zero secrets in git history.
Differentiation

Not an LLM gateway — a shift-left firewall

LLM gateways (LiteLLM, Portkey, Helicone) intercept the API call after a prompt is assembled and sent. They can't catch what's already in a staged file or a tool result.

Capability LLM / MCP Gateway ContextDuty
Blocks secret at git pre-commit
Scans MCP tool results before context window
CI/CD pipeline enforcement
In-process — no network hop, no proxy
Air-gap / regulated environment safe
Your data sent to third-party infraYesNever
Policy-as-code in your repo✓ .contextduty.json
Runtime API call inspection✓ (via MCP server)
Gateways guard the inference call. ContextDuty guards everything upstream of it.
Detection Coverage

25 detectors across 8 categories

Every detector is enabled by default with deterministic masking — the same value always produces the same mask token, enabling correlation across log lines without exposing the raw secret.

Deterministic masks<ANTHROPIC_KEY_aee1b6dbb8> is stable across runs. You can correlate findings across audit logs, CI runs, and MCP traces without ever storing the raw secret.
PII
Email · Phone
Generic tokens
API key · Bearer token
Cloud
AWS key+secret · GCP service account · Google OAuth · Azure storage
AI / ML
OpenAI · Anthropic · HuggingFace
VCS
GitHub PAT (all 6 formats)
SaaS
Slack · Stripe · SendGrid · Mailchimp · npm · Twilio
Database
Postgres · MySQL · MongoDB · Redis DSNs (credential-bearing only)
Crypto material
SSH key · PGP key · PEM · JWT · .env secrets
Enterprise Observability

Audit dashboard — every finding, timestamped, auditable

Every scan writes a JSONL audit entry — no raw secret values, only finding counts and detector names. The local dashboard shows trends, blocked commits, and per-developer activity.

📈
30-day findings timeline
Spikes correlate with sprints, deployments, new team members
🚫
Blocked commits tracker
Shows who almost leaked what, and when the hook saved them
📥
CSV export
One-click download for compliance reports and security reviews

Run contextduty dashboard --demo to see it now

ContextDuty Audit Dashboard
Policy as Code

One JSON file governs all three enforcement layers

Teams commit .contextduty.json to the repo. Policy changes go through code review. Individual developers can override per-detector modes — block vs redact vs audit-only — for their specific context.

Per-detector modes — block AWS keys, redact emails, warn on phone numbers. All in one file, version-controlled, reviewed in PRs.
🔒 block
✏️ redact
👁️ audit-only
✅ allow_patterns
📋 policy inheritance
{
  "mode": "redact",
  "detectors": [
    "anthropic_key", "openai_key",
    "aws_key", "aws_secret",
    "db_dsn", "github_pat"
  ],
  "detector_modes": {
    "aws_key":  "block",   // never allow
    "email":   "redact",  // mask it
    "phone":   "audit"    // log, don't block
  },
  "allow_patterns": {
    "email": [".*@acme\\.com"]  // internal ok
  },
  "extends": "../org-base-policy.json"
}
Integration

Works where developers already work

🖥️
CLI + CI/CD
contextduty scan file.py
contextduty redact \
  --in raw.py --out clean.py
GitHub Actions · GitLab CI · Jenkins
🔌
MCP Server
# ~/.cursor/mcp.json
{
  "mcpServers": {
    "contextduty": {
      "command": "contextduty-mcp"
    }
  }
}
Cursor · VS Code · Claude Desktop
🪝
Pre-commit Hook
contextduty install-hooks

# .pre-commit-config.yaml
repos:
  - repo: local
    hooks:
      - id: contextduty
        name: ContextDuty scan
Auto-blocks at every commit
Roadmap

Built in weeks. Roadmap for months.

✅ Done — v0.1
Foundation
25 detectors · CLI (scan/redact) · MCP server · Pre-commit hook · Policy-as-code · Per-detector modes · Audit log · Dashboard
🔜 Next — v0.2
Integrations
Presidio integration (names, locations) · VS Code extension · GitHub App for org-level policy · Slack alerting from audit log
🗓️ Q3 — v0.3
Enterprise
SSO-gated policy server · Centralized audit log aggregation · SIEM webhook export · SBOM auto-generation · SOC2 evidence export
🔭 Later
AI-Aware
LLM-as-detector for novel PII patterns · Context-aware false-positive reduction · Auto-remediation suggestions · Semantic similarity matching

The context firewall every AI-native team needs

LLM gateways watch the API call. ContextDuty watches the source — the file, the commit, the tool result, the context window — where leakage actually starts.

pip install
contextduty
MIT
Open source
170
Tests passing

Try the demo: contextduty dashboard --demo  ·  Full five-act demo: bash demo/real_demo.sh

1 / 11