agnostic-security 4.28.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (67) hide show
  1. agnostic_security-4.28.0/PKG-INFO +356 -0
  2. agnostic_security-4.28.0/README.md +322 -0
  3. agnostic_security-4.28.0/agnostic_security.egg-info/PKG-INFO +356 -0
  4. agnostic_security-4.28.0/agnostic_security.egg-info/SOURCES.txt +65 -0
  5. agnostic_security-4.28.0/agnostic_security.egg-info/dependency_links.txt +1 -0
  6. agnostic_security-4.28.0/agnostic_security.egg-info/entry_points.txt +2 -0
  7. agnostic_security-4.28.0/agnostic_security.egg-info/requires.txt +14 -0
  8. agnostic_security-4.28.0/agnostic_security.egg-info/top_level.txt +4 -0
  9. agnostic_security-4.28.0/cli/__init__.py +0 -0
  10. agnostic_security-4.28.0/cli/as_init.py +683 -0
  11. agnostic_security-4.28.0/hooks/__init__.py +0 -0
  12. agnostic_security-4.28.0/hooks/dlp_scan.py +237 -0
  13. agnostic_security-4.28.0/hooks/vuln_scan.py +202 -0
  14. agnostic_security-4.28.0/pyproject.toml +88 -0
  15. agnostic_security-4.28.0/rules/__init__.py +1 -0
  16. agnostic_security-4.28.0/rules/block_rules.py +376 -0
  17. agnostic_security-4.28.0/scripts/__init__.py +0 -0
  18. agnostic_security-4.28.0/scripts/audit.py +221 -0
  19. agnostic_security-4.28.0/scripts/code_scanner.py +304 -0
  20. agnostic_security-4.28.0/scripts/continuous_red_team.py +196 -0
  21. agnostic_security-4.28.0/scripts/demo.py +167 -0
  22. agnostic_security-4.28.0/scripts/harmbench_export.py +321 -0
  23. agnostic_security-4.28.0/scripts/hook_fast.py +249 -0
  24. agnostic_security-4.28.0/scripts/load_test.py +201 -0
  25. agnostic_security-4.28.0/scripts/network_enforcement.py +327 -0
  26. agnostic_security-4.28.0/scripts/nist_score.py +150 -0
  27. agnostic_security-4.28.0/scripts/owasp_score.py +89 -0
  28. agnostic_security-4.28.0/scripts/red_team.py +484 -0
  29. agnostic_security-4.28.0/scripts/red_team_report.py +533 -0
  30. agnostic_security-4.28.0/scripts/run_manual_tests.py +402 -0
  31. agnostic_security-4.28.0/scripts/secagent_check.py +2933 -0
  32. agnostic_security-4.28.0/scripts/smoke_test.py +261 -0
  33. agnostic_security-4.28.0/scripts/test_admin_console.py +246 -0
  34. agnostic_security-4.28.0/scripts/test_block_rules.py +39 -0
  35. agnostic_security-4.28.0/scripts/test_breach_classifier.py +38 -0
  36. agnostic_security-4.28.0/scripts/test_code_fingerprint.py +349 -0
  37. agnostic_security-4.28.0/scripts/test_code_scanner.py +184 -0
  38. agnostic_security-4.28.0/scripts/test_credential_classifier.py +84 -0
  39. agnostic_security-4.28.0/scripts/test_dlp_scanner.py +46 -0
  40. agnostic_security-4.28.0/scripts/test_enterprise_privacy.py +173 -0
  41. agnostic_security-4.28.0/scripts/test_fixes.py +169 -0
  42. agnostic_security-4.28.0/scripts/test_fp_vs_tp.py +120 -0
  43. agnostic_security-4.28.0/scripts/test_gateway_dlp.py +226 -0
  44. agnostic_security-4.28.0/scripts/test_hook_e2e.py +167 -0
  45. agnostic_security-4.28.0/scripts/test_image_ocr_dlp.py +510 -0
  46. agnostic_security-4.28.0/scripts/test_ingress_guard.py +472 -0
  47. agnostic_security-4.28.0/scripts/test_knowledge_graph.py +171 -0
  48. agnostic_security-4.28.0/scripts/test_model_locality.py +172 -0
  49. agnostic_security-4.28.0/scripts/test_outbound_guards.py +176 -0
  50. agnostic_security-4.28.0/scripts/test_pii_prompt_guard.py +377 -0
  51. agnostic_security-4.28.0/scripts/test_privacy_mode.py +150 -0
  52. agnostic_security-4.28.0/scripts/test_production_features.py +341 -0
  53. agnostic_security-4.28.0/scripts/test_red_team.py +405 -0
  54. agnostic_security-4.28.0/scripts/test_secure_fs.py +30 -0
  55. agnostic_security-4.28.0/scripts/test_security_memory.py +248 -0
  56. agnostic_security-4.28.0/scripts/test_shadow_ai.py +148 -0
  57. agnostic_security-4.28.0/scripts/test_smart_router.py +286 -0
  58. agnostic_security-4.28.0/scripts/test_terminal_bypass.py +177 -0
  59. agnostic_security-4.28.0/scripts/test_terminal_guard.py +184 -0
  60. agnostic_security-4.28.0/scripts/test_vuln_scanner.py +285 -0
  61. agnostic_security-4.28.0/scripts/train_enhanced_classifier.py +812 -0
  62. agnostic_security-4.28.0/scripts/train_ml_classifier.py +136 -0
  63. agnostic_security-4.28.0/scripts/vps_monitor.py +139 -0
  64. agnostic_security-4.28.0/setup.cfg +4 -0
  65. agnostic_security-4.28.0/tests/test_exec_output_scan.py +261 -0
  66. agnostic_security-4.28.0/tests/test_integration.py +153 -0
  67. agnostic_security-4.28.0/tests/test_prompt_scenarios.py +651 -0
