torusguard 2.0.0-alpha → 2.1.1
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.
- package/.torusguard/.manifest.json +94 -30
- package/.torusguard/core/__init__.py +146 -0
- package/.torusguard/core/agent_roles.py +104 -0
- package/.torusguard/core/ast_walker.py +283 -0
- package/.torusguard/core/authorization.py +218 -0
- package/.torusguard/core/browser_verifier.py +128 -0
- package/.torusguard/core/bundle.py +141 -0
- package/.torusguard/core/call_graph.py +184 -0
- package/.torusguard/core/clustering.py +275 -0
- package/.torusguard/core/confidence.py +120 -0
- package/.torusguard/core/cross_file_taint.py +101 -0
- package/.torusguard/core/exploit_checker.py +317 -0
- package/.torusguard/core/formatter.py +351 -0
- package/.torusguard/core/governance.py +210 -0
- package/.torusguard/core/identity.py +104 -0
- package/.torusguard/core/import_resolver.py +91 -0
- package/.torusguard/core/incremental.py +102 -0
- package/.torusguard/core/lifecycle.py +137 -0
- package/.torusguard/core/models.py +425 -0
- package/.torusguard/core/parallel.py +56 -0
- package/.torusguard/core/parser.py +202 -0
- package/.torusguard/core/rechecker.py +107 -0
- package/.torusguard/core/replay_trace.py +178 -0
- package/.torusguard/core/rules_registry.py +131 -0
- package/.torusguard/core/run_folder.py +60 -0
- package/.torusguard/core/run_manager.py +163 -0
- package/.torusguard/core/runtime_evidence.py +175 -0
- package/.torusguard/core/runtime_validator.py +246 -0
- package/.torusguard/core/safety_gate.py +139 -0
- package/.torusguard/core/sarif.py +189 -0
- package/.torusguard/core/stack_profiler.py +184 -0
- package/.torusguard/core/symbol_table.py +91 -0
- package/.torusguard/core/taint.py +133 -0
- package/.torusguard/core/taint_graph.py +235 -0
- package/.torusguard/core/taint_rules.py +268 -0
- package/.torusguard/core/v070_reporter.py +102 -0
- package/.torusguard/core/v070_workflow.py +339 -0
- package/.torusguard/core/v6_reporter.py +180 -0
- package/.torusguard/core/v6_workflow.py +221 -0
- package/.torusguard/core/watcher.py +58 -0
- package/.torusguard/rules/TG-INPUT-007-unvalidated-redirect.md +53 -0
- package/.torusguard/rules/TG-INPUT-008-insecure-deserialization.md +52 -0
- package/.torusguard/rules/container/TG-CONT-001-root-user-execution.md +50 -0
- package/.torusguard/rules/container/TG-CONT-002-docker-socket-mount.md +47 -0
- package/.torusguard/rules/container/TG-CONT-003-privileged-container-mode.md +53 -0
- package/.torusguard/rules/container/TG-CONT-004-build-arg-secret-exposure.md +43 -0
- package/.torusguard/rules/git/TG-GIT-001-historical-secret-in-git-commit.md +44 -0
- package/.torusguard/rules/git/TG-GIT-002-plaintext-credentials-in-git-config.md +41 -0
- package/.torusguard/rules/git/TG-GIT-003-sensitive-tracked-file-gitignore-breach.md +40 -0
- package/.torusguard/rules/rag/TG-RAG-001-untrusted-rag-context-injection.md +72 -0
- package/.torusguard/rules/rag/TG-RAG-002-autonomous-llm-tool-unsandboxed-call.md +51 -0
- package/.torusguard/rules/rag/TG-RAG-003-unpartitioned-vector-tenant-lookup.md +51 -0
- package/.torusguard/rules/redos/TG-REDOS-001-catastrophic-exponential-backtracking.md +46 -0
- package/.torusguard/rules/redos/TG-REDOS-002-unbounded-nested-quantifier.md +43 -0
- package/.torusguard/rules_catalog.json +96 -0
- package/.torusguard/scripts/__pycache__/audit_runner.cpython-314.pyc +0 -0
- package/.torusguard/scripts/__pycache__/finding_scorer.cpython-314.pyc +0 -0
- package/.torusguard/scripts/__pycache__/manifest_builder.cpython-314.pyc +0 -0
- package/.torusguard/scripts/__pycache__/rules_sync.cpython-314.pyc +0 -0
- package/.torusguard/scripts/audit_runner.py +108 -10
- package/.torusguard/scripts/finding_scorer.py +43 -13
- package/.torusguard/scripts/manifest_builder.py +1 -1
- package/.torusguard/scripts/skill_profiler.py +26 -0
- package/.torusguard/skills/torusguard/SKILL.md +74 -25
- package/.torusguard/skills/torusguard/bootstrap.py +57 -24
- package/.torusguard/skills/torusguard-ai-guard/SKILL.md +95 -0
- package/.torusguard/skills/torusguard-apply/SKILL.md +60 -34
- package/.torusguard/skills/torusguard-audit/SKILL.md +131 -57
- package/.torusguard/skills/torusguard-authorize/SKILL.md +48 -6
- package/.torusguard/skills/torusguard-container/SKILL.md +94 -0
- package/.torusguard/skills/torusguard-exploit-check/SKILL.md +50 -6
- package/.torusguard/skills/torusguard-full/SKILL.md +62 -19
- package/.torusguard/skills/torusguard-git-mine/SKILL.md +92 -0
- package/.torusguard/skills/torusguard-harden/SKILL.md +81 -50
- package/.torusguard/skills/torusguard-init/SKILL.md +61 -14
- package/.torusguard/skills/torusguard-ocr-scan/SKILL.md +94 -0
- package/.torusguard/skills/torusguard-recheck/SKILL.md +71 -18
- package/.torusguard/skills/torusguard-redos/SKILL.md +91 -0
- package/.torusguard/skills/torusguard-report/SKILL.md +50 -9
- package/.torusguard/skills/torusguard-status/SKILL.md +63 -10
- package/.torusguard/skills/torusguard-verify/SKILL.md +52 -10
- package/.torusguard/skills/torusguard-web-validate/SKILL.md +53 -8
- package/.torusguard/workflows/ai-guard.md +31 -0
- package/.torusguard/workflows/apply.md +32 -55
- package/.torusguard/workflows/audit.md +35 -49
- package/.torusguard/workflows/authorize.md +27 -50
- package/.torusguard/workflows/container.md +29 -0
- package/.torusguard/workflows/exploit-check.md +28 -50
- package/.torusguard/workflows/git-mine.md +25 -0
- package/.torusguard/workflows/harden.md +29 -48
- package/.torusguard/workflows/init.md +27 -50
- package/.torusguard/workflows/memory.md +18 -23
- package/.torusguard/workflows/ocr-scan.md +25 -0
- package/.torusguard/workflows/recheck.md +28 -46
- package/.torusguard/workflows/redos.md +27 -0
- package/.torusguard/workflows/report.md +33 -52
- package/.torusguard/workflows/status.md +31 -52
- package/.torusguard/workflows/verify.md +29 -49
- package/.torusguard/workflows/web-validate.md +22 -45
- package/README.md +96 -60
- package/package.json +7 -2
- package/skills/torusguard/SKILL.md +75 -24
- package/skills/torusguard/__pycache__/bootstrap.cpython-314.pyc +0 -0
- package/skills/torusguard/bootstrap.py +60 -71
- package/skills/torusguard/payload/.manifest.json +94 -31
- package/skills/torusguard/payload/core/__init__.py +146 -0
- package/skills/torusguard/payload/core/agent_roles.py +104 -0
- package/skills/torusguard/payload/core/ast_walker.py +283 -0
- package/skills/torusguard/payload/core/authorization.py +218 -0
- package/skills/torusguard/payload/core/browser_verifier.py +128 -0
- package/skills/torusguard/payload/core/bundle.py +141 -0
- package/skills/torusguard/payload/core/call_graph.py +184 -0
- package/skills/torusguard/payload/core/clustering.py +275 -0
- package/skills/torusguard/payload/core/confidence.py +120 -0
- package/skills/torusguard/payload/core/cross_file_taint.py +101 -0
- package/skills/torusguard/payload/core/exploit_checker.py +317 -0
- package/skills/torusguard/payload/core/formatter.py +351 -0
- package/skills/torusguard/payload/core/governance.py +210 -0
- package/skills/torusguard/payload/core/identity.py +104 -0
- package/skills/torusguard/payload/core/import_resolver.py +91 -0
- package/skills/torusguard/payload/core/incremental.py +102 -0
- package/skills/torusguard/payload/core/lifecycle.py +137 -0
- package/skills/torusguard/payload/core/models.py +425 -0
- package/skills/torusguard/payload/core/parallel.py +56 -0
- package/skills/torusguard/payload/core/parser.py +202 -0
- package/skills/torusguard/payload/core/rechecker.py +107 -0
- package/skills/torusguard/payload/core/replay_trace.py +178 -0
- package/skills/torusguard/payload/core/rules_registry.py +131 -0
- package/skills/torusguard/payload/core/run_folder.py +60 -0
- package/skills/torusguard/payload/core/run_manager.py +163 -0
- package/skills/torusguard/payload/core/runtime_evidence.py +175 -0
- package/skills/torusguard/payload/core/runtime_validator.py +246 -0
- package/skills/torusguard/payload/core/safety_gate.py +139 -0
- package/skills/torusguard/payload/core/sarif.py +189 -0
- package/skills/torusguard/payload/core/stack_profiler.py +184 -0
- package/skills/torusguard/payload/core/symbol_table.py +91 -0
- package/skills/torusguard/payload/core/taint.py +133 -0
- package/skills/torusguard/payload/core/taint_graph.py +235 -0
- package/skills/torusguard/payload/core/taint_rules.py +268 -0
- package/skills/torusguard/payload/core/v070_reporter.py +102 -0
- package/skills/torusguard/payload/core/v070_workflow.py +339 -0
- package/skills/torusguard/payload/core/v6_reporter.py +180 -0
- package/skills/torusguard/payload/core/v6_workflow.py +221 -0
- package/skills/torusguard/payload/core/watcher.py +58 -0
- package/skills/torusguard/payload/rules/TG-INPUT-007-unvalidated-redirect.md +53 -0
- package/skills/torusguard/payload/rules/TG-INPUT-008-insecure-deserialization.md +52 -0
- package/skills/torusguard/payload/rules/container/TG-CONT-001-root-user-execution.md +50 -0
- package/skills/torusguard/payload/rules/container/TG-CONT-002-docker-socket-mount.md +47 -0
- package/skills/torusguard/payload/rules/container/TG-CONT-003-privileged-container-mode.md +53 -0
- package/skills/torusguard/payload/rules/container/TG-CONT-004-build-arg-secret-exposure.md +43 -0
- package/skills/torusguard/payload/rules/git/TG-GIT-001-historical-secret-in-git-commit.md +44 -0
- package/skills/torusguard/payload/rules/git/TG-GIT-002-plaintext-credentials-in-git-config.md +41 -0
- package/skills/torusguard/payload/rules/git/TG-GIT-003-sensitive-tracked-file-gitignore-breach.md +40 -0
- package/skills/torusguard/payload/rules/rag/TG-RAG-001-untrusted-rag-context-injection.md +72 -0
- package/skills/torusguard/payload/rules/rag/TG-RAG-002-autonomous-llm-tool-unsandboxed-call.md +51 -0
- package/skills/torusguard/payload/rules/rag/TG-RAG-003-unpartitioned-vector-tenant-lookup.md +51 -0
- package/skills/torusguard/payload/rules/redos/TG-REDOS-001-catastrophic-exponential-backtracking.md +46 -0
- package/skills/torusguard/payload/rules/redos/TG-REDOS-002-unbounded-nested-quantifier.md +43 -0
- package/skills/torusguard/payload/rules_catalog.json +338 -518
- package/skills/torusguard/payload/scripts/__pycache__/term_ui.cpython-314.pyc +0 -0
- package/skills/torusguard/payload/scripts/audit_runner.py +108 -10
- package/skills/torusguard/payload/scripts/finding_scorer.py +43 -13
- package/skills/torusguard/payload/scripts/manifest_builder.py +1 -1
- package/skills/torusguard/payload/skills/torusguard/SKILL.md +74 -25
- package/skills/torusguard/payload/skills/torusguard/bootstrap.py +57 -24
- package/skills/torusguard/payload/skills/torusguard/references/csharp-security.md +41 -41
- package/skills/torusguard/payload/skills/torusguard/references/go-security.md +41 -41
- package/skills/torusguard/payload/skills/torusguard/references/java-security.md +40 -40
- package/skills/torusguard/payload/skills/torusguard/references/polyglot-security-matrix.md +25 -25
- package/skills/torusguard/payload/skills/torusguard/references/rust-security.md +40 -40
- package/skills/torusguard/payload/skills/torusguard-ai-guard/SKILL.md +95 -0
- package/skills/torusguard/payload/skills/torusguard-apply/SKILL.md +60 -34
- package/skills/torusguard/payload/skills/torusguard-audit/SKILL.md +131 -57
- package/skills/torusguard/payload/skills/torusguard-authorize/SKILL.md +48 -6
- package/skills/torusguard/payload/skills/torusguard-container/SKILL.md +94 -0
- package/skills/torusguard/payload/skills/torusguard-exploit-check/SKILL.md +50 -6
- package/skills/torusguard/payload/skills/torusguard-full/SKILL.md +62 -19
- package/skills/torusguard/payload/skills/torusguard-git-mine/SKILL.md +92 -0
- package/skills/torusguard/payload/skills/torusguard-harden/SKILL.md +81 -50
- package/skills/torusguard/payload/skills/torusguard-init/SKILL.md +61 -14
- package/skills/torusguard/payload/skills/torusguard-ocr-scan/SKILL.md +94 -0
- package/skills/torusguard/payload/skills/torusguard-recheck/SKILL.md +71 -18
- package/skills/torusguard/payload/skills/torusguard-redos/SKILL.md +91 -0
- package/skills/torusguard/payload/skills/torusguard-report/SKILL.md +50 -9
- package/skills/torusguard/payload/skills/torusguard-status/SKILL.md +63 -10
- package/skills/torusguard/payload/skills/torusguard-verify/SKILL.md +52 -10
- package/skills/torusguard/payload/skills/torusguard-web-validate/SKILL.md +53 -8
- package/skills/torusguard/payload/workflows/ai-guard.md +31 -0
- package/skills/torusguard/payload/workflows/apply.md +31 -62
- package/skills/torusguard/payload/workflows/audit.md +35 -55
- package/skills/torusguard/payload/workflows/authorize.md +27 -50
- package/skills/torusguard/payload/workflows/container.md +29 -0
- package/skills/torusguard/payload/workflows/exploit-check.md +28 -50
- package/skills/torusguard/payload/workflows/git-mine.md +25 -0
- package/skills/torusguard/payload/workflows/harden.md +28 -52
- package/skills/torusguard/payload/workflows/init.md +27 -56
- package/skills/torusguard/payload/workflows/memory.md +18 -23
- package/skills/torusguard/payload/workflows/ocr-scan.md +25 -0
- package/skills/torusguard/payload/workflows/recheck.md +28 -46
- package/skills/torusguard/payload/workflows/redos.md +27 -0
- package/skills/torusguard/payload/workflows/report.md +39 -62
- package/skills/torusguard/payload/workflows/status.md +31 -55
- package/skills/torusguard/payload/workflows/torusguard-audit.md +35 -55
- package/skills/torusguard/payload/workflows/verify.md +29 -49
- package/skills/torusguard/payload/workflows/web-validate.md +22 -45
- package/skills/torusguard/references/csharp-security.md +41 -0
- package/skills/torusguard/references/go-security.md +41 -0
- package/skills/torusguard/references/java-security.md +40 -0
- package/skills/torusguard/references/polyglot-security-matrix.md +25 -0
- package/skills/torusguard/references/rust-security.md +40 -0
- package/skills/torusguard-ai-guard/SKILL.md +95 -0
- package/skills/torusguard-apply/SKILL.md +60 -34
- package/skills/torusguard-audit/SKILL.md +130 -57
- package/skills/torusguard-authorize/SKILL.md +48 -6
- package/skills/torusguard-container/SKILL.md +94 -0
- package/skills/torusguard-exploit-check/SKILL.md +50 -6
- package/skills/torusguard-full/SKILL.md +62 -19
- package/skills/torusguard-git-mine/SKILL.md +92 -0
- package/skills/torusguard-harden/SKILL.md +81 -50
- package/skills/torusguard-init/SKILL.md +61 -14
- package/skills/torusguard-ocr-scan/SKILL.md +94 -0
- package/skills/torusguard-recheck/SKILL.md +71 -18
- package/skills/torusguard-redos/SKILL.md +91 -0
- package/skills/torusguard-report/SKILL.md +50 -9
- package/skills/torusguard-status/SKILL.md +63 -10
- package/skills/torusguard-verify/SKILL.md +52 -10
- package/skills/torusguard-web-validate/SKILL.md +53 -8
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: torusguard-redos
|
|
3
|
+
description: Analyzes regular expressions across JavaScript, TypeScript, Python, and Go for catastrophic exponential backtracking and ReDoS vulnerabilities via CLI, Chat, or MCP.
|
|
4
|
+
version: 2.0.0
|
|
5
|
+
workflow: .torusguard/workflows/redos.md
|
|
6
|
+
tools: Read, Grep, Glob, Write, run_command
|
|
7
|
+
scripts-binding:
|
|
8
|
+
- internal/scanner/redos.go
|
|
9
|
+
- cmd/torusguard/main.go
|
|
10
|
+
- cmd/torusguard/mcp.go
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
# TorusGuard ReDoS Complexity Scanner
|
|
14
|
+
|
|
15
|
+
## Objective
|
|
16
|
+
Detect and remediate catastrophic exponential ($O(2^n)$) and polynomial ($O(n^k)$) backtracking regular expressions in web applications. Prevents thread starvation, CPU exhaustion, and availability denial of service attacks caused by untrusted user input matching evil regex patterns.
|
|
17
|
+
|
|
18
|
+
---
|
|
19
|
+
|
|
20
|
+
## Tri-Mode Execution
|
|
21
|
+
|
|
22
|
+
### Mode A: Automated CLI Execution
|
|
23
|
+
Run ReDoS scanning against source code files:
|
|
24
|
+
```bash
|
|
25
|
+
# Scan current workspace for catastrophic regex backtracking
|
|
26
|
+
torusguard redos
|
|
27
|
+
|
|
28
|
+
# Scan specific directory or source tree
|
|
29
|
+
torusguard redos --target ./src
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
### Mode B: In-Session AI Chat Slash Command
|
|
33
|
+
Run `/torusguard redos` in chat.
|
|
34
|
+
The agent executes the compiled Go ReDoS analyzer or MCP tool to locate dangerous nested quantifiers, overlapping alternations, and unanchored expressions.
|
|
35
|
+
|
|
36
|
+
### Mode C: Native MCP Tool Call
|
|
37
|
+
MCP-enabled coding agents (Antigravity, Cursor, Windsurf, Claude Code) call:
|
|
38
|
+
```json
|
|
39
|
+
{
|
|
40
|
+
"tool": "torusguard_redos",
|
|
41
|
+
"arguments": {
|
|
42
|
+
"target": "."
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
---
|
|
48
|
+
|
|
49
|
+
## Supported Patterns & Invariants
|
|
50
|
+
- **TG-REDOS-001 (Nested Quantifier Catastrophic Backtracking):** Detects nested repetitions such as `(a+)+`, `([a-zA-Z0-9]+)*`, or `((foo)*)+` that cause exponential evaluation time $O(2^n)$ when matching non-matching suffixes (e.g. `aaaaaaaaaaaaaaaa!`).
|
|
51
|
+
- **TG-REDOS-002 (Overlapping Alternation with Outer Repetition):** Detects patterns like `(a|ab)+` or `(user|username)*` where multiple branches match identical prefixes, causing exponential branch exploration.
|
|
52
|
+
|
|
53
|
+
---
|
|
54
|
+
|
|
55
|
+
## 🏛️ OpenCodeReview Hybrid Architecture Integration
|
|
56
|
+
- **First-Principles NFA/DFA Complexity Analysis:** Scans regex literals and constructor invocations across JS, TS, Python, and Go.
|
|
57
|
+
- **Engine-Aware Triage:** Flags backtracking engines (V8, Node.js, Python `re`, PCRE) as high risk while noting linear-time DFA engines (Go `regexp`/RE2, Rust `regex`).
|
|
58
|
+
- **Surgical Patching:** Replaces evil regexes with bounded, non-overlapping expressions or length pre-checks (≤35 additions, ≤25 deletions).
|
|
59
|
+
|
|
60
|
+
---
|
|
61
|
+
|
|
62
|
+
## 🚨 LLM Trap Table
|
|
63
|
+
|
|
64
|
+
| Pattern | What AI Does Wrong | What Is Actually Correct |
|
|
65
|
+
| :--- | :--- | :--- |
|
|
66
|
+
| **Nested Quantifiers** | Writes `([a-zA-Z0-9_]+)*` or `(https?://.+)*`, causing $O(2^n)$ catastrophic backtracking on malicious input. | Flatten expressions: `[a-zA-Z0-9_]*` or use non-overlapping delimiters like `[^/\s]+`. |
|
|
67
|
+
| **Overlapping Alternation** | Combines overlapping options inside repetition: `(a\|aa)+` or `(\w+\|\d+)+`. | Disjoint branch design: ensure alternatives cannot consume the same character prefix. |
|
|
68
|
+
| **Missing Input Length Guards** | Evaluates complex regexes against arbitrarily long input strings from untrusted HTTP bodies. | Impose input bounds (`if (input.length > 256) return false`) before regex evaluation. |
|
|
69
|
+
| **Unanchored Wildcards** | Writes `.*foo.*` without anchors, leading to quadratic scan across long documents. | Anchor patterns with `^` and `$` whenever full string matching is intended. |
|
|
70
|
+
| **Engine Indifference** | Assumes all regex engines backtrack identically; doesn't know Go RE2 is linear $O(n)$ while Node V8 is vulnerable. | Tailor remediation to target runtime: use atomic groups/lookahead in V8/Python or switch to parser combinators. |
|
|
71
|
+
|
|
72
|
+
---
|
|
73
|
+
|
|
74
|
+
## ✅ Pre-Flight Self-Audit
|
|
75
|
+
|
|
76
|
+
Before concluding a ReDoS complexity audit, verify:
|
|
77
|
+
- [ ] Were all regex literals and `RegExp` / `re.compile` declarations inspected?
|
|
78
|
+
- [ ] Are any nested quantifiers (`(x+)+`, `(x*)*`) present in the codebase?
|
|
79
|
+
- [ ] Are alternatives in grouped alternations strictly mutually exclusive?
|
|
80
|
+
- [ ] Is untrusted input strictly bounded in length before regex execution?
|
|
81
|
+
- [ ] Are remediations validated within Ponytail diff bounds?
|
|
82
|
+
|
|
83
|
+
---
|
|
84
|
+
|
|
85
|
+
## 🔁 VBC Protocol (Verify → Build → Confirm)
|
|
86
|
+
|
|
87
|
+
```
|
|
88
|
+
VERIFY: Identify regex patterns evaluated on untrusted user inputs.
|
|
89
|
+
BUILD: Execute torusguard redos or torusguard_redos to detect exponential backtracking structures.
|
|
90
|
+
CONFIRM: Refactor pattern into deterministic, non-overlapping tokens, adding length guards and testing with evil payloads.
|
|
91
|
+
```
|
|
@@ -5,11 +5,11 @@ version: 2.2.0
|
|
|
5
5
|
workflow: .torusguard/workflows/report.md
|
|
6
6
|
tools: Read, Grep, Glob, Write, run_command
|
|
7
7
|
scripts-binding:
|
|
8
|
+
- internal/scanner/scanner.go
|
|
8
9
|
- .torusguard/scripts/report_sync.py
|
|
9
10
|
- .torusguard/scripts/html_reporter.py
|
|
10
11
|
- .torusguard/scripts/sarif_exporter.py
|
|
11
12
|
- .torusguard/scripts/run_manager.py
|
|
12
|
-
- .torusguard/scripts/term_ui.py
|
|
13
13
|
---
|
|
14
14
|
|
|
15
15
|
# TorusGuard Report — Posture Reporting & SARIF / HTML Export
|
|
@@ -19,30 +19,40 @@ Aggregate findings, verification traces, and recheck results into an auditable e
|
|
|
19
19
|
|
|
20
20
|
---
|
|
21
21
|
|
|
22
|
+
## Tri-Mode Parity
|
|
23
|
+
|
|
24
|
+
| Mode | Command / Tool | Governed Behavior |
|
|
25
|
+
| :--- | :--- | :--- |
|
|
26
|
+
| **Mode A: CLI Terminal** | `torusguard report --html` | Compiles single-file HTML dashboard and OASIS SARIF v2.1.0 log. |
|
|
27
|
+
| **Mode B: AI Chat Slash** | `/torusguard report` | Generates executive posture summary and checks CI/CD readiness. |
|
|
28
|
+
| **Mode C: Native MCP Tool**| `torusguard://security_report` | Serves resource payload and posture metrics directly to agent context. |
|
|
29
|
+
|
|
30
|
+
---
|
|
31
|
+
|
|
22
32
|
## Execution Steps
|
|
23
33
|
|
|
24
34
|
### Mode A: Automated CLI Execution
|
|
25
35
|
Run the report engine from your terminal:
|
|
26
36
|
```bash
|
|
27
37
|
# Generate visual dark-mode HTML dashboard (defaults to report.html at project root)
|
|
28
|
-
|
|
38
|
+
torusguard report --html
|
|
29
39
|
|
|
30
40
|
# Export OASIS SARIF v2.1.0 for GitHub Code Scanning / CI
|
|
31
|
-
|
|
41
|
+
torusguard report --sarif
|
|
32
42
|
|
|
33
43
|
# Generate both HTML and SARIF in a single pass
|
|
34
|
-
|
|
44
|
+
torusguard report --html --sarif
|
|
35
45
|
|
|
36
46
|
# Custom HTML output location
|
|
37
|
-
|
|
47
|
+
torusguard report --html --out ./docs/security-audit.html
|
|
38
48
|
|
|
39
49
|
# Target a specific subproject / monorepo package
|
|
40
|
-
|
|
50
|
+
torusguard report --target ./apps/api --html
|
|
41
51
|
```
|
|
42
52
|
|
|
43
53
|
**Under the Hood:**
|
|
44
|
-
-
|
|
45
|
-
-
|
|
54
|
+
- Compiles self-contained, offline-ready HTML reports with dynamic filtering, posture gauge, directory attack surface heatmap, and golden recipe explorer at `report.html` (workspace root) and mirrors to `.torusguard/runs/report-latest.html`.
|
|
55
|
+
- Produces OASIS SARIF v2.1.0 logs at `.torusguard/runs/results-latest.sarif`.
|
|
46
56
|
- Finalizes `manifest.json` metrics and updates historical posture scoring.
|
|
47
57
|
- Displays standardized 75-column terminal cards adhering to visual width invariants.
|
|
48
58
|
|
|
@@ -65,7 +75,7 @@ When generating security posture summaries in AI chat:
|
|
|
65
75
|
|
|
66
76
|
## SARIF v2.1.0 Output Specification
|
|
67
77
|
- **Schema:** `https://docs.oasis-open.org/sarif/sarif/v2.1.0/cos02/schemas/sarif-schema-2.1.0.json`
|
|
68
|
-
- **Tool Driver:** `name: TorusGuard`, `semanticVersion:
|
|
78
|
+
- **Tool Driver:** `name: TorusGuard`, `semanticVersion: 2.0.0`, full rules catalog in `driver.rules`.
|
|
69
79
|
- **Automation Details:** `automationDetails.id: "torusguard/static"` to avoid collisions in multi-scanner CI/CD pipelines.
|
|
70
80
|
- **Fingerprints:** `partialFingerprints.primaryLocationLineHash` with SHA-256 context hash.
|
|
71
81
|
|
|
@@ -91,3 +101,34 @@ When generating security posture summaries in AI chat:
|
|
|
91
101
|
|
|
92
102
|
## Living Report Ground Truth
|
|
93
103
|
- Read `security_report.md` in the workspace root before taking any action. Update the relevant finding card after completing remediation.
|
|
104
|
+
|
|
105
|
+
---
|
|
106
|
+
|
|
107
|
+
## 🚨 LLM Trap Table
|
|
108
|
+
|
|
109
|
+
| Pattern | What AI Does Wrong | What Is Actually Correct |
|
|
110
|
+
| :--- | :--- | :--- |
|
|
111
|
+
| **Credential Leakage in HTML** | Embeds raw plaintext passwords, JWTs, or API secrets into HTML report DOM or SARIF output. | Redact all secret values (`[REDACTED]`) before serializing findings to HTML or SARIF. |
|
|
112
|
+
| **External CDN Dependency** | Inserts CDN links (`https://cdn.jsdelivr.net/...`, Google Fonts) breaking offline and air-gapped environments. | Embed 100% of styles, SVGs, and interactive logic inline inside single-file `report.html`. |
|
|
113
|
+
| **SARIF Schema Invalidation** | Emits invalid JSON or omits required fields (`runs[0].tool.driver.rules`), breaking GitHub Code Scanning ingestion. | Validate SARIF output against OASIS v2.1.0 specification with valid rule IDs and URI locations. |
|
|
114
|
+
| **Out-of-Sync Ledger** | Emits HTML report with different counts or statuses than `security_report.md`. | Synchronize metrics so `report.html`, `security_report.md`, and SARIF reflect the identical ground truth. |
|
|
115
|
+
|
|
116
|
+
---
|
|
117
|
+
|
|
118
|
+
## ✅ Pre-Flight Self-Audit
|
|
119
|
+
|
|
120
|
+
Before generating reports:
|
|
121
|
+
- [ ] Are all secrets, tokens, and authorization credentials redacted?
|
|
122
|
+
- [ ] Is `report.html` 100% self-contained with zero external CDN tags?
|
|
123
|
+
- [ ] Does the SARIF export conform strictly to OASIS SARIF v2.1.0?
|
|
124
|
+
- [ ] Does the reported posture score match findings in `security_report.md`?
|
|
125
|
+
|
|
126
|
+
---
|
|
127
|
+
|
|
128
|
+
## 🔁 VBC Protocol (Verify → Build → Confirm)
|
|
129
|
+
|
|
130
|
+
```
|
|
131
|
+
VERIFY: Collect finding counts, verification states, and recheck results from active run.
|
|
132
|
+
BUILD: Compile self-contained visual HTML dashboard and serialize SARIF v2.1.0 log.
|
|
133
|
+
CONFIRM: Check file size and validity on disk; verify zero unredacted secrets exist.
|
|
134
|
+
```
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: torusguard-status
|
|
3
3
|
description: Display current TorusGuard security posture, active configuration, rules catalog, and run history via CLI or AI Agent.
|
|
4
|
-
version:
|
|
4
|
+
version: 2.0.0
|
|
5
5
|
workflow: .torusguard/workflows/status.md
|
|
6
6
|
tools: Read, Grep, Glob, run_command, Write
|
|
7
7
|
scripts-binding:
|
|
8
|
+
- internal/scanner/scanner.go
|
|
8
9
|
- .torusguard/scripts/report_sync.py
|
|
9
10
|
- .torusguard/scripts/run_manager.py
|
|
10
|
-
- .torusguard/scripts/term_ui.py
|
|
11
11
|
---
|
|
12
12
|
|
|
13
13
|
# TorusGuard Status — Workspace Security Posture & Diagnostic Overview
|
|
@@ -17,23 +17,34 @@ Provide an instant diagnostic summary of the repository's security state, active
|
|
|
17
17
|
|
|
18
18
|
---
|
|
19
19
|
|
|
20
|
-
##
|
|
20
|
+
## Tri-Mode Parity
|
|
21
|
+
|
|
22
|
+
| Mode | Command / Tool | Governed Behavior |
|
|
23
|
+
| :--- | :--- | :--- |
|
|
24
|
+
| **Mode A: CLI Terminal** | `torusguard status` | Emits 75-column diagnostic cards with stack, posture, and active rules. |
|
|
25
|
+
| **Mode B: AI Chat Slash** | `/torusguard status` | Parses workspace posture, reviews latest run manifest and open findings. |
|
|
26
|
+
| **Mode C: Native MCP Tool**| `torusguard_status` | Returns structured diagnostic payload directly to AI coding agents. |
|
|
27
|
+
|
|
28
|
+
---
|
|
29
|
+
|
|
30
|
+
## Tri-Mode Execution
|
|
21
31
|
|
|
22
32
|
### Mode A: Automated CLI Execution
|
|
23
33
|
Run the diagnostic overview from your terminal:
|
|
24
34
|
```bash
|
|
25
35
|
# Display 75-column status cards
|
|
26
|
-
|
|
36
|
+
torusguard status
|
|
27
37
|
|
|
28
38
|
# Check status of specific project directory
|
|
29
|
-
|
|
39
|
+
torusguard status ./examples/vulnerable-react-express
|
|
30
40
|
|
|
31
41
|
# Output machine-readable JSON
|
|
32
|
-
|
|
42
|
+
torusguard status --json
|
|
33
43
|
```
|
|
44
|
+
|
|
34
45
|
**Under the Hood:**
|
|
35
46
|
- Evaluates `.torusguard/config/torusguard.json` for initialized status and detected stack.
|
|
36
|
-
- Enumerates active rules in `.torusguard/rules/active/` (or canonical 74 rules).
|
|
47
|
+
- Enumerates active rules in `.torusguard/rules/active/` (or canonical 74 rules across 18 families).
|
|
37
48
|
- Scans `.torusguard/runs/` for run history, finding counts, and verified fixes.
|
|
38
49
|
- Inspects `.torusguard/config/scope.json` for authorized runtime validation targets.
|
|
39
50
|
- Displays mathematically aligned 75-column terminal cards.
|
|
@@ -43,15 +54,26 @@ When checking workspace status in AI chat:
|
|
|
43
54
|
1. **Verify Workspace Setup:** Check if `.torusguard/` exists on disk.
|
|
44
55
|
2. **Inspect Active Config:** Read `.torusguard/config/torusguard.json` for detected stack, framework, and rules.
|
|
45
56
|
3. **Inspect Latest Run:** Find the latest run directory under `.torusguard/runs/` and read `manifest.json`.
|
|
46
|
-
4. **Inspect
|
|
47
|
-
5. **
|
|
57
|
+
4. **Inspect Living Ledger:** Inspect `security_report.md` for current open/fixed finding counts.
|
|
58
|
+
5. **Inspect Memory Engine:** Check `.torusguard/memory/patterns.json` for captured Golden Fix Recipes.
|
|
59
|
+
6. **Render Diagnostic Card:** Present an overview of posture, stack, and recommended next steps.
|
|
60
|
+
|
|
61
|
+
### Mode C: Native MCP Tool Execution
|
|
62
|
+
For autonomous AI coding agents (Antigravity, Cursor, Windsurf, Claude Code):
|
|
63
|
+
- **Tool Invocation:** Call `torusguard_status` with target directory:
|
|
64
|
+
```json
|
|
65
|
+
{
|
|
66
|
+
"target": "."
|
|
67
|
+
}
|
|
68
|
+
```
|
|
69
|
+
- **Programmatic Return:** Receives formatted diagnostic status string detailing detected stack, engine version, and active protection state.
|
|
48
70
|
|
|
49
71
|
---
|
|
50
72
|
|
|
51
73
|
## Output Card Format
|
|
52
74
|
```markdown
|
|
53
75
|
### 🛡️ TorusGuard Workspace Status Overview
|
|
54
|
-
- **Version:**
|
|
76
|
+
- **Version:** v2.0.0 | **Stack:** Node.js / React / Express
|
|
55
77
|
- **Active Rules:** 74 canonical security rules enabled
|
|
56
78
|
- **Historical Runs:** 3 runs recorded
|
|
57
79
|
- **Golden Recipes:** 4 distilled into persistent memory
|
|
@@ -60,3 +82,34 @@ When checking workspace status in AI chat:
|
|
|
60
82
|
|
|
61
83
|
## Living Report Ground Truth
|
|
62
84
|
- Read `security_report.md` in the workspace root before taking any action. Update the relevant finding card after completing remediation.
|
|
85
|
+
|
|
86
|
+
---
|
|
87
|
+
|
|
88
|
+
## 🚨 LLM Trap Table
|
|
89
|
+
|
|
90
|
+
| Pattern | What AI Does Wrong | What Is Actually Correct |
|
|
91
|
+
| :--- | :--- | :--- |
|
|
92
|
+
| **Hallucinated Posture** | Reports repository is "100% secure" without reading `security_report.md` or `.torusguard/config/torusguard.json`. | Read actual disk artifacts (`security_report.md`, `manifest.json`) before reporting status. |
|
|
93
|
+
| **Phantom Run Counts** | Fabricates arbitrary run IDs or counts instead of checking `.torusguard/runs/`. | Enumerate `.torusguard/runs/` directories or use `torusguard status` CLI/MCP output. |
|
|
94
|
+
| **Stack Guessing** | Assumes project stack without inspecting package manifests (`go.mod`, `package.json`, `Cargo.toml`). | Verify detected stack from `torusguard.json` or root dependency files. |
|
|
95
|
+
| **Stale Cache Reliance** | Reports previous conversation status after new files or patches were applied. | Perform fresh inspection of workspace status on each invocation. |
|
|
96
|
+
|
|
97
|
+
---
|
|
98
|
+
|
|
99
|
+
## ✅ Pre-Flight Self-Audit
|
|
100
|
+
|
|
101
|
+
Before emitting a status report:
|
|
102
|
+
- [ ] Did I verify the existence and content of `.torusguard/config/torusguard.json`?
|
|
103
|
+
- [ ] Did I check `security_report.md` for active finding counts?
|
|
104
|
+
- [ ] Did I verify if `.torusguard/runs/` contains historical run data?
|
|
105
|
+
- [ ] Are all reported counts and stack frameworks backed by active disk state?
|
|
106
|
+
|
|
107
|
+
---
|
|
108
|
+
|
|
109
|
+
## 🔁 VBC Protocol (Verify → Build → Confirm)
|
|
110
|
+
|
|
111
|
+
```
|
|
112
|
+
VERIFY: Check disk for .torusguard/ directory and read configuration files.
|
|
113
|
+
BUILD: Aggregate stack information, active rules, and latest run findings.
|
|
114
|
+
CONFIRM: Emit standardized 75-column diagnostic summary card with recommended next steps.
|
|
115
|
+
```
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: torusguard-verify
|
|
3
3
|
description: Verify finding evidence sufficiency, audit live code line matches, and calibrate 0–100 confidence scores.
|
|
4
|
-
version:
|
|
4
|
+
version: 2.0.0
|
|
5
5
|
workflow: .torusguard/workflows/verify.md
|
|
6
6
|
tools: Read, Grep, Glob, Write, run_command
|
|
7
7
|
scripts-binding:
|
|
8
|
+
- internal/scanner/scanner.go
|
|
8
9
|
- .torusguard/scripts/report_sync.py
|
|
9
10
|
- .torusguard/scripts/finding_scorer.py
|
|
10
11
|
---
|
|
@@ -16,22 +17,31 @@ Audit the evidence sufficiency of candidate findings by reading current disk lin
|
|
|
16
17
|
|
|
17
18
|
---
|
|
18
19
|
|
|
20
|
+
## Tri-Mode Parity
|
|
21
|
+
|
|
22
|
+
| Mode | Command / Tool | Governed Behavior |
|
|
23
|
+
| :--- | :--- | :--- |
|
|
24
|
+
| **Mode A: CLI Terminal** | `torusguard verify` | Verifies evidence across findings on disk, asserts line matches. |
|
|
25
|
+
| **Mode B: AI Chat Slash** | `/torusguard verify` | Performs live code inspection, audits source-to-sink taint flows. |
|
|
26
|
+
| **Mode C: Native MCP Tool**| `torusguard_audit` / verify | Diagnostic validation of candidate security findings. |
|
|
27
|
+
|
|
28
|
+
---
|
|
29
|
+
|
|
19
30
|
## Execution Steps
|
|
20
31
|
|
|
21
|
-
1. **Locate Target Findings:** Load active findings from `.torusguard/runs/<latest-run>/findings.md`.
|
|
22
|
-
2. **
|
|
23
|
-
3. **
|
|
24
|
-
4. **
|
|
25
|
-
5. **Calibrate Confidence Score:**
|
|
32
|
+
1. **Locate Target Findings:** Load active findings from `security_report.md` or `.torusguard/runs/<latest-run>/findings.md`.
|
|
33
|
+
2. **Live Disk Line Match:** Inspect exact cited lines using `view_file` to confirm code presence on disk. Do not rely on stale line numbers.
|
|
34
|
+
3. **Audit Evidence Sufficiency:** Verify source-to-sink flow against criteria below.
|
|
35
|
+
4. **Calibrate Confidence Score:**
|
|
26
36
|
```bash
|
|
27
|
-
|
|
37
|
+
torusguard verify
|
|
28
38
|
```
|
|
29
|
-
|
|
30
|
-
|
|
39
|
+
5. **Update State:** Mark finding as `Confirmed`, `Needs Review`, or `False Positive`.
|
|
40
|
+
6. **Emit Verified Evidence:** Save report in `.torusguard/runs/<run_id>/verified-evidence.md`.
|
|
31
41
|
|
|
32
42
|
---
|
|
33
43
|
|
|
34
|
-
## Evidence Sufficiency
|
|
44
|
+
## Evidence Sufficiency Rubric
|
|
35
45
|
A finding is verified as sufficient when:
|
|
36
46
|
- **Direct AST Match:** The vulnerable API or sink call exists on disk at the cited location.
|
|
37
47
|
- **Exposed Surface:** The sink is reachable from an external route, view, or public method.
|
|
@@ -59,3 +69,35 @@ A finding is verified as sufficient when:
|
|
|
59
69
|
- Artifact: `.torusguard/runs/<run_id>/verified-evidence.md`
|
|
60
70
|
Next: Run `/torusguard harden` to formulate surgical fixes for confirmed flaws.
|
|
61
71
|
```
|
|
72
|
+
|
|
73
|
+
---
|
|
74
|
+
|
|
75
|
+
## 🚨 LLM Trap Table
|
|
76
|
+
|
|
77
|
+
| Pattern | What AI Does Wrong | What Is Actually Correct |
|
|
78
|
+
| :--- | :--- | :--- |
|
|
79
|
+
| **Stale Line Reliance** | Assumes finding line number matches current disk state without inspecting active file. | Read live disk lines via `view_file` to verify the exact AST sink is located at that line. |
|
|
80
|
+
| **Sanitizer Blindness** | Flags parameterized queries or sanitized inputs as SQLi because raw SQL keywords exist. | Inspect surrounding lines ($\pm 3$) for parameter bindings (`?`, `$1`, prep statements) or sanitizers. |
|
|
81
|
+
| **Test Fixture Confusion** | Confirms vulnerabilities inside mock test files or test suites as production risks. | Check file path against test exclusion patterns (`_test.go`, `.test.ts`, `fixtures/`). Test vulnerabilities must be contextualized or ignored. |
|
|
82
|
+
| **Hallucinated Reachability** | Confirms private internal functions with no external caller as exploitable web attack surfaces. | Verify if the tainted source is actually reachable from public handlers or API routes. |
|
|
83
|
+
|
|
84
|
+
---
|
|
85
|
+
|
|
86
|
+
## ✅ Pre-Flight Self-Audit
|
|
87
|
+
|
|
88
|
+
Before calibrating or confirming any finding:
|
|
89
|
+
- [ ] Did I read the live file content directly from disk?
|
|
90
|
+
- [ ] Did I verify the exact cited code exists and matches the AST rule pattern?
|
|
91
|
+
- [ ] Did I check for neutralizing middleware, sanitizers, or parameterization in the context window?
|
|
92
|
+
- [ ] Did I verify that the file is not an excluded test fixture or mock?
|
|
93
|
+
- [ ] Is the confidence score (0-100) calibrated against real evidence, not assumptions?
|
|
94
|
+
|
|
95
|
+
---
|
|
96
|
+
|
|
97
|
+
## 🔁 VBC Protocol (Verify → Build → Confirm)
|
|
98
|
+
|
|
99
|
+
```
|
|
100
|
+
VERIFY: Read cited file lines on disk to verify presence of the reported sink.
|
|
101
|
+
BUILD: Trace source-to-sink flow and check for existing sanitizers or validators.
|
|
102
|
+
CONFIRM: Calibrate confidence score and record verified status in security_report.md.
|
|
103
|
+
```
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: torusguard-web-validate
|
|
3
3
|
description: Execute authorized HTTP probing against local/staging web applications — session capture, transparent audit headers, and secret redaction.
|
|
4
|
-
version:
|
|
4
|
+
version: 2.0.0
|
|
5
5
|
workflow: .torusguard/workflows/web-validate.md
|
|
6
6
|
tools: Read, Grep, Glob, Bash, Write, run_command
|
|
7
7
|
scripts-binding:
|
|
8
|
+
- internal/scanner/scanner.go
|
|
8
9
|
- .torusguard/scripts/report_sync.py
|
|
9
10
|
- .torusguard/scripts/safety_gate.py
|
|
10
11
|
---
|
|
@@ -16,16 +17,27 @@ Safely probe live web applications within authorized scope, injecting transparen
|
|
|
16
17
|
|
|
17
18
|
---
|
|
18
19
|
|
|
20
|
+
## Tri-Mode Parity
|
|
21
|
+
|
|
22
|
+
| Mode | Command / Tool | Governed Behavior |
|
|
23
|
+
| :--- | :--- | :--- |
|
|
24
|
+
| **Mode A: CLI Terminal** | `torusguard web-validate` | Dispatches bounded HTTP probes with transparent audit headers and redaction. |
|
|
25
|
+
| **Mode B: AI Chat Slash** | `/torusguard web-validate` | Interactive verification of endpoints, security headers, and cookie flags. |
|
|
26
|
+
| **Mode C: Native MCP Tool**| — | Safe runtime execution guarded by scope.json boundaries. |
|
|
27
|
+
|
|
28
|
+
---
|
|
29
|
+
|
|
19
30
|
## Authorization Gate Check
|
|
20
31
|
Before dispatching any HTTP request:
|
|
21
32
|
1. Verify `.torusguard/config/scope.json` exists and contains target URL.
|
|
22
33
|
2. Confirm current timestamp is prior to `expires_at` TTL.
|
|
23
34
|
3. Assert target is local or non-production staging.
|
|
35
|
+
4. **SSRF Boundary Enforcement:** Resolve target IP and assert it does not target cloud metadata endpoints (`169.254.169.254`) or unintended internal subnets (`127.0.0.1` unless explicitly authorized as local dev).
|
|
24
36
|
|
|
25
37
|
---
|
|
26
38
|
|
|
27
39
|
## Safety Gate
|
|
28
|
-
All requests pass through
|
|
40
|
+
All requests pass through safety boundary checks:
|
|
29
41
|
- `Auto-Allowed`: Read-only `GET`, `HEAD`, `OPTIONS` on non-sensitive paths.
|
|
30
42
|
- `Approval Required`: Requests touching auth, sessions, or parameters.
|
|
31
43
|
- `Manual Only`: Any destructive method (`DELETE`, `DROP`) is strictly blocked.
|
|
@@ -34,13 +46,15 @@ All requests pass through `.torusguard/scripts/safety_gate.py`:
|
|
|
34
46
|
|
|
35
47
|
## Execution Steps
|
|
36
48
|
|
|
37
|
-
1. **Gate Check:** Validate scope in `scope.json
|
|
38
|
-
2. **
|
|
49
|
+
1. **Gate Check:** Validate scope in `scope.json`.
|
|
50
|
+
2. **Execute Probe:**
|
|
51
|
+
```bash
|
|
52
|
+
torusguard web-validate --target http://localhost:3000
|
|
53
|
+
```
|
|
39
54
|
3. **Inject Audit Header:** Attach `X-TorusGuard-AuthID: <auth_id>` to all outbound requests.
|
|
40
|
-
4. **
|
|
41
|
-
5. **
|
|
42
|
-
6. **
|
|
43
|
-
7. **Capture Replay Trace:** Save sanitized trace in `.torusguard/runs/<run_id>/requests.json`.
|
|
55
|
+
4. **Validate Security Headers:** Check for CSP, HSTS, X-Content-Type-Options, and CORS configurations.
|
|
56
|
+
5. **Audit Cookie Flags:** Verify `HttpOnly`, `Secure`, and `SameSite` on session cookies.
|
|
57
|
+
6. **Capture Replay Trace:** Save sanitized trace in `.torusguard/runs/<run_id>/requests.json`.
|
|
44
58
|
|
|
45
59
|
---
|
|
46
60
|
|
|
@@ -68,3 +82,34 @@ All Bearer tokens, cookies, passwords, and API keys are redacted prior to disk s
|
|
|
68
82
|
- Replay Trace: `.torusguard/runs/<run_id>/requests.json`
|
|
69
83
|
Next: Run `/torusguard exploit-check` to confirm exploitability of candidate flaws.
|
|
70
84
|
```
|
|
85
|
+
|
|
86
|
+
---
|
|
87
|
+
|
|
88
|
+
## 🚨 LLM Trap Table
|
|
89
|
+
|
|
90
|
+
| Pattern | What AI Does Wrong | What Is Actually Correct |
|
|
91
|
+
| :--- | :--- | :--- |
|
|
92
|
+
| **Scope Bypass Probing** | Sends HTTP requests to arbitrary endpoints without validating `.torusguard/config/scope.json`. | Check `scope.json` and verify TTL before every outbound probe. |
|
|
93
|
+
| **Token Exposure in Traces** | Writes unredacted `Authorization: Bearer <secret>` or session cookies to `requests.json`. | Redact all credentials to `[REDACTED]` before saving traces to disk. |
|
|
94
|
+
| **SSRF Blindness** | Follows redirects or probes endpoints pointing to AWS/GCP metadata (`169.254.169.254`). | Block private IP ranges and metadata addresses under invariant 9. |
|
|
95
|
+
| **Unbounded Flooding** | Launches high-concurrency request loops or stress tests against local dev server. | Enforce rate limiting and cap session probes to maximum 50 requests. |
|
|
96
|
+
|
|
97
|
+
---
|
|
98
|
+
|
|
99
|
+
## ✅ Pre-Flight Self-Audit
|
|
100
|
+
|
|
101
|
+
Before dispatching web probes:
|
|
102
|
+
- [ ] Is the target URL verified inside `scope.json` and within valid TTL?
|
|
103
|
+
- [ ] Are transparent audit headers (`X-TorusGuard-AuthID`) attached?
|
|
104
|
+
- [ ] Are destructive operations (`DELETE`, drops) blocked?
|
|
105
|
+
- [ ] Are sensitive tokens and cookies redacted from trace logs?
|
|
106
|
+
|
|
107
|
+
---
|
|
108
|
+
|
|
109
|
+
## 🔁 VBC Protocol (Verify → Build → Confirm)
|
|
110
|
+
|
|
111
|
+
```
|
|
112
|
+
VERIFY: Check scope.json validity, TTL, and SSRF boundaries for the target URL.
|
|
113
|
+
BUILD: Construct bounded HTTP request with X-TorusGuard-AuthID audit header.
|
|
114
|
+
CONFIRM: Redact sensitive tokens and save sanitized trace into requests.json.
|
|
115
|
+
```
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# /torusguard-ai-guard — AI Application & RAG Pipeline Guard
|
|
2
|
+
|
|
3
|
+
$ARGUMENTS
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## Objective
|
|
8
|
+
Detect and remediate prompt injection, unsandboxed autonomous tool executions, and cross-tenant vector contamination across AI agent and RAG architectures.
|
|
9
|
+
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
## Tri-Mode Parity
|
|
13
|
+
- **Mode A (Terminal CLI):** `torusguard ai-guard [target]`
|
|
14
|
+
- **Mode B (AI Chat Slash Command):** `/torusguard ai-guard [target]`
|
|
15
|
+
- **Mode C (Native MCP Tool):** `torusguard_ai_guard`
|
|
16
|
+
|
|
17
|
+
---
|
|
18
|
+
|
|
19
|
+
## Execution Steps
|
|
20
|
+
|
|
21
|
+
1. **Discover LLM & Agent Call Sites:** Locate AI framework usage (OpenAI, Anthropic, LangChain, LlamaIndex, Vercel AI SDK).
|
|
22
|
+
2. **Audit Prompt Templates:**
|
|
23
|
+
- Detect raw user string concatenation into system instructions (`TG-AGENT-001`).
|
|
24
|
+
- Flag raw document chunk ingestion in RAG without inert delimiters (`TG-RAG-002`).
|
|
25
|
+
3. **Audit Tool Registry & Dispatchers:**
|
|
26
|
+
- Check for unsandboxed shell, file, or database tool calls lacking Human Gates (`TG-AGENT-002`).
|
|
27
|
+
- Enforce Zod/Pydantic schema validation on all tool argument payloads (`TG-AGENT-003`).
|
|
28
|
+
4. **Audit Vector Store Queries:**
|
|
29
|
+
- Assert all similarity searches (`pgvector`, `pinecone`, `qdrant`, `chroma`) include tenant/user metadata filters (`TG-RAG-001`).
|
|
30
|
+
- Flag ingestion of unvalidated external document payloads (`TG-RAG-003`).
|
|
31
|
+
5. **Formulate Patches & Synchronize:** Propose surgical fixes and record findings in `security_report.md`.
|