torusguard 0.9.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (236) hide show
  1. package/.torusguard/.manifest.json +95 -0
  2. package/.torusguard/ARCHITECTURE.md +168 -0
  3. package/.torusguard/TORUSGUARD.md +145 -0
  4. package/.torusguard/agents/auditor.md +41 -0
  5. package/.torusguard/agents/profiler.md +49 -0
  6. package/.torusguard/agents/remediator.md +41 -0
  7. package/.torusguard/agents/reviewer.md +39 -0
  8. package/.torusguard/agents/validator.md +46 -0
  9. package/.torusguard/config/scope.json +24 -0
  10. package/.torusguard/config/slash-commands.json +102 -0
  11. package/.torusguard/config/torusguard.json +30 -0
  12. package/.torusguard/references/django-security.md +43 -0
  13. package/.torusguard/references/drf-security.md +20 -0
  14. package/.torusguard/references/express-security.md +103 -0
  15. package/.torusguard/references/fastapi-security.md +20 -0
  16. package/.torusguard/references/firebase-security.md +78 -0
  17. package/.torusguard/references/flask-security.md +20 -0
  18. package/.torusguard/references/nextjs-security.md +96 -0
  19. package/.torusguard/references/react-vite-security.md +97 -0
  20. package/.torusguard/references/sqlalchemy-security.md +16 -0
  21. package/.torusguard/references/supabase-security.md +84 -0
  22. package/.torusguard/rules/README.md +62 -0
  23. package/.torusguard/rules/TORUSGUARD.md +145 -0
  24. package/.torusguard/rules/active/.gitkeep +0 -0
  25. package/.torusguard/rules/active/TG-DIFF-001.md +20 -0
  26. package/.torusguard/rules/active/TG-DIFF-002.md +20 -0
  27. package/.torusguard/rules/active/TG-DIFF-003.md +19 -0
  28. package/.torusguard/runs/.gitkeep +0 -0
  29. package/.torusguard/schemas/authorization.schema.json +81 -0
  30. package/.torusguard/schemas/confidence.schema.json +72 -0
  31. package/.torusguard/schemas/evidence.schema.json +66 -0
  32. package/.torusguard/schemas/finding.schema.json +164 -0
  33. package/.torusguard/schemas/provenance.schema.json +46 -0
  34. package/.torusguard/schemas/remediation.schema.json +59 -0
  35. package/.torusguard/schemas/retest.schema.json +53 -0
  36. package/.torusguard/schemas/runtime-evidence.schema.json +72 -0
  37. package/.torusguard/scripts/__pycache__/diff_guard.cpython-311.pyc +0 -0
  38. package/.torusguard/scripts/__pycache__/monorepo_detector.cpython-311.pyc +0 -0
  39. package/.torusguard/scripts/diff_guard.py +171 -0
  40. package/.torusguard/scripts/finding_scorer.py +86 -0
  41. package/.torusguard/scripts/manifest_builder.py +130 -0
  42. package/.torusguard/scripts/monorepo_detector.py +164 -0
  43. package/.torusguard/scripts/run_manager.py +89 -0
  44. package/.torusguard/scripts/safety_gate.py +64 -0
  45. package/.torusguard/scripts/sarif_exporter.py +116 -0
  46. package/.torusguard/scripts/stack_detect.py +152 -0
  47. package/.torusguard/skills/torusguard/SKILL.md +37 -0
  48. package/.torusguard/skills/torusguard/bootstrap.py +158 -0
  49. package/.torusguard/skills/torusguard/references/auth-and-sessions.md +56 -0
  50. package/.torusguard/skills/torusguard/references/business-logic-and-abuse.md +23 -0
  51. package/.torusguard/skills/torusguard/references/cache-and-sensitive-responses.md +10 -0
  52. package/.torusguard/skills/torusguard/references/client-code-exposure.md +55 -0
  53. package/.torusguard/skills/torusguard/references/csrf-and-cross-origin.md +11 -0
  54. package/.torusguard/skills/torusguard/references/dependency-and-supply-chain.md +22 -0
  55. package/.torusguard/skills/torusguard/references/django-security.md +43 -0
  56. package/.torusguard/skills/torusguard/references/drf-security.md +20 -0
  57. package/.torusguard/skills/torusguard/references/fastapi-security.md +20 -0
  58. package/.torusguard/skills/torusguard/references/flask-security.md +20 -0
  59. package/.torusguard/skills/torusguard/references/frontend-no-db.md +53 -0
  60. package/.torusguard/skills/torusguard/references/graphql-security.md +12 -0
  61. package/.torusguard/skills/torusguard/references/input-and-injection.md +51 -0
  62. package/.torusguard/skills/torusguard/references/mass-assignment-and-property-auth.md +22 -0
  63. package/.torusguard/skills/torusguard/references/platform-hardening.md +56 -0
  64. package/.torusguard/skills/torusguard/references/python-dependencies.md +16 -0
  65. package/.torusguard/skills/torusguard/references/python-security-overview.md +12 -0
  66. package/.torusguard/skills/torusguard/references/rate-limit-and-abuse.md +57 -0
  67. package/.torusguard/skills/torusguard/references/secrets-and-config.md +64 -0
  68. package/.torusguard/skills/torusguard/references/sqlalchemy-security.md +16 -0
  69. package/.torusguard/skills/torusguard/references/ssrf-and-outbound-requests.md +46 -0
  70. package/.torusguard/skills/torusguard/references/webhook-security.md +15 -0
  71. package/.torusguard/skills/torusguard/references/websocket-security.md +12 -0
  72. package/.torusguard/skills/torusguard-apply/SKILL.md +46 -0
  73. package/.torusguard/skills/torusguard-audit/SKILL.md +70 -0
  74. package/.torusguard/skills/torusguard-authorize/SKILL.md +47 -0
  75. package/.torusguard/skills/torusguard-exploit-check/SKILL.md +64 -0
  76. package/.torusguard/skills/torusguard-full/SKILL.md +70 -0
  77. package/.torusguard/skills/torusguard-harden/SKILL.md +63 -0
  78. package/.torusguard/skills/torusguard-init/SKILL.md +52 -0
  79. package/.torusguard/skills/torusguard-recheck/SKILL.md +53 -0
  80. package/.torusguard/skills/torusguard-report/SKILL.md +54 -0
  81. package/.torusguard/skills/torusguard-status/SKILL.md +42 -0
  82. package/.torusguard/skills/torusguard-verify/SKILL.md +55 -0
  83. package/.torusguard/skills/torusguard-web-validate/SKILL.md +64 -0
  84. package/.torusguard/templates/audit-report.template.md +54 -0
  85. package/.torusguard/templates/authorization.template.md +34 -0
  86. package/.torusguard/templates/finding-card.template.md +32 -0
  87. package/.torusguard/templates/remediation-bundle.template.md +35 -0
  88. package/.torusguard/workflows/apply.md +95 -0
  89. package/.torusguard/workflows/audit.md +93 -0
  90. package/.torusguard/workflows/authorize.md +95 -0
  91. package/.torusguard/workflows/exploit-check.md +97 -0
  92. package/.torusguard/workflows/harden.md +93 -0
  93. package/.torusguard/workflows/init.md +95 -0
  94. package/.torusguard/workflows/recheck.md +95 -0
  95. package/.torusguard/workflows/report.md +95 -0
  96. package/.torusguard/workflows/status.md +95 -0
  97. package/.torusguard/workflows/verify.md +95 -0
  98. package/.torusguard/workflows/web-validate.md +95 -0
  99. package/LICENSE +21 -0
  100. package/README.md +319 -0
  101. package/bin/torusguard.js +110 -0
  102. package/install.py +98 -0
  103. package/package.json +48 -0
  104. package/skills/torusguard/SKILL.md +41 -0
  105. package/skills/torusguard/__pycache__/bootstrap.cpython-311.pyc +0 -0
  106. package/skills/torusguard/bootstrap.py +256 -0
  107. package/skills/torusguard/payload/.manifest.json +95 -0
  108. package/skills/torusguard/payload/ARCHITECTURE.md +168 -0
  109. package/skills/torusguard/payload/TORUSGUARD.md +145 -0
  110. package/skills/torusguard/payload/agents/auditor.md +41 -0
  111. package/skills/torusguard/payload/agents/profiler.md +49 -0
  112. package/skills/torusguard/payload/agents/remediator.md +41 -0
  113. package/skills/torusguard/payload/agents/reviewer.md +39 -0
  114. package/skills/torusguard/payload/agents/validator.md +46 -0
  115. package/skills/torusguard/payload/config/scope.json +24 -0
  116. package/skills/torusguard/payload/config/slash-commands.json +102 -0
  117. package/skills/torusguard/payload/config/torusguard.json +30 -0
  118. package/skills/torusguard/payload/references/django-security.md +43 -0
  119. package/skills/torusguard/payload/references/drf-security.md +20 -0
  120. package/skills/torusguard/payload/references/express-security.md +103 -0
  121. package/skills/torusguard/payload/references/fastapi-security.md +20 -0
  122. package/skills/torusguard/payload/references/firebase-security.md +78 -0
  123. package/skills/torusguard/payload/references/flask-security.md +20 -0
  124. package/skills/torusguard/payload/references/nextjs-security.md +96 -0
  125. package/skills/torusguard/payload/references/react-vite-security.md +97 -0
  126. package/skills/torusguard/payload/references/sqlalchemy-security.md +16 -0
  127. package/skills/torusguard/payload/references/supabase-security.md +84 -0
  128. package/skills/torusguard/payload/rules/README.md +62 -0
  129. package/skills/torusguard/payload/rules/TORUSGUARD.md +145 -0
  130. package/skills/torusguard/payload/rules/active/.gitkeep +0 -0
  131. package/skills/torusguard/payload/rules/active/TG-DIFF-001.md +20 -0
  132. package/skills/torusguard/payload/rules/active/TG-DIFF-002.md +20 -0
  133. package/skills/torusguard/payload/rules/active/TG-DIFF-003.md +19 -0
  134. package/skills/torusguard/payload/schemas/authorization.schema.json +81 -0
  135. package/skills/torusguard/payload/schemas/confidence.schema.json +72 -0
  136. package/skills/torusguard/payload/schemas/evidence.schema.json +66 -0
  137. package/skills/torusguard/payload/schemas/finding.schema.json +164 -0
  138. package/skills/torusguard/payload/schemas/provenance.schema.json +46 -0
  139. package/skills/torusguard/payload/schemas/remediation.schema.json +59 -0
  140. package/skills/torusguard/payload/schemas/retest.schema.json +53 -0
  141. package/skills/torusguard/payload/schemas/runtime-evidence.schema.json +72 -0
  142. package/skills/torusguard/payload/scripts/diff_guard.py +171 -0
  143. package/skills/torusguard/payload/scripts/finding_scorer.py +86 -0
  144. package/skills/torusguard/payload/scripts/manifest_builder.py +130 -0
  145. package/skills/torusguard/payload/scripts/monorepo_detector.py +164 -0
  146. package/skills/torusguard/payload/scripts/run_manager.py +89 -0
  147. package/skills/torusguard/payload/scripts/safety_gate.py +64 -0
  148. package/skills/torusguard/payload/scripts/sarif_exporter.py +116 -0
  149. package/skills/torusguard/payload/scripts/stack_detect.py +152 -0
  150. package/skills/torusguard/payload/skills/torusguard/SKILL.md +37 -0
  151. package/skills/torusguard/payload/skills/torusguard/bootstrap.py +158 -0
  152. package/skills/torusguard/payload/skills/torusguard/references/auth-and-sessions.md +56 -0
  153. package/skills/torusguard/payload/skills/torusguard/references/business-logic-and-abuse.md +23 -0
  154. package/skills/torusguard/payload/skills/torusguard/references/cache-and-sensitive-responses.md +10 -0
  155. package/skills/torusguard/payload/skills/torusguard/references/client-code-exposure.md +55 -0
  156. package/skills/torusguard/payload/skills/torusguard/references/csrf-and-cross-origin.md +11 -0
  157. package/skills/torusguard/payload/skills/torusguard/references/dependency-and-supply-chain.md +22 -0
  158. package/skills/torusguard/payload/skills/torusguard/references/django-security.md +43 -0
  159. package/skills/torusguard/payload/skills/torusguard/references/drf-security.md +20 -0
  160. package/skills/torusguard/payload/skills/torusguard/references/fastapi-security.md +20 -0
  161. package/skills/torusguard/payload/skills/torusguard/references/flask-security.md +20 -0
  162. package/skills/torusguard/payload/skills/torusguard/references/frontend-no-db.md +53 -0
  163. package/skills/torusguard/payload/skills/torusguard/references/graphql-security.md +12 -0
  164. package/skills/torusguard/payload/skills/torusguard/references/input-and-injection.md +51 -0
  165. package/skills/torusguard/payload/skills/torusguard/references/mass-assignment-and-property-auth.md +22 -0
  166. package/skills/torusguard/payload/skills/torusguard/references/platform-hardening.md +56 -0
  167. package/skills/torusguard/payload/skills/torusguard/references/python-dependencies.md +16 -0
  168. package/skills/torusguard/payload/skills/torusguard/references/python-security-overview.md +12 -0
  169. package/skills/torusguard/payload/skills/torusguard/references/rate-limit-and-abuse.md +57 -0
  170. package/skills/torusguard/payload/skills/torusguard/references/secrets-and-config.md +64 -0
  171. package/skills/torusguard/payload/skills/torusguard/references/sqlalchemy-security.md +16 -0
  172. package/skills/torusguard/payload/skills/torusguard/references/ssrf-and-outbound-requests.md +46 -0
  173. package/skills/torusguard/payload/skills/torusguard/references/webhook-security.md +15 -0
  174. package/skills/torusguard/payload/skills/torusguard/references/websocket-security.md +12 -0
  175. package/skills/torusguard/payload/skills/torusguard-apply/SKILL.md +46 -0
  176. package/skills/torusguard/payload/skills/torusguard-audit/SKILL.md +70 -0
  177. package/skills/torusguard/payload/skills/torusguard-authorize/SKILL.md +47 -0
  178. package/skills/torusguard/payload/skills/torusguard-exploit-check/SKILL.md +64 -0
  179. package/skills/torusguard/payload/skills/torusguard-full/SKILL.md +70 -0
  180. package/skills/torusguard/payload/skills/torusguard-harden/SKILL.md +63 -0
  181. package/skills/torusguard/payload/skills/torusguard-init/SKILL.md +52 -0
  182. package/skills/torusguard/payload/skills/torusguard-recheck/SKILL.md +53 -0
  183. package/skills/torusguard/payload/skills/torusguard-report/SKILL.md +54 -0
  184. package/skills/torusguard/payload/skills/torusguard-status/SKILL.md +42 -0
  185. package/skills/torusguard/payload/skills/torusguard-verify/SKILL.md +55 -0
  186. package/skills/torusguard/payload/skills/torusguard-web-validate/SKILL.md +64 -0
  187. package/skills/torusguard/payload/templates/audit-report.template.md +54 -0
  188. package/skills/torusguard/payload/templates/authorization.template.md +34 -0
  189. package/skills/torusguard/payload/templates/finding-card.template.md +32 -0
  190. package/skills/torusguard/payload/templates/remediation-bundle.template.md +35 -0
  191. package/skills/torusguard/payload/workflows/apply.md +95 -0
  192. package/skills/torusguard/payload/workflows/audit.md +93 -0
  193. package/skills/torusguard/payload/workflows/authorize.md +95 -0
  194. package/skills/torusguard/payload/workflows/exploit-check.md +97 -0
  195. package/skills/torusguard/payload/workflows/harden.md +93 -0
  196. package/skills/torusguard/payload/workflows/init.md +95 -0
  197. package/skills/torusguard/payload/workflows/recheck.md +95 -0
  198. package/skills/torusguard/payload/workflows/report.md +95 -0
  199. package/skills/torusguard/payload/workflows/status.md +95 -0
  200. package/skills/torusguard/payload/workflows/verify.md +95 -0
  201. package/skills/torusguard/payload/workflows/web-validate.md +95 -0
  202. package/skills/torusguard/references/auth-and-sessions.md +56 -0
  203. package/skills/torusguard/references/business-logic-and-abuse.md +23 -0
  204. package/skills/torusguard/references/cache-and-sensitive-responses.md +10 -0
  205. package/skills/torusguard/references/client-code-exposure.md +55 -0
  206. package/skills/torusguard/references/csrf-and-cross-origin.md +11 -0
  207. package/skills/torusguard/references/dependency-and-supply-chain.md +22 -0
  208. package/skills/torusguard/references/django-security.md +43 -0
  209. package/skills/torusguard/references/drf-security.md +20 -0
  210. package/skills/torusguard/references/fastapi-security.md +20 -0
  211. package/skills/torusguard/references/flask-security.md +20 -0
  212. package/skills/torusguard/references/frontend-no-db.md +53 -0
  213. package/skills/torusguard/references/graphql-security.md +12 -0
  214. package/skills/torusguard/references/input-and-injection.md +51 -0
  215. package/skills/torusguard/references/mass-assignment-and-property-auth.md +22 -0
  216. package/skills/torusguard/references/platform-hardening.md +56 -0
  217. package/skills/torusguard/references/python-dependencies.md +16 -0
  218. package/skills/torusguard/references/python-security-overview.md +12 -0
  219. package/skills/torusguard/references/rate-limit-and-abuse.md +57 -0
  220. package/skills/torusguard/references/secrets-and-config.md +64 -0
  221. package/skills/torusguard/references/sqlalchemy-security.md +16 -0
  222. package/skills/torusguard/references/ssrf-and-outbound-requests.md +46 -0
  223. package/skills/torusguard/references/webhook-security.md +15 -0
  224. package/skills/torusguard/references/websocket-security.md +12 -0
  225. package/skills/torusguard-apply/SKILL.md +46 -0
  226. package/skills/torusguard-audit/SKILL.md +70 -0
  227. package/skills/torusguard-authorize/SKILL.md +47 -0
  228. package/skills/torusguard-exploit-check/SKILL.md +64 -0
  229. package/skills/torusguard-full/SKILL.md +70 -0
  230. package/skills/torusguard-harden/SKILL.md +63 -0
  231. package/skills/torusguard-init/SKILL.md +52 -0
  232. package/skills/torusguard-recheck/SKILL.md +53 -0
  233. package/skills/torusguard-report/SKILL.md +54 -0
  234. package/skills/torusguard-status/SKILL.md +42 -0
  235. package/skills/torusguard-verify/SKILL.md +55 -0
  236. package/skills/torusguard-web-validate/SKILL.md +64 -0