@@ -0,0 +1,356 @@
1
+ Metadata-Version: 2.4
2
+ Name: agnostic-security
3
+ Version: 4.28.0
4
+ Summary: The firewall for AI coding agents — prevents secrets, PII, and credentials from leaking through Copilot, Claude Code, Cursor, and LangChain
5
+ Author-email: AgnosticSecurity <security@agnosticsecurity.io>
6
+ Project-URL: Homepage, https://securemind.live
7
+ Project-URL: Repository, https://github.com/secure-mind-live/AgnosticSecurity
8
+ Project-URL: Issues, https://github.com/secure-mind-live/AgnosticSecurity/issues
9
+ Project-URL: Documentation, https://secure-mind-live.github.io/agnostic-security-site/docs.html
10
+ Keywords: security,dlp,data-loss-prevention,ai-agents,llm,copilot,claude-code,cursor,windsurf,guardrail,secrets,pii,credentials,devsecops
11
+ Classifier: Development Status :: 4 - Beta
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: Intended Audience :: System Administrators
14
+ Classifier: Topic :: Security
15
+ Classifier: Topic :: Software Development :: Quality Assurance
16
+ Classifier: Programming Language :: Python :: 3.11
17
+ Classifier: Programming Language :: Python :: 3.12
18
+ Classifier: Programming Language :: Python :: 3.13
19
+ Classifier: Environment :: Console
20
+ Classifier: Operating System :: OS Independent
21
+ Requires-Python: >=3.11
22
+ Description-Content-Type: text/markdown
23
+ Requires-Dist: securityagent-core>=3.1.0
24
+ Provides-Extra: gateway
25
+ Requires-Dist: fastapi>=0.110; extra == "gateway"
26
+ Requires-Dist: uvicorn[standard]; extra == "gateway"
27
+ Requires-Dist: httpx; extra == "gateway"
28
+ Requires-Dist: python-dotenv; extra == "gateway"
29
+ Requires-Dist: pydantic-settings>=2.0; extra == "gateway"
30
+ Provides-Extra: llm
31
+ Requires-Dist: ollama; extra == "llm"
32
+ Provides-Extra: all
33
+ Requires-Dist: agnostic-security[gateway,llm]; extra == "all"
34
+
35
+ # AgnosticSecurity
36
+
37
+ **The firewall for AI coding agents.** Prevents secrets, credentials, and PII from leaking through Copilot, Claude Code, Cursor, and LangChain — before the data ever leaves your machine.
38
+
39
+ [![Tests](https://img.shields.io/badge/tests-942%2B%20passing-brightgreen)]()
40
+ [![Red Team](https://img.shields.io/badge/red%20team-274%20attacks%20%2B%2055%20Docker%20agents-blue)]()
41
+
42
+ ---
43
+
44
+ > Your AI coding assistant has read access to your entire codebase — `.env` files, API keys, SSH keys, customer PII. There are zero guardrails. **AgnosticSecurity is that guardrail.**
45
+
46
+ ---
47
+
48
+ ## Quick Start
49
+
50
+ ```bash
51
+ # Option 1: One-command setup (auto-detects your AI tools)
52
+ pip install -e .
53
+ as-init
54
+
55
+ # Option 2: Live demo (starts Docker, runs red team, opens dashboard)
56
+ python3 scripts/demo.py
57
+
58
+ # Option 3: Docker
59
+ docker compose up
60
+
61
+ # Option 3: Just the VS Code extension
62
+ code --install-extension vscode-extension/agnostic-security-4.22.0.vsix
63
+ ```
64
+
65
+ That's it. Your `.env` files, credentials, and PII are now protected from every AI tool in your environment.
66
+
67
+ ---
68
+
69
+ ## What It Does
70
+
71
+ ```
72
+ Your code editor (VS Code / Cursor / Windsurf)
73
+
74
+ │ ── AI tries to read .env ──────────── BLOCKED (file gate)
75
+ │ ── AI autocompletes a secret ──────── BLOCKED (context boundary)
76
+ │ ── @workspace indexes credentials ─── BLOCKED (search.exclude)
77
+ │ ── Prompt contains SSN ────────────── BLOCKED (prompt guard)
78
+ │ ── Agent runs `curl -d @.env` ─────── BLOCKED (exec guard)
79
+ │ ── LLM response leaks PII ────────── BLOCKED (output scan)
80
+ │ ── Memory stores "password is X" ──── BLOCKED (memory guard)
81
+ │ ── Tool call smuggles data out ────── BLOCKED (tool call guard)
82
+ │ ── AI bulk-edits .env (15+ lines) ── REVERTED (AI-vs-human detection)
83
+
84
+ └── Everything else ──────────────────── Works normally
85
+ ```
86
+
87
+ **Key insight:** We don't block AI from editing files (that's a losing game). We make sensitive data **invisible** to AI at every layer — if AI never sees the data, there's nothing to leak.
88
+
89
+ ---
90
+
91
+ ## Protection Layers
92
+
93
+ | Layer | What It Stops | Speed |
94
+ |-------|--------------|-------|
95
+ | **File gate** | AI reading `.env`, credentials, keys | <1ms |
96
+ | **Context boundary** | AI seeing sensitive file content (`.copilotignore`, `search.exclude`, LM API interceptor) | 0ms |
97
+ | **Terminal Guard v4** | AI agents running `cat .env` in terminal — process ancestry tree + input cadence detection (AI vs human typing), bash + zsh support, command wrappers can't be bypassed (humans pass freely) | <1ms |
98
+ | **Exec guard** | `cat ~/.env`, `curl -d @secrets`, obfuscated exfiltration, netcat/SSH tunnels | <1ms |
99
+ | **Prompt guard** | "Show me all API keys", PII in prompts, 10 encoding evasion layers (base64, hex, ROT13, unicode, zero-width chars, reversed text, leetspeak) | <50ms |
100
+ | **Output scan** | LLM responses containing leaked PII/credentials | <1ms |
101
+ | **Taint tracking** | Data exfiltration across sessions (SHA-256 + n-gram Jaccard) | <1ms |
102
+ | **Memory guard** | Memory poisoning ("user authorized all exports"), trust boundary violations | <1ms |
103
+ | **Tool call guard** | MCP tools smuggling data in arguments | <1ms |
104
+ | **Egress allowlist** | `curl` to unauthorized external domains | <1ms |
105
+ | **Lethal trifecta** | Private data + untrusted input + external comm all active simultaneously | <1ms |
106
+ | **Ingress guard** | Malicious external agents probing your APIs (7-layer: fingerprint, behavior, risk, reputation, policy, headers, DLP controls) | <5ms |
107
+ | **DLP controls** | Runtime per-type PII blocking (SSN, credit card, API keys, JWTs) via REST API | <1ms |
108
+ | **Enterprise privacy** | Org-wide policy push, per-team overrides, scheduled mode changes (full_privacy during market hours, balanced after-hours), policy inheritance hierarchy | <1ms |
109
+ | **Model usage reporting** | VS Code reports which AI models devs use to gateway — auto-proxy routes all LLM traffic through DLP | 0ms |
110
+ | **Vuln scanner** | SQL injection, XSS, command injection in AI-generated code | <10ms |
111
+ | **Code fingerprint** | Proprietary code leaking to cloud LLMs | <10ms |
112
+
113
+ ---
114
+
115
+ ## Works With Everything
116
+
117
+ | AI Tool | How |
118
+ |---------|-----|
119
+ | **GitHub Copilot** | VS Code extension (context boundary + LM API interceptor) |
120
+ | **Claude Code** | Hook-based (PreToolUse + UserPromptSubmit) |
121
+ | **Cursor** | `.cursorignore` + VS Code extension |
122
+ | **Windsurf** | `.aiignore` + VS Code extension |
123
+ | **ChatGPT / Claude.ai / Gemini / Grok / Perplexity / DeepSeek / Meta AI / HuggingChat** | Chrome extension (DLP for web LLM interfaces, India PII support: Aadhaar, PAN Card, Indian phone) |
124
+ | **LangChain / Autogen** | Auto-instrumentation SDK (zero-code monkey-patching) |
125
+ | **Any LLM provider** | API Gateway with input/output security pipelines |
126
+
127
+ **Any LLM provider works** — OpenAI, Anthropic, Google, Azure, local Ollama. Security shouldn't depend on your model choice.
128
+
129
+ ---
130
+
131
+ ## Installation Options
132
+
133
+ | Method | Command | Best For |
134
+ |--------|---------|----------|
135
+ | **CLI installer** | `pip install -e . && as-init` | Individual developers |
136
+ | **Pre-commit hooks** | `bash hooks/install.sh` | Teams wanting git-level protection |
137
+ | **GitHub Action** | Add workflow YAML ([see below](#github-action)) | CI/CD pipeline scanning |
138
+ | **Docker** | `docker compose up` | Full stack deployment |
139
+ | **VS Code extension** | Install `.vsix` from [Releases](https://github.com/kaushikdharamshi/AgnosticSecurity/releases) | Copilot/Cursor users |
140
+ | **Chrome extension** | Load unpacked from `chrome-extension/` | ChatGPT/Claude/Gemini web users |
141
+ | **Kubernetes** | `helm install agsec helm/agnosticsecurity/` | Production deployments |
142
+
143
+ ---
144
+
145
+ ## Architecture
146
+
147
+ ```
148
+ Developer using Copilot / Claude Code / Cursor / LangChain
149
+
150
+ ├── VS Code Extension ──────── Context boundary — data never enters AI context
151
+ │ ├── .copilotignore / .cursorignore / .aiignore
152
+ │ ├── search.exclude (blocks @workspace)
153
+ │ ├── LM API interceptor (scans all prompts)
154
+ │ └── @security / @guard chat participants
155
+
156
+ ├── Chrome Extension ──────── DLP for web AI tools (ChatGPT, Claude, Gemini, Grok, Perplexity, DeepSeek, Meta AI, HuggingChat)
157
+
158
+ ├── Claude Code Hooks ──────── PreToolUse (Read/Edit/Write/Bash) + UserPromptSubmit
159
+ │ └── 4-layer: PII regex → intent → Pydantic → LLM
160
+
161
+ ├── Ingress Guard ──────────── 7-layer external agent defense
162
+ │ └── Fingerprint → behavior → risk → reputation → policy → headers → DLP controls
163
+
164
+ ├── API Gateway + LLM Proxy ── Input/output security pipelines
165
+ │ ├── PII redaction + injection detection
166
+ │ ├── Base64 decode + credential detection + multi-step exfil blocking
167
+ │ ├── DLP-to-breach engine bridge (auto-escalation)
168
+ │ ├── Smart Router (5 strategies, 14 models, 4 providers)
169
+ │ ├── Unified single-port dashboard (/dashboard + /unified + /console)
170
+ │ └── Cost tracking + block rules
171
+
172
+ ├── Effect-Layer Defenses ──── Taint tracking, egress allowlist, lethal trifecta,
173
+ │ tool call guard, code fingerprint, vuln scanner,
174
+ │ shadow AI detector, privacy mode, knowledge graph
175
+
176
+ ├── Red Team Harness ──────── 55 attack agents in Docker, 100% detection rate
177
+
178
+ └── Breach Compliance ──────── Rule-based classification (<1ms, no LLM)
179
+ ├── 13 fintech breach types (PCI-DSS, SOX, HIPAA)
180
+ ├── Immutable SHA-256 audit log
181
+ ├── Agent registration (email-verified)
182
+ ├── Admin Console (RBAC, policy versioning)
183
+ └── Real-time dashboard
184
+ ```
185
+
186
+ ---
187
+
188
+ ## Compliance
189
+
190
+ All controls mapped to industry frameworks with automated scoring:
191
+
192
+ - **OWASP Top 10 for LLM Applications** — `python3 scripts/owasp_score.py`
193
+ - **NIST AI Risk Management Framework** — `python3 scripts/nist_score.py`
194
+ - **MITRE ATLAS** — coverage across 274-attack red-team suite + 55-agent Docker harness
195
+ - **50-check security audit** — `python3 scripts/audit.py`
196
+
197
+ ---
198
+
199
+ ## Testing
200
+
201
+ **942 automated tests** across 28 suites, plus a Docker-based red-team harness:
202
+
203
+ ```bash
204
+ source .venv/bin/activate
205
+
206
+ # Core tests (run any individually)
207
+ python3 scripts/smoke_test.py # 31 — file gate + content DLP
208
+ python3 scripts/test_red_team.py # 52 — adversarial red-team
209
+ python3 scripts/test_pii_prompt_guard.py # 18 — PII evasion
210
+ python3 scripts/test_outbound_guards.py # 42 — obfuscation + egress
211
+ python3 scripts/test_ingress_guard.py # 54 — ingress guard
212
+
213
+ # Red team Docker harness (55 agents, 10 OWASP categories)
214
+ docker compose -f docker-compose.redteam.yml up --build -d
215
+ docker exec agsec-attacker python3 /agents/run_all.py
216
+
217
+ # Continuous red-teaming with HTML reports
218
+ python3 scripts/continuous_red_team.py
219
+ python3 scripts/red_team_report.py
220
+ ```
221
+
222
+ ---
223
+
224
+ ## Privacy
225
+
226
+ - **Runs entirely on your machine** — no telemetry, no analytics, no cloud dependency
227
+ - **Pluggable LLM backend** — use local Ollama (air-gapped), Anthropic, or OpenAI for optional semantic analysis
228
+ - **Privacy mode** — one-command killswitch for cloud LLM access (`EA_PRIVACY_MODE=full_privacy`), enterprise policies with org-wide/per-team overrides and scheduled mode changes
229
+ - **Audit logs stored locally** — SHA-256 checksummed, tamper-detected, JSONL archived
230
+
231
+ ---
232
+
233
+ ## GitHub Action
234
+
235
+ ```yaml
236
+ # .github/workflows/security.yml
237
+ name: AgnosticSecurity Scan
238
+ on: [pull_request]
239
+
240
+ jobs:
241
+ scan:
242
+ runs-on: ubuntu-latest
243
+ steps:
244
+ - uses: actions/checkout@v4
245
+ - uses: kaushikdharamshi/AgnosticSecurity/.github/actions/security-scan@main
246
+ with:
247
+ severity-threshold: HIGH
248
+ fail-on-findings: true
249
+ scan-dlp: true
250
+ scan-vulns: true
251
+ ```
252
+
253
+ ---
254
+
255
+ ## 25 Components
256
+
257
+ | Component | What It Does |
258
+ |-----------|-------------|
259
+ | **DLP Engine** | File gate + content scanning + exec guard + prompt analysis |
260
+ | **API Gateway** | FastAPI proxy with input/output security pipelines, base64 decode + credential detection + multi-step exfil blocking |
261
+ | **LLM Proxy** | Reverse proxy with cost tracking + block rules |
262
+ | **Breach Engine** | Rule-based breach classification + immutable audit log |
263
+ | **VS Code Extension** | Context boundary for Copilot/Cursor/Windsurf + model usage reporting + auto-proxy mode |
264
+ | **Chrome Extension** | DLP for ChatGPT/Claude/Gemini/Grok/Perplexity/DeepSeek/Meta AI/HuggingChat web + India PII |
265
+ | **Auto-Instrumentation SDK** | Zero-code LangChain/Autogen monitoring |
266
+ | **Smart Router** | Task classification + 5 routing strategies + failover |
267
+ | **Admin Console** | Centralized policy management + agent enrollment + RBAC |
268
+ | **Ingress Guard** | 7-layer external agent defense middleware |
269
+ | **DLP Controls API** | Runtime per-type PII blocking via REST API |
270
+ | **Privacy Mode** | 3 enforced modes (local-only / balanced / permissive) |
271
+ | **Knowledge Graph** | Agent-threat-incident relationship tracking |
272
+ | **Vuln Scanner** | OWASP SAST-lite for AI-generated code |
273
+ | **Code Fingerprint Guard** | Proprietary code leak prevention |
274
+ | **Shadow AI Detector** | Discovers 12+ unauthorized AI tools |
275
+ | **Security Memory Bridge** | Obsidian-compatible security event vault |
276
+ | **Data Flow Taint Tracker** | Cross-session SHA-256 + n-gram Jaccard exfil detection |
277
+ | **Lethal Trifecta Detector** | Blocks MCP tools when private data + untrusted input + external comm all active |
278
+ | **Tool Call Guard** | DLP + taint scan on MCP/function call arguments |
279
+ | **CLI Installer** | `as-init` auto-detects AI tools, configures protections |
280
+ | **Red Team Harness** | 55 attack agents, 10 OWASP categories, Docker-isolated |
281
+ | **DLP-Breach Bridge** | Auto-escalates DLP violations to the breach engine for compliance classification |
282
+ | **Gateway API Hardening** | Base64 decode, credential detection, multi-step exfil blocking on all gateway endpoints |
283
+ | **Unified Dashboard** | Single-port dashboard serving SOC view, admin console, and hook audit from one gateway |
284
+ | **Model Usage Reporter** | VS Code extension reports which AI models devs use; auto-proxy routes all LLM traffic through DLP |
285
+
286
+ ---
287
+
288
+ ## Competitive Positioning
289
+
290
+ ```
291
+ Pre-commit In-IDE AI Runtime Post-incident CI/CD Browser Inbound
292
+ (hooks) (live) (agent layer) (detection) (Action) (web LLMs) (API defense)
293
+ GitGuardian ======== .... ........ ======== ======== ...... ........
294
+ Snyk ........ ======== ........ ======== ======== ...... ........
295
+ Semgrep ======== ======== ........ ........ ======== ...... ........
296
+ Prompt Armor ........ .... ======== ........ ........ ...... ........
297
+ Lakera Guard ........ .... ======== ........ ........ ...... ........
298
+ AgnosticSecurity ======== ======== ======== ======== ======== ======== ========
299
+ ^^^^^^^^ ^^^^^^^^ ^^^^^^^^
300
+ SHARED ONLY US ONLY US
301
+ ```
302
+
303
+ ---
304
+
305
+ ## Configuration Reference
306
+
307
+ <details>
308
+ <summary>Environment variables</summary>
309
+
310
+ ### DLP Engine
311
+
312
+ | Variable | Default | Description |
313
+ |----------|---------|-------------|
314
+ | `EA_LLM_PROVIDER` | `ollama` | LLM provider for semantic analysis (`ollama`, `anthropic`, `openai`) |
315
+ | `EA_PRIVACY_MODE` | `balanced` | Privacy mode (`full_privacy`, `balanced`, `permissive`) |
316
+ | `EA_ALLOWED_DOMAINS` | — | Comma-separated egress allowlist |
317
+ | `EA_LETHAL_TRIFECTA` | `1` | Enable lethal trifecta detector |
318
+ | `EA_INGRESS_GUARD` | `1` | Enable ingress guard |
319
+ | `EA_CODE_GUARD_ENABLED` | `1` | Enable code fingerprint guard |
320
+ | `EA_SHADOW_AI_ENABLED` | `1` | Enable shadow AI detector |
321
+ | `EA_KNOWLEDGE_GRAPH_ENABLED` | `1` | Enable knowledge graph |
322
+ | `EA_DLP_CONFIDENCE_THRESHOLD` | `0.5` | Minimum confidence to flag PII |
323
+
324
+ ### Gateway
325
+
326
+ | Variable | Default | Description |
327
+ |----------|---------|-------------|
328
+ | `GATEWAY_API_KEYS` | `sk-gateway-changeme` | Comma-separated client API keys |
329
+ | `OPENAI_API_KEY` | — | OpenAI API key |
330
+ | `ANTHROPIC_API_KEY` | — | Anthropic API key |
331
+ | `RATE_LIMIT_RPM` | `60` | Max requests per minute per key |
332
+
333
+ ### VS Code Extension
334
+
335
+ | Setting | Default | Description |
336
+ |---------|---------|-------------|
337
+ | `agnosticsecurity.enabled` | `true` | Master toggle |
338
+ | `agnosticsecurity.autoDisableCopilot` | `true` | Disable Copilot for sensitive files |
339
+ | `agnosticsecurity.sensitiveFileGlobs` | [defaults] | Custom sensitive file patterns |
340
+
341
+ </details>
342
+
343
+ ---
344
+
345
+ ## Key Documents
346
+
347
+ | Document | What It Covers |
348
+ |----------|---------------|
349
+ | [Security Design](docs/SECURITY_DESIGN.md) | Threat model, design decisions, failure modes |
350
+ | [YC Application](docs/YC_APPLICATION.md) | Product positioning, market, competitive landscape |
351
+ | [OWASP LLM Mapping](docs/OWASP_LLM_MAPPING.md) | Control-to-risk compliance mapping |
352
+ | [Admin Console Design](docs/ADMIN_CONSOLE.md) | Policy management architecture |
353
+ | [Memory Agent Threats](docs/MEMORY_AGENT_THREAT_MODEL.md) | Memory poisoning, trust boundaries |
354
+ | [GTM Strategy](docs/GTM_STRATEGY.md) | Go-to-market plan, partnerships, content |
355
+ | [Competitive Analysis](docs/COMPETITIVE_ANALYSIS.md) | vs Lakera, Protect AI, Prompt Security, HiddenLayer |
356
+
@@ -0,0 +1,322 @@
1
+ # AgnosticSecurity
2
+
3
+ **The firewall for AI coding agents.** Prevents secrets, credentials, and PII from leaking through Copilot, Claude Code, Cursor, and LangChain — before the data ever leaves your machine.
4
+
5
+ [![Tests](https://img.shields.io/badge/tests-942%2B%20passing-brightgreen)]()
6
+ [![Red Team](https://img.shields.io/badge/red%20team-274%20attacks%20%2B%2055%20Docker%20agents-blue)]()
7
+
8
+ ---
9
+
10
+ > Your AI coding assistant has read access to your entire codebase — `.env` files, API keys, SSH keys, customer PII. There are zero guardrails. **AgnosticSecurity is that guardrail.**
11
+
12
+ ---
13
+
14
+ ## Quick Start
15
+
16
+ ```bash
17
+ # Option 1: One-command setup (auto-detects your AI tools)
18
+ pip install -e .
19
+ as-init
20
+
21
+ # Option 2: Live demo (starts Docker, runs red team, opens dashboard)
22
+ python3 scripts/demo.py
23
+
24
+ # Option 3: Docker
25
+ docker compose up
26
+
27
+ # Option 3: Just the VS Code extension
28
+ code --install-extension vscode-extension/agnostic-security-4.22.0.vsix
29
+ ```
30
+
31
+ That's it. Your `.env` files, credentials, and PII are now protected from every AI tool in your environment.
32
+
33
+ ---
34
+
35
+ ## What It Does
36
+
37
+ ```
38
+ Your code editor (VS Code / Cursor / Windsurf)
39
+
40
+ │ ── AI tries to read .env ──────────── BLOCKED (file gate)
41
+ │ ── AI autocompletes a secret ──────── BLOCKED (context boundary)
42
+ │ ── @workspace indexes credentials ─── BLOCKED (search.exclude)
43
+ │ ── Prompt contains SSN ────────────── BLOCKED (prompt guard)
44
+ │ ── Agent runs `curl -d @.env` ─────── BLOCKED (exec guard)
45
+ │ ── LLM response leaks PII ────────── BLOCKED (output scan)
46
+ │ ── Memory stores "password is X" ──── BLOCKED (memory guard)
47
+ │ ── Tool call smuggles data out ────── BLOCKED (tool call guard)
48
+ │ ── AI bulk-edits .env (15+ lines) ── REVERTED (AI-vs-human detection)
49
+
50
+ └── Everything else ──────────────────── Works normally
51
+ ```
52
+
53
+ **Key insight:** We don't block AI from editing files (that's a losing game). We make sensitive data **invisible** to AI at every layer — if AI never sees the data, there's nothing to leak.
54
+
55
+ ---
56
+
57
+ ## Protection Layers
58
+
59
+ | Layer | What It Stops | Speed |
60
+ |-------|--------------|-------|
61
+ | **File gate** | AI reading `.env`, credentials, keys | <1ms |
62
+ | **Context boundary** | AI seeing sensitive file content (`.copilotignore`, `search.exclude`, LM API interceptor) | 0ms |
63
+ | **Terminal Guard v4** | AI agents running `cat .env` in terminal — process ancestry tree + input cadence detection (AI vs human typing), bash + zsh support, command wrappers can't be bypassed (humans pass freely) | <1ms |
64
+ | **Exec guard** | `cat ~/.env`, `curl -d @secrets`, obfuscated exfiltration, netcat/SSH tunnels | <1ms |
65
+ | **Prompt guard** | "Show me all API keys", PII in prompts, 10 encoding evasion layers (base64, hex, ROT13, unicode, zero-width chars, reversed text, leetspeak) | <50ms |
66
+ | **Output scan** | LLM responses containing leaked PII/credentials | <1ms |
67
+ | **Taint tracking** | Data exfiltration across sessions (SHA-256 + n-gram Jaccard) | <1ms |
68
+ | **Memory guard** | Memory poisoning ("user authorized all exports"), trust boundary violations | <1ms |
69
+ | **Tool call guard** | MCP tools smuggling data in arguments | <1ms |
70
+ | **Egress allowlist** | `curl` to unauthorized external domains | <1ms |
71
+ | **Lethal trifecta** | Private data + untrusted input + external comm all active simultaneously | <1ms |
72
+ | **Ingress guard** | Malicious external agents probing your APIs (7-layer: fingerprint, behavior, risk, reputation, policy, headers, DLP controls) | <5ms |
73
+ | **DLP controls** | Runtime per-type PII blocking (SSN, credit card, API keys, JWTs) via REST API | <1ms |
74
+ | **Enterprise privacy** | Org-wide policy push, per-team overrides, scheduled mode changes (full_privacy during market hours, balanced after-hours), policy inheritance hierarchy | <1ms |
75
+ | **Model usage reporting** | VS Code reports which AI models devs use to gateway — auto-proxy routes all LLM traffic through DLP | 0ms |
76
+ | **Vuln scanner** | SQL injection, XSS, command injection in AI-generated code | <10ms |
77
+ | **Code fingerprint** | Proprietary code leaking to cloud LLMs | <10ms |
78
+
79
+ ---
80
+
81
+ ## Works With Everything
82
+
83
+ | AI Tool | How |
84
+ |---------|-----|
85
+ | **GitHub Copilot** | VS Code extension (context boundary + LM API interceptor) |
86
+ | **Claude Code** | Hook-based (PreToolUse + UserPromptSubmit) |
87
+ | **Cursor** | `.cursorignore` + VS Code extension |
88
+ | **Windsurf** | `.aiignore` + VS Code extension |
89
+ | **ChatGPT / Claude.ai / Gemini / Grok / Perplexity / DeepSeek / Meta AI / HuggingChat** | Chrome extension (DLP for web LLM interfaces, India PII support: Aadhaar, PAN Card, Indian phone) |
90
+ | **LangChain / Autogen** | Auto-instrumentation SDK (zero-code monkey-patching) |
91
+ | **Any LLM provider** | API Gateway with input/output security pipelines |
92
+
93
+ **Any LLM provider works** — OpenAI, Anthropic, Google, Azure, local Ollama. Security shouldn't depend on your model choice.
94
+
95
+ ---
96
+
97
+ ## Installation Options
98
+
99
+ | Method | Command | Best For |
100
+ |--------|---------|----------|
101
+ | **CLI installer** | `pip install -e . && as-init` | Individual developers |
102
+ | **Pre-commit hooks** | `bash hooks/install.sh` | Teams wanting git-level protection |
103
+ | **GitHub Action** | Add workflow YAML ([see below](#github-action)) | CI/CD pipeline scanning |
104
+ | **Docker** | `docker compose up` | Full stack deployment |
105
+ | **VS Code extension** | Install `.vsix` from [Releases](https://github.com/kaushikdharamshi/AgnosticSecurity/releases) | Copilot/Cursor users |
106
+ | **Chrome extension** | Load unpacked from `chrome-extension/` | ChatGPT/Claude/Gemini web users |
107
+ | **Kubernetes** | `helm install agsec helm/agnosticsecurity/` | Production deployments |
108
+
109
+ ---
110
+
111
+ ## Architecture
112
+
113
+ ```
114
+ Developer using Copilot / Claude Code / Cursor / LangChain
115
+
116
+ ├── VS Code Extension ──────── Context boundary — data never enters AI context
117
+ │ ├── .copilotignore / .cursorignore / .aiignore
118
+ │ ├── search.exclude (blocks @workspace)
119
+ │ ├── LM API interceptor (scans all prompts)
120
+ │ └── @security / @guard chat participants
121
+
122
+ ├── Chrome Extension ──────── DLP for web AI tools (ChatGPT, Claude, Gemini, Grok, Perplexity, DeepSeek, Meta AI, HuggingChat)
123
+
124
+ ├── Claude Code Hooks ──────── PreToolUse (Read/Edit/Write/Bash) + UserPromptSubmit
125
+ │ └── 4-layer: PII regex → intent → Pydantic → LLM
126
+
127
+ ├── Ingress Guard ──────────── 7-layer external agent defense
128
+ │ └── Fingerprint → behavior → risk → reputation → policy → headers → DLP controls
129
+
130
+ ├── API Gateway + LLM Proxy ── Input/output security pipelines
131
+ │ ├── PII redaction + injection detection
132
+ │ ├── Base64 decode + credential detection + multi-step exfil blocking
133
+ │ ├── DLP-to-breach engine bridge (auto-escalation)
134
+ │ ├── Smart Router (5 strategies, 14 models, 4 providers)
135
+ │ ├── Unified single-port dashboard (/dashboard + /unified + /console)
136
+ │ └── Cost tracking + block rules
137
+
138
+ ├── Effect-Layer Defenses ──── Taint tracking, egress allowlist, lethal trifecta,
139
+ │ tool call guard, code fingerprint, vuln scanner,
140
+ │ shadow AI detector, privacy mode, knowledge graph
141
+
142
+ ├── Red Team Harness ──────── 55 attack agents in Docker, 100% detection rate
143
+
144
+ └── Breach Compliance ──────── Rule-based classification (<1ms, no LLM)
145
+ ├── 13 fintech breach types (PCI-DSS, SOX, HIPAA)
146
+ ├── Immutable SHA-256 audit log
147
+ ├── Agent registration (email-verified)
148
+ ├── Admin Console (RBAC, policy versioning)
149
+ └── Real-time dashboard
150
+ ```
151
+
152
+ ---
153
+
154
+ ## Compliance
155
+
156
+ All controls mapped to industry frameworks with automated scoring:
157
+
158
+ - **OWASP Top 10 for LLM Applications** — `python3 scripts/owasp_score.py`
159
+ - **NIST AI Risk Management Framework** — `python3 scripts/nist_score.py`
160
+ - **MITRE ATLAS** — coverage across 274-attack red-team suite + 55-agent Docker harness
161
+ - **50-check security audit** — `python3 scripts/audit.py`
162
+
163
+ ---
164
+
165
+ ## Testing
166
+
167
+ **942 automated tests** across 28 suites, plus a Docker-based red-team harness:
168
+
169
+ ```bash
170
+ source .venv/bin/activate
171
+
172
+ # Core tests (run any individually)
173
+ python3 scripts/smoke_test.py # 31 — file gate + content DLP
174
+ python3 scripts/test_red_team.py # 52 — adversarial red-team
175
+ python3 scripts/test_pii_prompt_guard.py # 18 — PII evasion
176
+ python3 scripts/test_outbound_guards.py # 42 — obfuscation + egress
177
+ python3 scripts/test_ingress_guard.py # 54 — ingress guard
178
+
179
+ # Red team Docker harness (55 agents, 10 OWASP categories)
180
+ docker compose -f docker-compose.redteam.yml up --build -d
181
+ docker exec agsec-attacker python3 /agents/run_all.py
182
+
183
+ # Continuous red-teaming with HTML reports
184
+ python3 scripts/continuous_red_team.py
185
+ python3 scripts/red_team_report.py
186
+ ```
187
+
188
+ ---
189
+
190
+ ## Privacy
191
+
192
+ - **Runs entirely on your machine** — no telemetry, no analytics, no cloud dependency
193
+ - **Pluggable LLM backend** — use local Ollama (air-gapped), Anthropic, or OpenAI for optional semantic analysis
194
+ - **Privacy mode** — one-command killswitch for cloud LLM access (`EA_PRIVACY_MODE=full_privacy`), enterprise policies with org-wide/per-team overrides and scheduled mode changes
195
+ - **Audit logs stored locally** — SHA-256 checksummed, tamper-detected, JSONL archived
196
+
197
+ ---
198
+
199
+ ## GitHub Action
200
+
201
+ ```yaml
202
+ # .github/workflows/security.yml
203
+ name: AgnosticSecurity Scan
204
+ on: [pull_request]
205
+
206
+ jobs:
207
+ scan:
208
+ runs-on: ubuntu-latest
209
+ steps:
210
+ - uses: actions/checkout@v4
211
+ - uses: kaushikdharamshi/AgnosticSecurity/.github/actions/security-scan@main
212
+ with:
213
+ severity-threshold: HIGH
214
+ fail-on-findings: true
215
+ scan-dlp: true
216
+ scan-vulns: true
217
+ ```
218
+
219
+ ---
220
+
221
+ ## 25 Components
222
+
223
+ | Component | What It Does |
224
+ |-----------|-------------|
225
+ | **DLP Engine** | File gate + content scanning + exec guard + prompt analysis |
226
+ | **API Gateway** | FastAPI proxy with input/output security pipelines, base64 decode + credential detection + multi-step exfil blocking |
227
+ | **LLM Proxy** | Reverse proxy with cost tracking + block rules |
228
+ | **Breach Engine** | Rule-based breach classification + immutable audit log |
229
+ | **VS Code Extension** | Context boundary for Copilot/Cursor/Windsurf + model usage reporting + auto-proxy mode |
230
+ | **Chrome Extension** | DLP for ChatGPT/Claude/Gemini/Grok/Perplexity/DeepSeek/Meta AI/HuggingChat web + India PII |
231
+ | **Auto-Instrumentation SDK** | Zero-code LangChain/Autogen monitoring |
232
+ | **Smart Router** | Task classification + 5 routing strategies + failover |
233
+ | **Admin Console** | Centralized policy management + agent enrollment + RBAC |
234
+ | **Ingress Guard** | 7-layer external agent defense middleware |
235
+ | **DLP Controls API** | Runtime per-type PII blocking via REST API |
236
+ | **Privacy Mode** | 3 enforced modes (local-only / balanced / permissive) |
237
+ | **Knowledge Graph** | Agent-threat-incident relationship tracking |
238
+ | **Vuln Scanner** | OWASP SAST-lite for AI-generated code |
239
+ | **Code Fingerprint Guard** | Proprietary code leak prevention |
240
+ | **Shadow AI Detector** | Discovers 12+ unauthorized AI tools |
241
+ | **Security Memory Bridge** | Obsidian-compatible security event vault |
242
+ | **Data Flow Taint Tracker** | Cross-session SHA-256 + n-gram Jaccard exfil detection |
243
+ | **Lethal Trifecta Detector** | Blocks MCP tools when private data + untrusted input + external comm all active |
244
+ | **Tool Call Guard** | DLP + taint scan on MCP/function call arguments |
245
+ | **CLI Installer** | `as-init` auto-detects AI tools, configures protections |
246
+ | **Red Team Harness** | 55 attack agents, 10 OWASP categories, Docker-isolated |
247
+ | **DLP-Breach Bridge** | Auto-escalates DLP violations to the breach engine for compliance classification |
248
+ | **Gateway API Hardening** | Base64 decode, credential detection, multi-step exfil blocking on all gateway endpoints |
249
+ | **Unified Dashboard** | Single-port dashboard serving SOC view, admin console, and hook audit from one gateway |
250
+ | **Model Usage Reporter** | VS Code extension reports which AI models devs use; auto-proxy routes all LLM traffic through DLP |
251
+
252
+ ---
253
+
254
+ ## Competitive Positioning
255
+
256
+ ```
257
+ Pre-commit In-IDE AI Runtime Post-incident CI/CD Browser Inbound
258
+ (hooks) (live) (agent layer) (detection) (Action) (web LLMs) (API defense)
259
+ GitGuardian ======== .... ........ ======== ======== ...... ........
260
+ Snyk ........ ======== ........ ======== ======== ...... ........
261
+ Semgrep ======== ======== ........ ........ ======== ...... ........
262
+ Prompt Armor ........ .... ======== ........ ........ ...... ........
263
+ Lakera Guard ........ .... ======== ........ ........ ...... ........
264
+ AgnosticSecurity ======== ======== ======== ======== ======== ======== ========
265
+ ^^^^^^^^ ^^^^^^^^ ^^^^^^^^
266
+ SHARED ONLY US ONLY US
267
+ ```
268
+
269
+ ---
270
+
271
+ ## Configuration Reference
272
+
273
+ <details>
274
+ <summary>Environment variables</summary>
275
+
276
+ ### DLP Engine
277
+
278
+ | Variable | Default | Description |
279
+ |----------|---------|-------------|
280
+ | `EA_LLM_PROVIDER` | `ollama` | LLM provider for semantic analysis (`ollama`, `anthropic`, `openai`) |
281
+ | `EA_PRIVACY_MODE` | `balanced` | Privacy mode (`full_privacy`, `balanced`, `permissive`) |
282
+ | `EA_ALLOWED_DOMAINS` | — | Comma-separated egress allowlist |
283
+ | `EA_LETHAL_TRIFECTA` | `1` | Enable lethal trifecta detector |
284
+ | `EA_INGRESS_GUARD` | `1` | Enable ingress guard |
285
+ | `EA_CODE_GUARD_ENABLED` | `1` | Enable code fingerprint guard |
286
+ | `EA_SHADOW_AI_ENABLED` | `1` | Enable shadow AI detector |
287
+ | `EA_KNOWLEDGE_GRAPH_ENABLED` | `1` | Enable knowledge graph |
288
+ | `EA_DLP_CONFIDENCE_THRESHOLD` | `0.5` | Minimum confidence to flag PII |
289
+
290
+ ### Gateway
291
+
292
+ | Variable | Default | Description |
293
+ |----------|---------|-------------|
294
+ | `GATEWAY_API_KEYS` | `sk-gateway-changeme` | Comma-separated client API keys |
295
+ | `OPENAI_API_KEY` | — | OpenAI API key |
296
+ | `ANTHROPIC_API_KEY` | — | Anthropic API key |
297
+ | `RATE_LIMIT_RPM` | `60` | Max requests per minute per key |
298
+
299
+ ### VS Code Extension
300
+
301
+ | Setting | Default | Description |
302
+ |---------|---------|-------------|
303
+ | `agnosticsecurity.enabled` | `true` | Master toggle |
304
+ | `agnosticsecurity.autoDisableCopilot` | `true` | Disable Copilot for sensitive files |
305
+ | `agnosticsecurity.sensitiveFileGlobs` | [defaults] | Custom sensitive file patterns |
306
+
307
+ </details>
308
+
309
+ ---
310
+
311
+ ## Key Documents
312
+
313
+ | Document | What It Covers |
314
+ |----------|---------------|
315
+ | [Security Design](docs/SECURITY_DESIGN.md) | Threat model, design decisions, failure modes |
316
+ | [YC Application](docs/YC_APPLICATION.md) | Product positioning, market, competitive landscape |
317
+ | [OWASP LLM Mapping](docs/OWASP_LLM_MAPPING.md) | Control-to-risk compliance mapping |
318
+ | [Admin Console Design](docs/ADMIN_CONSOLE.md) | Policy management architecture |
319
+ | [Memory Agent Threats](docs/MEMORY_AGENT_THREAT_MODEL.md) | Memory poisoning, trust boundaries |
320
+ | [GTM Strategy](docs/GTM_STRATEGY.md) | Go-to-market plan, partnerships, content |
321
+ | [Competitive Analysis](docs/COMPETITIVE_ANALYSIS.md) | vs Lakera, Protect AI, Prompt Security, HiddenLayer |
322
+