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
|
@@ -1,87 +1,160 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: torusguard-audit
|
|
3
|
-
description:
|
|
4
|
-
version:
|
|
3
|
+
description: Taint-aware static AST security scanning, cross-file interprocedural dataflow, 86+ rules across 22 families, line-shift invariant fingerprinting, and 7-signal calibrated confidence scoring via CLI or AI Agent.
|
|
4
|
+
version: 2.0.0
|
|
5
5
|
workflow: .torusguard/workflows/audit.md
|
|
6
6
|
tools: Read, Grep, Glob, Write, run_command
|
|
7
7
|
scripts-binding:
|
|
8
|
-
- .torusguard/scripts/report_sync.py
|
|
9
8
|
- .torusguard/scripts/audit_runner.py
|
|
10
|
-
- .torusguard/scripts/term_ui.py
|
|
11
9
|
- .torusguard/scripts/finding_scorer.py
|
|
10
|
+
- core/taint_graph.py
|
|
11
|
+
- core/cross_file_taint.py
|
|
12
|
+
- core/confidence.py
|
|
13
|
+
- core/parser.py
|
|
14
|
+
- core/incremental.py
|
|
12
15
|
---
|
|
13
16
|
|
|
14
|
-
# TorusGuard Audit — Static Code Security Analysis
|
|
17
|
+
# TorusGuard Audit — Deep Taint-Aware Static Code Security Analysis
|
|
15
18
|
|
|
16
19
|
## Objective
|
|
17
|
-
Execute static AST analysis across
|
|
20
|
+
Execute deep static analysis combining **Tree-sitter polyglot AST parsing**, **source-to-sink taint tracking**, and **interprocedural call-graph analysis** across Python, JavaScript/TypeScript, Go, Rust, Java, Ruby, PHP, and C#. Evaluates code against 86+ canonical rules across 22 architectural families, generates line-shift invariant fingerprints, clusters systemic root causes, and computes 7-signal evidence-chain confidence ratings.
|
|
18
21
|
|
|
19
22
|
---
|
|
20
23
|
|
|
21
|
-
##
|
|
24
|
+
## Tri-Mode Execution Parity
|
|
22
25
|
|
|
23
|
-
### Mode A: Automated CLI
|
|
26
|
+
### Mode A: Automated Terminal CLI
|
|
24
27
|
Run the static security audit from your terminal:
|
|
25
28
|
```bash
|
|
26
|
-
#
|
|
27
|
-
|
|
29
|
+
# Full codebase audit with taint dataflow analysis
|
|
30
|
+
torusguard audit
|
|
28
31
|
|
|
29
|
-
#
|
|
30
|
-
|
|
32
|
+
# Incremental scan (sub-second diff on changed files only)
|
|
33
|
+
torusguard audit --incremental
|
|
31
34
|
|
|
32
|
-
#
|
|
33
|
-
|
|
35
|
+
# Continuous watch mode (re-scan debounced on file save)
|
|
36
|
+
torusguard audit --watch
|
|
37
|
+
|
|
38
|
+
# Audit specific directory or microservice
|
|
39
|
+
torusguard audit ./examples/vulnerable-react-express
|
|
40
|
+
|
|
41
|
+
# Export findings to OASIS SARIF v2.1.0 format
|
|
42
|
+
torusguard audit --sarif --sarif-out ./report.sarif
|
|
43
|
+
|
|
44
|
+
# Machine-readable JSON output
|
|
45
|
+
torusguard audit --json
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
### Mode B: In-Session AI Chat Slash Command (`/torusguard audit`)
|
|
49
|
+
When executing audits directly in AI chat:
|
|
50
|
+
1. **Trace Dataflow (Sources → Sinks):** Track user inputs (`request.GET`, `req.body`, `r.URL.Query()`) through assignments and helper functions to dangerous sinks (`execute()`, `innerHTML`, `open()`).
|
|
51
|
+
2. **Verify Sanitizer Absence:** Confirm that input is not cleansed by `int()`, `escape()`, `shlex.quote()`, or `zod.safeParse()`.
|
|
52
|
+
3. **Cross-File Correlation:** Trace calls across module boundaries up to 5 interprocedural hops using `CrossFileTaintAnalyzer`.
|
|
53
|
+
4. **Cluster Root Causes:** Group findings into architectural failure patterns (e.g. `cluster-prompt-injection`, `cluster-tenant-isolation`, `cluster-supply-chain`).
|
|
54
|
+
5. **Calibrate Confidence:** Score findings via the 7-signal evidence chain model.
|
|
55
|
+
6. **Synchronize Ground Truth:** Record active findings in `security_report.md` at workspace root.
|
|
56
|
+
|
|
57
|
+
### Mode C: Native MCP Tool Calling
|
|
58
|
+
MCP agents invoke `torusguard_audit(target_root, incremental, use_taint)` via JSON-RPC 2.0 stdio to receive structured findings with verified taint paths and confidence scores.
|
|
59
|
+
|
|
60
|
+
---
|
|
61
|
+
|
|
62
|
+
## Architectural Rule Taxonomy (86 Rules Across 22 Families)
|
|
63
|
+
|
|
64
|
+
| Family Code | Security Domain | Core Invariant Enforced |
|
|
65
|
+
| :--- | :--- | :--- |
|
|
66
|
+
| **`TG-SEC`** | Secrets & Credentials | Zero hardcoded API keys, private certificates, or JWT secrets. |
|
|
67
|
+
| **`TG-AUTH`** | Authentication & Session | Enforce timing-safe compares, strong password hashing, algorithm verification. |
|
|
68
|
+
| **`TG-DB`** | Database & Tenancy | Parameterized SQL queries and tenant partition scoping across all lookups. |
|
|
69
|
+
| **`TG-INPUT`** | Input & Sanitization | Strict path sanitization, command argument escaping, safe template rendering. |
|
|
70
|
+
| **`TG-RATE`** | Rate Limiting | Rate-limiting middleware on auth endpoints and payload size bounds. |
|
|
71
|
+
| **`TG-AGENT`** | AI Agents & Prompts | Structural prompt isolation, inert XML delimiters, MCP tool schema validation. |
|
|
72
|
+
| **`TG-SSRF`** | Outbound Net & SSRF | Hostname whitelisting, private IP blocklist (127.0.0.1, 169.254.169.254). |
|
|
73
|
+
| **`TG-WEBHOOK`**| Webhook Verification | Cryptographic HMAC-SHA256 signature verification and replay prevention. |
|
|
74
|
+
| **`TG-WS`** | WebSockets | Origin verification, handshake authentication, inbound frame size limits. |
|
|
75
|
+
| **`TG-CSRF`** | CSRF Protection | SameSite cookie attributes and anti-CSRF token verification on state mutations. |
|
|
76
|
+
| **`TG-GQL`** | GraphQL Safety | Query depth limiting (max depth 6) and production schema introspection suppression. |
|
|
77
|
+
| **`TG-SUPPLY`** | Supply Chain & CI/CD | Immutable commit SHA pinning in GitHub Actions, lockfile integrity audits. |
|
|
78
|
+
| **`TG-BIZ`** | Business Logic | Non-negative quantity asserts, transaction locks, server-side discount bounds. |
|
|
79
|
+
| **`TG-CACHE`** | Cache Poisoning | Cache-Control headers on sensitive responses, unkeyed header sanitization. |
|
|
80
|
+
| **`TG-CLIENT`** | Client Bundle Secrets | Zero private environment variables (`process.env.SUPABASE_SERVICE_ROLE`) in client. |
|
|
81
|
+
| **`TG-PLATFORM`**| Platform Hardening | Helmet security headers, debug mode suppression, cookie secure flags. |
|
|
82
|
+
| **`TG-DIFF`** | Security Bypasses | Block `# nosec`, `InsecureSkipVerify`, and enforce Ponytail line budgets. |
|
|
83
|
+
| **`TG-EDGE`** | Edge & Serverless | Subrequest fan-out limits and serverless execution timeouts. |
|
|
84
|
+
| **`TG-CONT`** | Container Safety | Enforce non-root execution, zero docker socket mounts, no privileged mode. |
|
|
85
|
+
| **`TG-GIT`** | Git History Secrets | Zero historical committed credentials, no tokens in remote URLs. |
|
|
86
|
+
| **`TG-REDOS`** | ReDoS Prevention | Zero nested quantifiers `(a+)+` or catastrophic backtracking regular expressions. |
|
|
87
|
+
| **`TG-RAG`** | RAG & Vector DB | Mandatory tenant scoping on vector similarity search and inert ingestion. |
|
|
88
|
+
|
|
89
|
+
---
|
|
90
|
+
|
|
91
|
+
## Evidence-Chain Confidence Scoring (0–100)
|
|
92
|
+
|
|
93
|
+
Findings are evaluated against 7 empirical signals:
|
|
34
94
|
|
|
35
|
-
# Output machine-readable JSON
|
|
36
|
-
npx torusguard audit --json
|
|
37
95
|
```
|
|
38
|
-
|
|
39
|
-
-
|
|
40
|
-
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
-
|
|
50
|
-
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
96
|
+
Final Score = Σ weighted signals:
|
|
97
|
+
- rule_severity_base (0.20): Critical=90, High=75, Medium=50, Low=25
|
|
98
|
+
- taint_path_confirmed (0.25): 100 if source→sink reachability is confirmed, 0 otherwise
|
|
99
|
+
- taint_depth (0.10): direct=100, 1-hop=80, 2-hop=60, 3+=40
|
|
100
|
+
- sanitizer_absence (0.15): 100 if no known sanitizer present, 0 if sanitized
|
|
101
|
+
- framework_context_match (0.10): 100 if sink matches detected stack, 50 default
|
|
102
|
+
- evidence_snippet_quality (0.10): 100 for multi-line AST context, 50 for single line
|
|
103
|
+
- test_fixture_penalty (-0.10): -50 penalty if located in test suite or fixtures
|
|
104
|
+
- memory_boost: -30 (false positive class) to +15 (regression watch)
|
|
105
|
+
|
|
106
|
+
Classification Bands:
|
|
107
|
+
- 90–100: Confirmed (High priority for automated Ponytail hardening)
|
|
108
|
+
- 70–89: High Confidence (Requires review & remediation)
|
|
109
|
+
- 50–69: Medium Confidence (Context verification needed)
|
|
110
|
+
- 0–49: Needs Review (Suppressed or test fixture)
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
---
|
|
114
|
+
|
|
115
|
+
## 🏛️ Context Minimization & Performance Invariants
|
|
116
|
+
- **1/9th Token Strategy:** Never ingest entire files into agent context. Always inspect bounded AST context windows ($\pm 3$ lines) via `scanner.ExtractContext`.
|
|
117
|
+
- **Incremental Cache:** Uses cryptographic content hashes in `.torusguard/cache/ast_cache.json` to complete repeat audits in under 1 second.
|
|
118
|
+
- **Fail-Closed Safety:** Incomplete parses or syntax anomalies in non-standard files gracefully degrade to fallback token parsing without aborting the audit.
|
|
59
119
|
|
|
60
120
|
---
|
|
61
121
|
|
|
62
|
-
##
|
|
63
|
-
|
|
122
|
+
## 🚨 LLM Trap Table
|
|
123
|
+
|
|
124
|
+
| Pattern | What AI Does Wrong | What Is Actually Correct |
|
|
64
125
|
| :--- | :--- | :--- |
|
|
65
|
-
| **
|
|
66
|
-
| **
|
|
67
|
-
| **
|
|
68
|
-
| **
|
|
69
|
-
| **
|
|
70
|
-
| **TG-DIFF** | Security Bypasses | Disabled TLS verification (`verify=False`) |
|
|
126
|
+
| **Grepping Without Taint** | Flags `db.execute(query)` even when `query` is hardcoded or parameterized. | Verify user input reaches the sink via `core.taint_graph` before reporting. |
|
|
127
|
+
| **Ignoring Sanitizers** | Reports injection even though `int(user_id)` or `shlex.quote()` cleans the input. | Check if any node in the dataflow path acts as a registered sanitizer. |
|
|
128
|
+
| **Single-File Blindness** | Misses vulnerabilities when input enters `utils.py` and reaches a sink in `views.py`. | Trace interprocedural call chains using `CrossFileTaintAnalyzer` (up to 5 hops). |
|
|
129
|
+
| **Unbounded File Dumps** | Reads entire 1,000-line source files into chat context. | Read only the bounded context ($\pm 3$ lines) around the finding's line number. |
|
|
130
|
+
| **Missing Ground Truth Sync** | Produces analysis in chat without synchronizing `security_report.md`. | Always update `security_report.md` with active findings and run IDs. |
|
|
71
131
|
|
|
72
132
|
---
|
|
73
133
|
|
|
74
|
-
##
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
-
|
|
78
|
-
-
|
|
79
|
-
-
|
|
80
|
-
-
|
|
81
|
-
-
|
|
82
|
-
|
|
83
|
-
|
|
134
|
+
## ✅ Pre-Flight Self-Audit
|
|
135
|
+
|
|
136
|
+
Before finishing an audit pass, confirm:
|
|
137
|
+
- [ ] Did I run `torusguard audit` or inspect `security_report.md`?
|
|
138
|
+
- [ ] Are all reported findings backed by confirmed taint paths or verified regex patterns?
|
|
139
|
+
- [ ] Did I verify user input reaches the sink without prior sanitization?
|
|
140
|
+
- [ ] Are findings pinned to exact 1-indexed line numbers with stable region hashes?
|
|
141
|
+
- [ ] Did I synchronize discovering state into `security_report.md`?
|
|
142
|
+
|
|
143
|
+
---
|
|
144
|
+
|
|
145
|
+
## 🔁 VBC Protocol (Verify → Build → Confirm)
|
|
146
|
+
|
|
147
|
+
```
|
|
148
|
+
VERIFY: Scan source code with polyglot AST parser and trace dataflow reachability from sources to sinks.
|
|
149
|
+
BUILD: Group findings by root cause, compute 7-signal calibrated confidence scores, and format 75-column terminal cards.
|
|
150
|
+
CONFIRM: Synchronize all findings to security_report.md at workspace root and guide operator to /torusguard harden.
|
|
84
151
|
```
|
|
85
152
|
|
|
86
|
-
|
|
87
|
-
|
|
153
|
+
---
|
|
154
|
+
|
|
155
|
+
## 🔄 Rollback Defaults
|
|
156
|
+
|
|
157
|
+
If audit data becomes corrupted or a run needs to be reverted:
|
|
158
|
+
1. Historical runs are preserved immutably in `.torusguard/runs/<run_id>/`.
|
|
159
|
+
2. AST cache can be cleared anytime by deleting `.torusguard/cache/ast_cache.json`.
|
|
160
|
+
3. Pre-apply code snapshots remain intact in `.torusguard/snapshots/`.
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: torusguard-authorize
|
|
3
3
|
description: Register and validate runtime target authorization boundaries — scope boundaries, ownership proofs, TTL expiration, and Safety Gate enforcement.
|
|
4
|
-
version:
|
|
4
|
+
version: 2.0.0
|
|
5
5
|
workflow: .torusguard/workflows/authorize.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/safety_gate.py
|
|
10
11
|
---
|
|
@@ -16,18 +17,27 @@ Define and validate legal runtime authorization boundaries, verify target owners
|
|
|
16
17
|
|
|
17
18
|
---
|
|
18
19
|
|
|
20
|
+
## Tri-Mode Parity
|
|
21
|
+
|
|
22
|
+
| Mode | Command / Tool | Governed Behavior |
|
|
23
|
+
| :--- | :--- | :--- |
|
|
24
|
+
| **Mode A: CLI Terminal** | `torusguard authorize` | Interactive boundary setup, generates cryptographically signed scope tokens. |
|
|
25
|
+
| **Mode B: AI Chat Slash** | `/torusguard authorize` | Conversational parameter collection, validates host ownership and environment. |
|
|
26
|
+
| **Mode C: Native MCP Tool**| — | Administrative gatekeeper ensuring strict safety boundaries before probes. |
|
|
27
|
+
|
|
28
|
+
---
|
|
29
|
+
|
|
19
30
|
## Execution Steps
|
|
20
31
|
|
|
21
32
|
1. **Capture Scope Parameters:** Collect target host URL, allowed path prefixes, forbidden prefixes, and session TTL.
|
|
22
|
-
2. **Validate Environment:** Assert target is local (`localhost`, `127.0.0.1`) or staging (`*.staging.*`). Block production targets without explicit override.
|
|
33
|
+
2. **Validate Environment:** Assert target is local (`localhost`, `127.0.0.1`) or staging (`*.staging.*`). Block production targets without explicit cryptographic override.
|
|
23
34
|
3. **Verify Host Ownership:** Confirm ownership token or local process socket binding.
|
|
24
35
|
4. **Invoke Safety Gate:**
|
|
25
36
|
```bash
|
|
26
|
-
|
|
37
|
+
torusguard authorize --url <target_url>
|
|
27
38
|
```
|
|
28
|
-
5. **
|
|
29
|
-
6. **
|
|
30
|
-
7. **Validate Schema:** Confirm `scope.json` adheres to `auth-boundary.schema.json`.
|
|
39
|
+
5. **Write Scope Record:** Persist authorized targets, rate limits, and expiration timestamp into `.torusguard/config/scope.json`.
|
|
40
|
+
6. **Validate Schema:** Confirm `scope.json` adheres to `auth-boundary.schema.json`.
|
|
31
41
|
|
|
32
42
|
---
|
|
33
43
|
|
|
@@ -39,6 +49,7 @@ Define and validate legal runtime authorization boundaries, verify target owners
|
|
|
39
49
|
- Never authorize wildcard hosts (`*`) or third-party domains.
|
|
40
50
|
- State-changing destructive actions (`DELETE`, bulk drops) are disabled by default.
|
|
41
51
|
- Set strict TTL (default 4 hours, maximum 24 hours).
|
|
52
|
+
- Fail-Closed Cryptography: Authorization token generation must panic on entropy failure. No hardcoded fallback tokens are permitted.
|
|
42
53
|
|
|
43
54
|
---
|
|
44
55
|
|
|
@@ -51,3 +62,34 @@ Define and validate legal runtime authorization boundaries, verify target owners
|
|
|
51
62
|
- Scope File: `.torusguard/config/scope.json`
|
|
52
63
|
Next: Run `/torusguard web-validate` to begin safe runtime probing.
|
|
53
64
|
```
|
|
65
|
+
|
|
66
|
+
---
|
|
67
|
+
|
|
68
|
+
## 🚨 LLM Trap Table
|
|
69
|
+
|
|
70
|
+
| Pattern | What AI Does Wrong | What Is Actually Correct |
|
|
71
|
+
| :--- | :--- | :--- |
|
|
72
|
+
| **Wildcard Scope Authorization** | Accepts `*` or wide domain patterns like `*.com`, enabling unbounded network probes. | Strictly enforce exact domain/port matching (`http://localhost:3000`, `https://staging.internal`). |
|
|
73
|
+
| **Infinite TTL** | Omits `expires_at` or sets multi-year expiration timestamps. | Enforce TTL bound of maximum 24 hours (default 4 hours) to prevent lingering test permissions. |
|
|
74
|
+
| **Production Probe Authorization** | Authorizes live production domains without ownership challenge or manual user confirmation. | Reject production domains unless explicit cryptographic ownership challenge succeeds. |
|
|
75
|
+
| **Destructive Method Inclusion** | Allows `DELETE`, `PUT /bulk`, or `DROP` routes in `allowed_paths`. | Blacklist state-altering destructive paths; confine runtime validation to safe, non-destructive probes. |
|
|
76
|
+
|
|
77
|
+
---
|
|
78
|
+
|
|
79
|
+
## ✅ Pre-Flight Self-Audit
|
|
80
|
+
|
|
81
|
+
Before authorizing any runtime scope:
|
|
82
|
+
- [ ] Is the target host local (`localhost`, `127.0.0.1`) or an authorized staging environment?
|
|
83
|
+
- [ ] Are wildcards (`*`) strictly rejected?
|
|
84
|
+
- [ ] Is the TTL strictly bounded (≤24 hours)?
|
|
85
|
+
- [ ] Are destructive routes and SQL operations explicitly forbidden?
|
|
86
|
+
|
|
87
|
+
---
|
|
88
|
+
|
|
89
|
+
## 🔁 VBC Protocol (Verify → Build → Confirm)
|
|
90
|
+
|
|
91
|
+
```
|
|
92
|
+
VERIFY: Check target URL, environment, and ownership proof against safety boundaries.
|
|
93
|
+
BUILD: Construct scope.json record with explicit allowed paths and TTL bounds.
|
|
94
|
+
CONFIRM: Validate JSON against auth-boundary.schema.json and persist to .torusguard/config/scope.json.
|
|
95
|
+
```
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: torusguard-container
|
|
3
|
+
description: Audits Dockerfiles, Containerfiles, and Docker Compose configurations for root users, exposed docker sockets, privileged mode, and embedded secrets via CLI, Chat, or MCP.
|
|
4
|
+
version: 2.0.0
|
|
5
|
+
workflow: .torusguard/workflows/container.md
|
|
6
|
+
tools: Read, Grep, Glob, Write, run_command
|
|
7
|
+
scripts-binding:
|
|
8
|
+
- internal/scanner/container.go
|
|
9
|
+
- cmd/torusguard/main.go
|
|
10
|
+
- cmd/torusguard/mcp.go
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
# TorusGuard Container & Docker Security Audit
|
|
14
|
+
|
|
15
|
+
## Objective
|
|
16
|
+
Detect and remediate critical container runtime and build-time security vulnerabilities across `Dockerfile`, `Containerfile`, `docker-compose.yml`, and `compose.yaml` files. Enforces non-root execution, privilege containment, socket isolation, and BuildKit secret mounts.
|
|
17
|
+
|
|
18
|
+
---
|
|
19
|
+
|
|
20
|
+
## Tri-Mode Execution
|
|
21
|
+
|
|
22
|
+
### Mode A: Automated CLI Execution
|
|
23
|
+
Run container audits against current directory or specific target project:
|
|
24
|
+
```bash
|
|
25
|
+
# Scan container files in current directory
|
|
26
|
+
torusguard container
|
|
27
|
+
|
|
28
|
+
# Scan container files in specific workspace target
|
|
29
|
+
torusguard container --target ./deployments/docker
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
### Mode B: In-Session AI Chat Slash Command
|
|
33
|
+
Run `/torusguard container` in chat.
|
|
34
|
+
The agent invokes the native Go scanner or MCP tool to inspect container definitions, audit user permissions, and report structural container misconfigurations.
|
|
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_container",
|
|
41
|
+
"arguments": {
|
|
42
|
+
"target": "."
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
---
|
|
48
|
+
|
|
49
|
+
## Supported Patterns & Invariants
|
|
50
|
+
- **TG-CONT-001 (Root Execution Default):** Detects omission of explicit `USER <non-root>` instruction or explicit `USER root` declarations in production container stages.
|
|
51
|
+
- **TG-CONT-002 (Docker Socket Exposure):** Detects dangerous mounting of the host daemon socket (`/var/run/docker.sock`), which grants unconfined root privileges over the host.
|
|
52
|
+
- **TG-CONT-003 (Privileged Container Flag):** Detects `privileged: true`, `seccomp:unconfined`, or `SYS_ADMIN` capability grants that defeat Linux namespace and cgroup boundaries.
|
|
53
|
+
- **TG-CONT-004 (Build-Time Secret Injection):** Flags embedding sensitive tokens, passwords, or keys via `ARG` or `ENV` directives in Dockerfiles rather than BuildKit secret mounts.
|
|
54
|
+
|
|
55
|
+
---
|
|
56
|
+
|
|
57
|
+
## 🏛️ OpenCodeReview Hybrid Architecture Integration
|
|
58
|
+
- **Deterministic Dockerfile & Compose Parser:** Pattern extraction is executed by Go AST/regex parsers without external Docker daemon dependencies.
|
|
59
|
+
- **Token Efficiency:** Only flagged container directives and minimal surrounding context are returned to the agent context.
|
|
60
|
+
- **Ponytail Bounds:** Remediation patches must add dedicated non-root users (`USER appuser`) or switch secrets to `--mount=type=secret` without full container file rewrites (≤35 additions, ≤25 deletions).
|
|
61
|
+
|
|
62
|
+
---
|
|
63
|
+
|
|
64
|
+
## 🚨 LLM Trap Table
|
|
65
|
+
|
|
66
|
+
| Pattern | What AI Does Wrong | What Is Actually Correct |
|
|
67
|
+
| :--- | :--- | :--- |
|
|
68
|
+
| **Default Root Execution** | Forgets that Docker executes as UID 0 (`root`) unless a non-root `USER` is declared. | Always declare `RUN adduser -D appuser && USER appuser` before the entrypoint. |
|
|
69
|
+
| **Secrets in Build Arguments** | Recommends `ARG API_KEY` or `ENV DB_PASSWORD`, leaving keys baked into image layers. | Use Docker BuildKit secret mounts: `RUN --mount=type=secret,id=mysecret ...`. |
|
|
70
|
+
| **Permissive Privileged Mode** | Adds `privileged: true` or `cap_add: [ALL]` to resolve permission or port binding errors. | Grant only specific minimal Linux capabilities (e.g. `NET_BIND_SERVICE`) or fix file ownership. |
|
|
71
|
+
| **Docker Socket Mounting** | Mounts `/var/run/docker.sock` inside container to run Docker commands inside Docker. | Use Docker-in-Docker (dind) rootless or ephemeral CI runners with isolated daemons. |
|
|
72
|
+
| **Full File Rewrites** | Rewrites entire multi-stage Dockerfile destroying cached layer order. | Formulate surgical diffs replacing or inserting only the missing `USER` or mount flag. |
|
|
73
|
+
|
|
74
|
+
---
|
|
75
|
+
|
|
76
|
+
## ✅ Pre-Flight Self-Audit
|
|
77
|
+
|
|
78
|
+
Before concluding a container security review, verify:
|
|
79
|
+
- [ ] Did I scan all Dockerfiles (`Dockerfile`, `Dockerfile.*`, `Containerfile`)?
|
|
80
|
+
- [ ] Did I scan all compose files (`docker-compose.yml`, `compose.yaml`)?
|
|
81
|
+
- [ ] Is there an unprivileged non-root user defined before `ENTRYPOINT` or `CMD`?
|
|
82
|
+
- [ ] Are sensitive environment variables passed via runtime `.env` / secret managers instead of `ARG` / `ENV`?
|
|
83
|
+
- [ ] Is `/var/run/docker.sock` completely absent from compose volumes?
|
|
84
|
+
- [ ] Are all proposed fixes within Ponytail churn bounds (≤35 additions, ≤25 deletions)?
|
|
85
|
+
|
|
86
|
+
---
|
|
87
|
+
|
|
88
|
+
## 🔁 VBC Protocol (Verify → Build → Confirm)
|
|
89
|
+
|
|
90
|
+
```
|
|
91
|
+
VERIFY: Identify Dockerfiles and Compose files in the workspace.
|
|
92
|
+
BUILD: Execute torusguard container or torusguard_container to locate container privilege and secret flaws.
|
|
93
|
+
CONFIRM: Formulate surgical remediation patch introducing non-root users and removing dangerous mounts, rechecking with torusguard recheck.
|
|
94
|
+
```
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: torusguard-exploit-check
|
|
3
3
|
description: Safe, non-destructive confirmation of exploitability using inert canary tokens and sentinels.
|
|
4
|
-
version:
|
|
4
|
+
version: 2.0.0
|
|
5
5
|
workflow: .torusguard/workflows/exploit-check.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
|
- .torusguard/scripts/finding_scorer.py
|
|
@@ -17,11 +18,21 @@ Confirm whether candidate findings are practically exploitable using safe, singl
|
|
|
17
18
|
|
|
18
19
|
---
|
|
19
20
|
|
|
21
|
+
## Tri-Mode Parity
|
|
22
|
+
|
|
23
|
+
| Mode | Command / Tool | Governed Behavior |
|
|
24
|
+
| :--- | :--- | :--- |
|
|
25
|
+
| **Mode A: CLI Terminal** | `torusguard exploit-check` | Dispatches single-step sentinel canaries, confirms exploitability safely. |
|
|
26
|
+
| **Mode B: AI Chat Slash** | `/torusguard exploit-check` | Evaluates reproduction traces and classifies findings into 5 statuses. |
|
|
27
|
+
| **Mode C: Native MCP Tool**| — | Bounded execution guarded by safety gate and inert payloads. |
|
|
28
|
+
|
|
29
|
+
---
|
|
30
|
+
|
|
20
31
|
## Authorization Gate Check
|
|
21
32
|
Before dispatching any exploitability probe:
|
|
22
33
|
1. Verify target route is explicitly authorized in `.torusguard/config/scope.json`.
|
|
23
34
|
2. Verify authorization TTL has not expired.
|
|
24
|
-
3. Assert probe passes
|
|
35
|
+
3. Assert probe passes safety boundaries.
|
|
25
36
|
|
|
26
37
|
---
|
|
27
38
|
|
|
@@ -37,15 +48,17 @@ Before dispatching any exploitability probe:
|
|
|
37
48
|
|
|
38
49
|
1. **Verify Scope:** Read `scope.json`; assert authorized endpoint.
|
|
39
50
|
2. **Select Canary:** Choose matching non-destructive probe strategy.
|
|
40
|
-
3. **
|
|
41
|
-
|
|
42
|
-
|
|
51
|
+
3. **Dispatch Probe:** Send request with header `X-TorusGuard-AuthID`:
|
|
52
|
+
```bash
|
|
53
|
+
torusguard exploit-check --finding TG-SEC-001
|
|
54
|
+
```
|
|
55
|
+
4. **Classify Status:** Transition finding into one of 5 canonical outcomes:
|
|
43
56
|
- `Confirmed`: Canary reflected or secondary tenant data leaked.
|
|
44
57
|
- `Not Reproducible`: Endpoint responded with 401/403 or sanitized input.
|
|
45
58
|
- `Needs Review`: Ambiguous status code or incomplete response.
|
|
46
59
|
- `Blocked by Controls`: WAF or rate limiter stopped probe.
|
|
47
60
|
- `Out of Scope`: Target endpoint is not authorized.
|
|
48
|
-
|
|
61
|
+
5. **Record Evidence:** Save trace in `.torusguard/runs/<run_id>/exploit-evidence.md`.
|
|
49
62
|
|
|
50
63
|
---
|
|
51
64
|
|
|
@@ -68,3 +81,34 @@ Before dispatching any exploitability probe:
|
|
|
68
81
|
- Evidence: <Response snippet or status code>
|
|
69
82
|
Next: Run `/torusguard harden` to formulate surgical remediation bundle.
|
|
70
83
|
```
|
|
84
|
+
|
|
85
|
+
---
|
|
86
|
+
|
|
87
|
+
## 🚨 LLM Trap Table
|
|
88
|
+
|
|
89
|
+
| Pattern | What AI Does Wrong | What Is Actually Correct |
|
|
90
|
+
| :--- | :--- | :--- |
|
|
91
|
+
| **Destructive Payloads** | Generates real data-altering payloads (`'; DROP TABLE users;--`, `<script>evil()</script>`). | Use strictly inert canaries (`' OR 1=1--`, `<tg-canary-tag>`) that cannot destroy state or exfiltrate data. |
|
|
92
|
+
| **Fuzzing Floods** | Runs recursive wordlist fuzzing or multi-hundred request automated attacks. | Enforce single-step bounded confirmation (1-2 deterministic probe requests max). |
|
|
93
|
+
| **False Confirmation** | Declares finding "Confirmed" based on a generic HTTP 500 error without validating the canary reflection. | Require differential response evidence (e.g. reflection of exact sentinel tag or tenant leak). |
|
|
94
|
+
| **Missing Scope Check** | Probes external auth providers (OAuth Google/GitHub) during auth validation. | Confine probes strictly to internal endpoints authorized in `scope.json`. |
|
|
95
|
+
|
|
96
|
+
---
|
|
97
|
+
|
|
98
|
+
## ✅ Pre-Flight Self-Audit
|
|
99
|
+
|
|
100
|
+
Before dispatching an exploitability check:
|
|
101
|
+
- [ ] Is the probe payload completely inert and non-destructive?
|
|
102
|
+
- [ ] Is the route explicitly in scope and within TTL?
|
|
103
|
+
- [ ] Is the `X-TorusGuard-AuthID` header attached?
|
|
104
|
+
- [ ] Is the outcome classification mapped to one of the 5 canonical statuses?
|
|
105
|
+
|
|
106
|
+
---
|
|
107
|
+
|
|
108
|
+
## 🔁 VBC Protocol (Verify → Build → Confirm)
|
|
109
|
+
|
|
110
|
+
```
|
|
111
|
+
VERIFY: Check route authorization in scope.json and confirm finding AST context.
|
|
112
|
+
BUILD: Select inert canary token (e.g. <tg-canary-tag>) and construct probe.
|
|
113
|
+
CONFIRM: Evaluate response for differential proof, classify status, and record trace.
|
|
114
|
+
```
|
|
@@ -1,16 +1,14 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: torusguard-full
|
|
3
3
|
description: Master 7-stage security pipeline orchestrator — coordinates discovery, authorization, static audit, runtime validation, governed remediation, recheck, and reporting.
|
|
4
|
-
version:
|
|
4
|
+
version: 2.0.0
|
|
5
5
|
workflow: .torusguard/workflows/audit.md
|
|
6
6
|
tools: Read, Grep, Glob, Bash, Edit, Write, run_command
|
|
7
7
|
scripts-binding:
|
|
8
|
+
- internal/scanner/scanner.go
|
|
9
|
+
- internal/harden/patch.go
|
|
10
|
+
- internal/apply/apply.go
|
|
8
11
|
- .torusguard/scripts/report_sync.py
|
|
9
|
-
- .torusguard/scripts/stack_detect.py
|
|
10
|
-
- .torusguard/scripts/safety_gate.py
|
|
11
|
-
- .torusguard/scripts/finding_scorer.py
|
|
12
|
-
- .torusguard/scripts/run_manager.py
|
|
13
|
-
- .torusguard/scripts/sarif_exporter.py
|
|
14
12
|
---
|
|
15
13
|
|
|
16
14
|
# TorusGuard Full — Master 7-Stage Pipeline Orchestrator
|
|
@@ -20,15 +18,33 @@ Execute the full, closed-loop TorusGuard security lifecycle from stack discovery
|
|
|
20
18
|
|
|
21
19
|
---
|
|
22
20
|
|
|
21
|
+
## Tri-Mode Pipeline Parity
|
|
22
|
+
|
|
23
|
+
| Stage | Mode A: Terminal CLI | Mode B: AI Chat Slash | Mode C: Native MCP Tool |
|
|
24
|
+
| :--- | :--- | :--- | :--- |
|
|
25
|
+
| **0. Init** | `torusguard init` | `/torusguard init` | Init + `torusguard_status` |
|
|
26
|
+
| **1. Authorize** | `torusguard authorize` | `/torusguard authorize` | Safety Gate Boundary |
|
|
27
|
+
| **2. Audit & Vision** | `torusguard audit` / `ocr-scan` | `/torusguard audit` / `ocr-scan` | `torusguard_audit` / `torusguard_ocr_scan` |
|
|
28
|
+
| **3. Verify** | `torusguard verify` | `/torusguard verify` | `torusguard_verify` |
|
|
29
|
+
| **4. Harden** | `torusguard harden` | `/torusguard harden` | `torusguard_harden` |
|
|
30
|
+
| **5. Apply** | `torusguard apply [--yes]` | `/torusguard apply` | Human Gate Approval |
|
|
31
|
+
| **6. Recheck** | `torusguard recheck` | `/torusguard recheck` | `torusguard_recheck` |
|
|
32
|
+
| **7. Report** | `torusguard report --html` | `/torusguard report` | `torusguard://security_report` |
|
|
33
|
+
|
|
34
|
+
---
|
|
35
|
+
|
|
23
36
|
## 7-Stage Security Pipeline
|
|
24
|
-
|
|
37
|
+
```
|
|
38
|
+
0. Init ──► 1. Authorize ──► 2. Audit ──► 3. Validate ──► 4. Harden ──► 5. Apply ──► 6. Recheck ──► 7. Report
|
|
39
|
+
(Baseline) (Scope Gate) (AST Scan) (Evidence) (Ponytail) (Human Gate) (Regression) (SARIF/HTML)
|
|
40
|
+
```
|
|
25
41
|
|
|
26
42
|
---
|
|
27
43
|
|
|
28
44
|
## Specialist Skill Routing
|
|
29
45
|
- **Phase 0:** `torusguard-init` (`profiler`)
|
|
30
46
|
- **Phase 1:** `torusguard-authorize` (`reviewer`)
|
|
31
|
-
- **Phase 2:** `torusguard-audit` (`auditor`)
|
|
47
|
+
- **Phase 2:** `torusguard-audit` (`auditor`) / `torusguard-ocr-scan` (`vision`)
|
|
32
48
|
- **Phase 3:** `torusguard-verify` / `torusguard-exploit-check` (`validator`)
|
|
33
49
|
- **Phase 4:** `torusguard-harden` (`remediator`)
|
|
34
50
|
- **Phase 5:** `torusguard-apply` (`remediator`)
|
|
@@ -38,19 +54,14 @@ Execute the full, closed-loop TorusGuard security lifecycle from stack discovery
|
|
|
38
54
|
---
|
|
39
55
|
|
|
40
56
|
## Pipeline Execution Instructions
|
|
41
|
-
1. **Init:** Detect stack via `
|
|
57
|
+
1. **Init:** Detect stack via `torusguard init` and activate tailored rules in `.torusguard/rules/active/`.
|
|
42
58
|
2. **Authorize:** Verify target ownership and TTL in `.torusguard/config/scope.json`.
|
|
43
|
-
3. **Audit:** Scan ASTs; assign fingerprints;
|
|
59
|
+
3. **Audit:** Scan ASTs via `torusguard audit` (or `torusguard ocr-scan` for visual assets); assign fingerprints; compute confidence scores.
|
|
44
60
|
4. **Validate:** Audit evidence sufficiency; optionally send bounded probe canary.
|
|
45
|
-
5. **Harden:** Formulate surgical diffs bound by Ponytail limits ($\le 35$
|
|
46
|
-
6. **Apply:**
|
|
47
|
-
7. **Recheck:** Re-scan modified files
|
|
48
|
-
8. **Report:** Export OASIS SARIF v2.1.0 and emit
|
|
49
|
-
|
|
50
|
-
---
|
|
51
|
-
|
|
52
|
-
## Confidence Scoring Rubric
|
|
53
|
-
Evaluates Evidence (35 pts), Reproduction (25 pts), Corroboration (15 pts), Environment (15 pts), and Review Status (10 pts) into 4 bands: Confirmed (90–100), High (70–89), Medium (50–69), Needs Review (<50).
|
|
61
|
+
5. **Harden:** Formulate surgical diffs bound by Ponytail limits ($\le 35$ additions, $\le 25$ deletions).
|
|
62
|
+
6. **Apply:** Capture `.bak` snapshot in `.torusguard/snapshots/`; obtain Human Gate; apply patch via `torusguard apply`.
|
|
63
|
+
7. **Recheck:** Re-scan modified files via `torusguard recheck`; assert findings are `Fixed` with zero regressions.
|
|
64
|
+
8. **Report:** Export OASIS SARIF v2.1.0 and emit visual HTML dashboard via `torusguard report --html`.
|
|
54
65
|
|
|
55
66
|
---
|
|
56
67
|
|
|
@@ -62,6 +73,7 @@ Evaluates Evidence (35 pts), Reproduction (25 pts), Corroboration (15 pts), Envi
|
|
|
62
73
|
- Human Gate mandatory before code modifications in Phase 5.
|
|
63
74
|
- Enforce Ponytail line bounds ($\le 35$ additions, $\le 25$ deletions).
|
|
64
75
|
- Never dispatch network probes outside authorized scope in `scope.json`.
|
|
76
|
+
- Zero security bypasses permitted (`TG-DIFF-001`).
|
|
65
77
|
|
|
66
78
|
---
|
|
67
79
|
|
|
@@ -73,3 +85,34 @@ Evaluates Evidence (35 pts), Reproduction (25 pts), Corroboration (15 pts), Envi
|
|
|
73
85
|
- SARIF Log: `.torusguard/runs/<run_id>/results.sarif`
|
|
74
86
|
- Report: `.torusguard/runs/<run_id>/report.md`
|
|
75
87
|
```
|
|
88
|
+
|
|
89
|
+
---
|
|
90
|
+
|
|
91
|
+
## 🚨 LLM Trap Table
|
|
92
|
+
|
|
93
|
+
| Pattern | What AI Does Wrong | What Is Actually Correct |
|
|
94
|
+
| :--- | :--- | :--- |
|
|
95
|
+
| **Pipeline Step Skipping** | Jumps directly from Audit to Apply without verifying evidence or validating Ponytail patch bounds. | Follow the 7 stages in sequential order; each stage gate must be satisfied. |
|
|
96
|
+
| **Human Gate Bypass** | Writes modifications directly to disk without presenting candidate diffs or awaiting user confirmation. | Always require explicit Human Gate confirmation before Phase 5 (`torusguard apply`). |
|
|
97
|
+
| **Full File Rewrites** | Rewrites complete source files during remediation, causing massive line churn and regression risk. | Formulate surgical patches respecting Ponytail bounds ($\le 35$ add, $\le 25$ del) using Line-Level Reflection. |
|
|
98
|
+
| **Unsynchronized State** | Generates reports that don't match the statuses in `security_report.md`. | Keep `security_report.md` synchronized at every phase transition as the single living source of truth. |
|
|
99
|
+
|
|
100
|
+
---
|
|
101
|
+
|
|
102
|
+
## ✅ Pre-Flight Self-Audit
|
|
103
|
+
|
|
104
|
+
Before orchestrating the full pipeline:
|
|
105
|
+
- [ ] Are all prerequisite tools (`torusguard` binary) available?
|
|
106
|
+
- [ ] Is `security_report.md` inspected prior to initiating any scans or fixes?
|
|
107
|
+
- [ ] Are all patches bounded by Ponytail limits and verified without security bypasses?
|
|
108
|
+
- [ ] Is a `.bak` snapshot captured before any disk modification?
|
|
109
|
+
|
|
110
|
+
---
|
|
111
|
+
|
|
112
|
+
## 🔁 VBC Protocol (Verify → Build → Confirm)
|
|
113
|
+
|
|
114
|
+
```
|
|
115
|
+
VERIFY: Review current workspace security posture and verify phase prerequisites.
|
|
116
|
+
BUILD: Execute the pipeline stage by stage using designated specialist skills.
|
|
117
|
+
CONFIRM: Validate final SARIF, HTML report, and synchronized security_report.md.
|
|
118
|
+
```
|