@@ -0,0 +1,95 @@
1
+ ---
2
+ description: Evidence sufficiency verification, live disk line match audit, and finding score refinement.
3
+ tools: Read, Grep, Glob, Bash, Write
4
+ version: 0.9.2
5
+ agent: validator
6
+ lifecycle-phase: Phase 3a (Evidence Verification)
7
+ required-skills:
8
+ - torusguard-verify
9
+ scripts-binding:
10
+ - .torusguard/scripts/finding_scorer.py
11
+ ---
12
+
13
+ # /torusguard verify — Evidence Verification & Score Refinement
14
+
15
+ $ARGUMENTS
16
+
17
+ ---
18
+
19
+ ## Objective
20
+ Evidence sufficiency verification, live disk line match audit, and finding score refinement.
21
+
22
+ ---
23
+
24
+ ## Mandatory Pre-Flight Context Inspection
25
+
26
+ Inspect finding records and evidence integrity before verification:
27
+ 1. **Latest Run Records (`.torusguard/runs/`):** Locate most recent audit run directory.
28
+ 2. **Finding Files:** Confirm `findings.md` or `findings.json` exists in the target run folder.
29
+ 3. **Live File Drift:** Assert cited source files have not been edited or relocated on disk.
30
+ 4. **Scoring Model Calibration:** Ensure `finding_scorer.py` evaluates all 5 rubric dimensions.
31
+ 5. **Role Boundary:** Enforce validator role; do not apply code modifications during verification.
32
+
33
+ ---
34
+
35
+ ## When to Use /torusguard verify
36
+
37
+ | Trigger Scenario | Recommended Action |
38
+ | :--- | :--- |
39
+ | Auditing whether static findings are valid code flaws | Run `/torusguard verify` |
40
+ | Upgrading Medium confidence finding to Confirmed | Run `/torusguard verify` |
41
+ | No audit run executed yet | Run `/torusguard audit` first |
42
+ | Running live network requests against endpoints | Run `/torusguard web-validate` |
43
+ | Generating patch after verification | Run `/torusguard harden` |
44
+
45
+ ---
46
+
47
+ ## Execution Steps
48
+
49
+ 1. **Locate Target Findings:** Load active findings from latest run directory.
50
+ 2. **Live Disk Line Match:** Read current code at cited line ranges; verify AST snippet matches.
51
+ 3. **Audit Evidence Sufficiency:** Assess whether taint path is unbroken and caller context is exposed.
52
+ 4. **Refine Confidence Scores:**
53
+ ```bash
54
+ python .torusguard/scripts/finding_scorer.py --run <run_dir> --verify
55
+ ```
56
+ 5. **Classify Status:** Assign verified state (`Confirmed`, `Plausible`, or `False Positive / Disputed`).
57
+ 6. **Emit Verification Ledger:** Write `verified-evidence.md` into the active run folder.
58
+
59
+ ---
60
+
61
+ ## Failure Recovery
62
+
63
+ - **Missing Run Folder:** Run `/torusguard audit` first to produce a valid run baseline.
64
+ - **Line Drift Detected:** Flag line mismatch; scan nearby lines (±25) for relocated AST sink.
65
+ - **Malformed Finding JSON:** Repair JSON structure using finding schema before scoring.
66
+ - **Halt Trigger:** Abort if cited files are completely deleted from disk.
67
+
68
+ ---
69
+
70
+ ## Hallucination Guard
71
+
72
+ - ❌ Never confirm a finding if the cited sink has already been sanitized by middleware.
73
+ - ❌ Never bump confidence score without documenting unbroken taint source-to-sink flow.
74
+ - ✅ Always anchor line matches to live disk reads using `view_file`.
75
+
76
+ ---
77
+
78
+ ## Output Card Format
79
+
80
+ ```markdown
81
+ ### 🧪 TorusGuard Evidence Verification
82
+ - **Run ID:** `run-YYYYMMDD-HHMMSS-audit`
83
+ - **Findings Evaluated:** [Count] findings
84
+ - **Confirmed Real:** [Count] verified flaws
85
+ - **Downgraded / False Positives:** [Count] filtered out
86
+ - **Refined Mean Score:** [Score]/100
87
+ - **Ledger:** `.torusguard/runs/<run_id>/verified-evidence.md`
88
+ ```
89
+
90
+ ---
91
+
92
+ ## Next Steps
93
+
94
+ 1. Run `/torusguard web-validate` if live endpoint probing is required.
95
+ 2. Run `/torusguard harden` to build surgical patch bundles for verified flaws.
@@ -0,0 +1,95 @@
1
+ ---
2
+ description: Authorized HTTP probing, token redaction, transparent audit header injection, and replay trace capture.
3
+ tools: Read, Grep, Glob, Bash, Write
4
+ version: 0.9.2
5
+ agent: validator
6
+ lifecycle-phase: Phase 3b (Runtime Web Validation)
7
+ required-skills:
8
+ - torusguard-web-validate
9
+ scripts-binding:
10
+ - .torusguard/scripts/safety_gate.py
11
+ ---
12
+
13
+ # /torusguard web-validate — Bounded HTTP Probing & Session Capture
14
+
15
+ $ARGUMENTS
16
+
17
+ ---
18
+
19
+ ## Objective
20
+ Authorized HTTP probing, token redaction, transparent audit header injection, and replay capture.
21
+
22
+ ---
23
+
24
+ ## Mandatory Pre-Flight Context Inspection
25
+
26
+ Inspect authorization parameters and safety limits before sending HTTP requests:
27
+ 1. **Active Scope (`.torusguard/config/scope.json`):** Assert target host and path are authorized with valid TTL.
28
+ 2. **Safety Gate Classification:** Test proposed endpoint against `.torusguard/scripts/safety_gate.py`.
29
+ 3. **Sensitive Route Guard:** Ensure destructive endpoints (`DELETE`, account drops) are never called automatically.
30
+ 4. **Token Redaction Pipeline:** Ensure bearer tokens and session cookies are masked (`Bearer [REDACTED]`).
31
+ 5. **Request Budget:** Enforce maximum cap of 50 requests per validation session.
32
+
33
+ ---
34
+
35
+ ## When to Use /torusguard web-validate
36
+
37
+ | Trigger Scenario | Recommended Action |
38
+ | :--- | :--- |
39
+ | Testing live route accessibility and security headers | Run `/torusguard web-validate` |
40
+ | Verifying cookie security flags (`HttpOnly`, `Secure`, `SameSite`) | Run `/torusguard web-validate` |
41
+ | Checking CORS headers and authentication barriers | Run `/torusguard web-validate` |
42
+ | Pure static source code analysis | Run `/torusguard audit` |
43
+ | Confirming exploitable attack vectors | Run `/torusguard exploit-check` |
44
+
45
+ ---
46
+
47
+ ## Execution Steps
48
+
49
+ 1. **Verify Legal Scope:** Check target URL against `.torusguard/config/scope.json`.
50
+ 2. **Invoke Safety Gate:**
51
+ ```bash
52
+ python .torusguard/scripts/safety_gate.py check --url <target_url> --method GET
53
+ ```
54
+ 3. **Dispatch Non-Destructive Probe:** Send bounded HTTP request with audit header `X-TorusGuard-AuthID`.
55
+ 4. **Redact Sensitive Headers:** Sanitize auth tokens and credentials in request and response objects.
56
+ 5. **Write Replay Artifacts:**
57
+ Record sanitized trace in `.torusguard/runs/<run_id>/requests.json` and emit `web-validation.md`.
58
+
59
+ ---
60
+
61
+ ## Failure Recovery
62
+
63
+ - **Target Offline:** Verify local dev server is active and accessible on designated host port.
64
+ - **Safety Gate Rejection (Manual Only):** Halt probe immediately; report endpoint requires human manual test.
65
+ - **Rate Limit / 429:** Back off exponentially (1s, 2s, 4s); stop session if 429 persists.
66
+ - **Halt Trigger:** Abort if target domain deviates from authorized allowlist in `scope.json`.
67
+
68
+ ---
69
+
70
+ ## Hallucination Guard
71
+
72
+ - ❌ Never dispatch HTTP requests outside domains explicitly listed in `.torusguard/config/scope.json`.
73
+ - ❌ Never write raw Authorization headers or plaintext secrets to disk.
74
+ - ✅ Always include transparent audit headers (`X-TorusGuard-AuthID`).
75
+
76
+ ---
77
+
78
+ ## Output Card Format
79
+
80
+ ```markdown
81
+ ### 🌐 TorusGuard Web Validation
82
+ - **Target Host:** [Host URL]
83
+ - **Endpoints Probed:** [Count] routes tested
84
+ - **Security Headers:** [CSP / HSTS / CORS status]
85
+ - **Cookie Security:** [HttpOnly / Secure / SameSite status]
86
+ - **Replay Trace:** `.torusguard/runs/<run_id>/replay.json`
87
+ - **Status:** COMPLETED — non-destructive probe finished
88
+ ```
89
+
90
+ ---
91
+
92
+ ## Next Steps
93
+
94
+ 1. Run `/torusguard exploit-check` to confirm if reachable flaws constitute verified exploits.
95
+ 2. Run `/torusguard harden` to build surgical remediation diffs.
@@ -0,0 +1,56 @@
1
+ # Authentication, Sessions, and Authorization
2
+
3
+ ## When to load
4
+
5
+ Load during `/TorusGuard check auth`, login/signup/reset implementation, or resource route reviews.
6
+
7
+ ## Linked rules
8
+
9
+ - [TG-AUTH-001](../../rules/TG-AUTH-001-weak-password-storage.md) — Weak Password Storage (Critical)
10
+ - [TG-AUTH-002](../../rules/TG-AUTH-002-client-only-authorization.md) — Client-Only Authorization (High)
11
+ - [TG-AUTH-003](../../rules/TG-AUTH-003-missing-object-authorization.md) — IDOR/BOLA (High)
12
+ - [TG-AUTH-004](../../rules/TG-AUTH-004-insecure-session-cookie.md) — Insecure Session Cookie (High)
13
+ - [TG-AUTH-005](../../rules/TG-AUTH-005-unsafe-password-reset.md) — Unsafe Password Reset (High)
14
+
15
+ ## Hard bans
16
+
17
+ - No plaintext, MD5, or SHA1 password storage
18
+ - No authorization enforced only in frontend routing
19
+ - No trust in client-supplied user IDs or roles
20
+ - No session cookies missing httpOnly/Secure/SameSite in production
21
+ - No predictable or reusable password reset tokens
22
+
23
+ ## Safe defaults
24
+
25
+ - Argon2id or bcrypt (cost ≥ 12) for passwords
26
+ - httpOnly, Secure, SameSite cookies for browser sessions
27
+ - Server-side role and ownership checks on every sensitive route
28
+ - Neutral login/reset responses (no account enumeration)
29
+ - CSRF protection for cookie-authenticated state changes
30
+ - Reset tokens: random, single-use, expiring
31
+
32
+ ## IDOR test procedure
33
+
34
+ For each route with a resource ID (`/api/users/:id`, `/api/orders/:orderId`):
35
+
36
+ > Can User A change the ID and access User B's resource?
37
+
38
+ If yes → fails TG-AUTH-003.
39
+
40
+ ## Audit checklist
41
+
42
+ - [ ] Strong password hashing (TG-AUTH-001)
43
+ - [ ] Server enforces authZ (TG-AUTH-002)
44
+ - [ ] Object ownership verified (TG-AUTH-003)
45
+ - [ ] Secure cookie flags (TG-AUTH-004)
46
+ - [ ] Safe reset flow + rate limits (TG-AUTH-005)
47
+
48
+ ## Manual review
49
+
50
+ - Organization/tenant-scoped authorization
51
+ - Privilege escalation via mass assignment
52
+ - Session fixation and logout invalidation
53
+
54
+ ## Related rules
55
+
56
+ TG-RATE-001, TG-SEC-004, TG-INPUT-001
@@ -0,0 +1,23 @@
1
+ # Business Logic and Abuse
2
+
3
+ ## Topics
4
+ - Coupon and discount abuse.
5
+ - Trial and referral abuse.
6
+ - Payment amount tampering.
7
+ - Inventory manipulation.
8
+ - OTP and verification workflow bypass.
9
+ - Vote and rating manipulation.
10
+ - Repeated one-time operations.
11
+ - AI or third-party API cost abuse.
12
+ - Replay and idempotency.
13
+ - Per-user and per-account velocity.
14
+ - Server-side state transitions.
15
+
16
+ ## Review Table
17
+ | Flow | Value protected | Abuse action | Existing control | Missing control |
18
+ |---|---|---|---|---|
19
+ | Apply coupon | Discount amount | Reuse coupon | Database flag | Atomic update |
20
+ | Send OTP | SMS cost | Repeated requests | IP limiter | Account limiter |
21
+ | Create order | Inventory/payment | Modify quantity/price | Auth only | Server-side pricing |
22
+
23
+ The agent must ask whether a user can execute a technically valid operation too many times. OWASP identifies sensitive business-flow abuse separately from ordinary authentication and resource-exhaustion concerns.
@@ -0,0 +1,10 @@
1
+ # Cache and Sensitive Responses
2
+
3
+ - Cache-Control: private, no-store for sensitive responses where appropriate.
4
+ - CDN cache-key isolation.
5
+ - User-specific response separation.
6
+ - Sensitive query parameters and tokens.
7
+ - Referrer leakage.
8
+ - Authenticated API responses.
9
+ - Export/download URLs.
10
+ - Signed URL expiry.
@@ -0,0 +1,55 @@
1
+ # Client Code Exposure and Source Maps
2
+
3
+ ## When to load
4
+
5
+ Load during `/TorusGuard check client`, production build review, or frontend bundle audits.
6
+
7
+ ## Linked rules
8
+
9
+ - [TG-CLIENT-001](../../rules/TG-CLIENT-001-public-production-source-maps.md) — Public Production Source Maps (Medium)
10
+ - [TG-CLIENT-002](../../rules/TG-CLIENT-002-sensitive-client-bundle-content.md) — Sensitive Bundle Content (High)
11
+
12
+ ## Important truth
13
+
14
+ **Inspect Element and DevTools cannot be prevented.** Browser-delivered JavaScript is public. TorusGuard must never claim client code can be hidden. Security comes from server-side enforcement, not obfuscation.
15
+
16
+ Obfuscation is a minor deterrent only — never a security control.
17
+
18
+ ## Hard bans
19
+
20
+ - No secrets, privileged routes, or auth decisions only in client code
21
+ - No production `console.log` of tokens, users, or config
22
+ - No public `.map` files unless explicitly required
23
+
24
+ ## Safe defaults
25
+
26
+ | Framework | Production setting |
27
+ |-----------|-------------------|
28
+ | Vite | `build.sourcemap: false` |
29
+ | Next.js | `productionBrowserSourceMaps: false` |
30
+ | CRA | `GENERATE_SOURCEMAP=false` |
31
+
32
+ - Upload source maps privately to Sentry/monitoring — do not serve publicly
33
+ - Verify public `.map` URLs return 404 when disabled
34
+ - Add CSP where practical
35
+ - Move authorization and secrets server-side
36
+
37
+ ## Audit checklist
38
+
39
+ - [ ] Production source maps disabled or private (TG-CLIENT-001)
40
+ - [ ] No secrets or privileged logic in bundle (TG-CLIENT-002)
41
+ - [ ] No sensitive console logging
42
+ - [ ] CSP configured appropriately
43
+
44
+ ## Manual review
45
+
46
+ - Third-party script dependencies
47
+ - Comments revealing internal routes or admin endpoints
48
+
49
+ ## Related rules
50
+
51
+ TG-SEC-002, TG-AUTH-002, TG-PLATFORM-002
52
+
53
+ ## Framework guide
54
+
55
+ [React/Vite Security](../../guides/react-vite-security.md)
@@ -0,0 +1,11 @@
1
+ # CSRF and Cross-Origin
2
+
3
+ - Cookie-authenticated state changes.
4
+ - Synchronizer tokens.
5
+ - Double-submit cookies.
6
+ - SameSite behavior and limitations.
7
+ - CORS and credentials.
8
+ - Origin and Referer validation where appropriate.
9
+ - JSON content-type restrictions.
10
+ - Framework-native CSRF protections.
11
+ - SPA/API architecture differences.
@@ -0,0 +1,22 @@
1
+ # Dependency and Supply Chain
2
+
3
+ - Lockfiles.
4
+ - Dependency update policy.
5
+ - Vulnerability audit commands by ecosystem.
6
+ - Dependabot/Renovate.
7
+ - GitHub Actions pinning.
8
+ - CI secret exposure.
9
+ - Pull-request workflow trust.
10
+ - Install scripts.
11
+ - Dependency provenance.
12
+ - Review of new packages.
13
+
14
+ ## Audit Commands
15
+ ```bash
16
+ npm audit
17
+ pip-audit
18
+ osv-scanner --lockfile=package-lock.json
19
+ dotnet list package --vulnerable
20
+ bundle audit
21
+ govulncheck ./...
22
+ ```
@@ -0,0 +1,43 @@
1
+ # TorusGuard Skill Reference: Django Security
2
+
3
+ > **Loaded When:** A project is identified as a Django application (`manage.py`, `settings.py`, or `django` dependency detected).
4
+
5
+ ---
6
+
7
+ ## 🛡️ Key Inspection Areas & Rules
8
+
9
+ ### 1. Secrets & Production Configuration
10
+ * `TG-SEC-001`: Verify `SECRET_KEY` is loaded via `os.environ` or a secrets manager, not hardcoded.
11
+ * `TG-PLATFORM-003`: Verify `DEBUG = False` in production configs.
12
+ * `TG-PLATFORM-001`: Ensure `ALLOWED_HOSTS` is restricted to legitimate hostnames.
13
+
14
+ ### 2. Authentication & Authorization
15
+ * `TG-AUTH-001`: Ensure protected views use `@login_required` or `LoginRequiredMixin`.
16
+ * `TG-AUTH-007`: Enforce object-level ownership checks (e.g. `get_object_or_404(Model, id=id, user=request.user)`). Avoid unrestricted numeric ID lookups.
17
+
18
+ ### 3. Mass Assignment
19
+ * `TG-AUTH-006`: Ensure `ModelForm` definitions specify explicit `fields = [...]` lists instead of `fields = '__all__'`.
20
+
21
+ ### 4. Injection & Database Security
22
+ * `TG-INPUT-003`: Ensure `Model.objects.raw()` or `cursor.execute()` uses parameterized inputs (`%s`), never f-strings or `.format()`.
23
+
24
+ ### 5. CSRF & Request Security
25
+ * `TG-CSRF-001`: Verify `django.middleware.csrf.CsrfViewMiddleware` is active in `MIDDLEWARE`. Avoid indiscriminate `@csrf_exempt`.
26
+ * `TG-CACHE-001`: Verify sensitive authenticated endpoints use `@never_cache`.
27
+
28
+ ---
29
+
30
+ ## 🛠️ Safe Patterns Summary
31
+ ```python
32
+ # Safe Object Lookup
33
+ item = get_object_or_404(Invoice, id=invoice_id, account=request.user.account)
34
+
35
+ # Safe Form
36
+ class ProfileForm(forms.ModelForm):
37
+ class Meta:
38
+ model = Profile
39
+ fields = ['bio', 'website_url', 'avatar']
40
+
41
+ # Safe Raw SQL (if mandatory)
42
+ cursor.execute("SELECT * FROM reports WHERE account_id = %s", [request.user.account_id])
43
+ ```
@@ -0,0 +1,20 @@
1
+ # TorusGuard Skill Reference: Django REST Framework (DRF)
2
+
3
+ > **Loaded When:** Project uses `rest_framework` dependencies or imports.
4
+
5
+ ---
6
+
7
+ ## 🛡️ Key Inspection Areas & Rules
8
+
9
+ ### 1. Permissions & Endpoint Exposure
10
+ * `TG-AUTH-001`: Inspect `settings.py` for `REST_FRAMEWORK['DEFAULT_PERMISSION_CLASSES']`. If missing or set to `AllowAny`, verify that individual views specify explicit `permission_classes`.
11
+ * `TG-AUTH-007`: In `ModelViewSet` and API views, check if `get_queryset()` returns `Model.objects.all()` without filtering by `request.user` or tenant context.
12
+
13
+ ### 2. Serializer Field Whitelists & Mass Assignment
14
+ * `TG-AUTH-006`: Inspect Serializer classes. Flag serializers where `fields = '__all__'` or where administrative/financial fields are not in `read_only_fields`.
15
+
16
+ ### 3. Throttling & Rate Limits
17
+ * `TG-RATE-001`: Check authentication endpoints (login, password reset, register, OTP) for throttle classes (`UserRateThrottle`, `ScopedRateThrottle`).
18
+
19
+ ### 4. Pagination Caps
20
+ * `TG-RATE-002`: Check custom pagination classes for `max_page_size`. If client-controlled `page_size_query_param` is enabled without a ceiling, flag as unbound resource risk.
@@ -0,0 +1,20 @@
1
+ # TorusGuard Skill Reference: FastAPI Security
2
+
3
+ > **Loaded When:** Project uses `fastapi` dependencies or imports.
4
+
5
+ ---
6
+
7
+ ## 🛡️ Key Inspection Areas & Rules
8
+
9
+ ### 1. Route Authorization & Dependencies
10
+ * `TG-AUTH-001` / `TG-AUTH-003`: Verify protected routes include security dependencies (`Depends(get_current_user)`).
11
+ * `TG-AUTH-007`: In route handlers taking numeric/UUID path parameters (e.g. `profile_id`, `invoice_id`), verify that database queries filter by the authenticated user's ID.
12
+
13
+ ### 2. Request Models & Mass Assignment
14
+ * `TG-AUTH-006`: Check that endpoints accept structured Pydantic `BaseModel` classes rather than raw `dict`, `Body(...)`, or unpacking `**payload` directly into ORM entities.
15
+
16
+ ### 3. Outbound Requests & SSRF
17
+ * `TG-SSRF-001`: Inspect endpoints that fetch external URLs via `httpx` or `requests`. Verify scheme validation and private IP address filtering.
18
+
19
+ ### 4. Webhook Integrity
20
+ * `TG-WEBHOOK-001`: In webhook endpoints, verify HMAC signature validation using `await request.body()` (raw bytes) before JSON parsing.
@@ -0,0 +1,20 @@
1
+ # TorusGuard Skill Reference: Flask Security
2
+
3
+ > **Loaded When:** Project uses `flask` dependencies or imports.
4
+
5
+ ---
6
+
7
+ ## 🛡️ Key Inspection Areas & Rules
8
+
9
+ ### 1. Secret Key & Cookie Configuration
10
+ * `TG-SEC-001`: Inspect `app.config['SECRET_KEY']`. Flag hardcoded string literals.
11
+ * `TG-PLATFORM-003`: Verify `app.debug = False` in production configs.
12
+
13
+ ### 2. Authorization & Ownership (IDOR)
14
+ * `TG-AUTH-007`: In route handlers querying database models by route variables (e.g. `<int:id>`), verify that the query filters by `current_user.id`.
15
+
16
+ ### 3. CSRF Protection
17
+ * `TG-CSRF-001`: Verify that cookie-authenticated web forms initialize `flask_wtf.CSRFProtect`.
18
+
19
+ ### 4. File Uploads
20
+ * `TG-INPUT-004`: Ensure uploaded filenames are filtered using `secure_filename()` and validate against an extension whitelist.
@@ -0,0 +1,53 @@
1
+ # Frontend Database Protection
2
+
3
+ ## When to load
4
+
5
+ Load during `/TorusGuard check database`, full-stack audits, or when frontend code connects to data stores.
6
+
7
+ ## Linked rules
8
+
9
+ - [TG-DB-001](../../rules/TG-DB-001-frontend-database-query.md) — Database Query in Frontend (High)
10
+ - [TG-DB-002](../../rules/TG-DB-002-privileged-database-credential.md) — Privileged Credential in Browser (Critical)
11
+ - [TG-DB-003](../../rules/TG-DB-003-frontend-admin-sdk.md) — Frontend Admin SDK (Critical)
12
+
13
+ ## Hard bans
14
+
15
+ - No SQL in frontend directories (`src/`, `app/`, `pages/`, `components/`, `client/`, `public/`)
16
+ - No imports of `pg`, `mysql`, `mongoose`, `@prisma/client`, Sequelize, TypeORM, Drizzle server client
17
+ - No Supabase service-role key or Firebase Admin SDK in browser code
18
+ - No trust in client-provided user ID or role without server verification
19
+
20
+ ## Safe architecture
21
+
22
+ ```
23
+ Browser → HTTPS API → AuthZ → Parameterized query/ORM → Database
24
+ ```
25
+
26
+ ## Supabase
27
+
28
+ - Browser: anon key + **RLS enabled** on all exposed tables
29
+ - Server: service-role key only for admin tasks
30
+ - **Manual review required:** RLS policies for every table
31
+
32
+ ## Firebase
33
+
34
+ - Browser: client SDK + Security Rules
35
+ - Server: Admin SDK only
36
+ - **Manual review required:** Firestore/Storage rules
37
+
38
+ ## Audit checklist
39
+
40
+ - [ ] No DB queries or drivers in client code (TG-DB-001, TG-DB-003)
41
+ - [ ] No connection strings or service-role keys in bundle (TG-DB-002)
42
+ - [ ] All mutations authorized server-side
43
+ - [ ] Supabase RLS / Firebase rules reviewed and tested
44
+
45
+ ## Framework guides
46
+
47
+ - [Supabase](../../guides/supabase-security.md)
48
+ - [Firebase](../../guides/firebase-security.md)
49
+ - [React/Vite](../../guides/react-vite-security.md)
50
+
51
+ ## Related rules
52
+
53
+ TG-SEC-002, TG-AUTH-002, TG-AUTH-003
@@ -0,0 +1,12 @@
1
+ # GraphQL Security
2
+
3
+ - Resolver-level authentication and authorization.
4
+ - Query depth limits.
5
+ - Query complexity limits.
6
+ - Pagination and page-size caps.
7
+ - Batching controls.
8
+ - Introspection policy.
9
+ - Aliases and recursive relationships.
10
+ - Error sanitization.
11
+ - Sensitive field exposure.
12
+ - Data-loader and N+1 concerns as resource risks.
@@ -0,0 +1,51 @@
1
+ # Input Validation and Injection Prevention
2
+
3
+ ## When to load
4
+
5
+ Load during `/TorusGuard check input`, API route reviews, or upload/webhook implementation.
6
+
7
+ ## Linked rules
8
+
9
+ - [TG-INPUT-001](../../rules/TG-INPUT-001-missing-server-validation.md) — Missing Server Validation (High)
10
+ - [TG-INPUT-002](../../rules/TG-INPUT-002-raw-sql-concatenation.md) — Raw SQL Concatenation (Critical)
11
+ - [TG-INPUT-003](../../rules/TG-INPUT-003-unsafe-html-or-code-execution.md) — Unsafe HTML/Code Execution (High)
12
+ - [TG-INPUT-004](../../rules/TG-INPUT-004-unrestricted-file-upload.md) — Unrestricted File Upload (High)
13
+
14
+ ## Hard bans
15
+
16
+ - No raw SQL concatenation with request input
17
+ - No `eval`, `Function()`, or shell execution with untrusted input
18
+ - No unsanitized user HTML via `dangerouslySetInnerHTML`
19
+ - No file upload without size, type, and authorization checks
20
+ - No trust in `req.body.role`, `isAdmin`, or `userId`
21
+
22
+ ## Safe defaults
23
+
24
+ - Validate all external input on the server: body, query, params, headers, cookies, webhooks, uploads
25
+ - Treat third-party API and **LLM output** as untrusted
26
+ - Use Zod, Joi, Yup, or Ajv schemas at route entry
27
+ - Parameterized queries or safe ORM APIs only
28
+ - Redirect URLs must use allowlists
29
+ - Uploads: MIME allowlist, size cap, server-generated filenames, storage outside web root
30
+
31
+ ## Audit checklist
32
+
33
+ - [ ] Every API route validates input (TG-INPUT-001)
34
+ - [ ] No concatenated SQL (TG-INPUT-002)
35
+ - [ ] No unsafe HTML/code execution (TG-INPUT-003)
36
+ - [ ] Upload routes restricted (TG-INPUT-004)
37
+
38
+ ## Framework notes
39
+
40
+ - **Express** — validation middleware before handlers
41
+ - **Next.js** — validate in route handlers and Server Actions
42
+ - **Supabase** — Edge Functions validate before privileged ops
43
+
44
+ ## Manual review
45
+
46
+ - Business-logic validation beyond schema (e.g., cross-field rules)
47
+ - NoSQL injection patterns in MongoDB query builders
48
+
49
+ ## Related rules
50
+
51
+ TG-AUTH-002, TG-RATE-003, TG-PLATFORM-004
@@ -0,0 +1,22 @@
1
+ # Mass Assignment and Property Authorization
2
+
3
+ - Explicit writable-field allowlists.
4
+ - DTOs or request schemas.
5
+ - Separate user-editable and server-managed fields.
6
+ - Server-side assignment for role, balance, status, ownership, and verification.
7
+ - Authorization checks for sensitive individual properties.
8
+ - Tests that submit unexpected fields.
9
+
10
+ ## Unsafe
11
+ ```javascript
12
+ await User.update(req.body, { where: { id: req.user.id } });
13
+ ```
14
+
15
+ ## Safe
16
+ ```javascript
17
+ const input = updateProfileSchema.parse(req.body);
18
+ await User.update(
19
+ { displayName: input.displayName, avatarUrl: input.avatarUrl },
20
+ { where: { id: req.user.id } }
21
+ );
22
+ ```