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.
- package/.torusguard/.manifest.json +95 -0
- package/.torusguard/ARCHITECTURE.md +168 -0
- package/.torusguard/TORUSGUARD.md +145 -0
- package/.torusguard/agents/auditor.md +41 -0
- package/.torusguard/agents/profiler.md +49 -0
- package/.torusguard/agents/remediator.md +41 -0
- package/.torusguard/agents/reviewer.md +39 -0
- package/.torusguard/agents/validator.md +46 -0
- package/.torusguard/config/scope.json +24 -0
- package/.torusguard/config/slash-commands.json +102 -0
- package/.torusguard/config/torusguard.json +30 -0
- package/.torusguard/references/django-security.md +43 -0
- package/.torusguard/references/drf-security.md +20 -0
- package/.torusguard/references/express-security.md +103 -0
- package/.torusguard/references/fastapi-security.md +20 -0
- package/.torusguard/references/firebase-security.md +78 -0
- package/.torusguard/references/flask-security.md +20 -0
- package/.torusguard/references/nextjs-security.md +96 -0
- package/.torusguard/references/react-vite-security.md +97 -0
- package/.torusguard/references/sqlalchemy-security.md +16 -0
- package/.torusguard/references/supabase-security.md +84 -0
- package/.torusguard/rules/README.md +62 -0
- package/.torusguard/rules/TORUSGUARD.md +145 -0
- package/.torusguard/rules/active/.gitkeep +0 -0
- package/.torusguard/rules/active/TG-DIFF-001.md +20 -0
- package/.torusguard/rules/active/TG-DIFF-002.md +20 -0
- package/.torusguard/rules/active/TG-DIFF-003.md +19 -0
- package/.torusguard/runs/.gitkeep +0 -0
- package/.torusguard/schemas/authorization.schema.json +81 -0
- package/.torusguard/schemas/confidence.schema.json +72 -0
- package/.torusguard/schemas/evidence.schema.json +66 -0
- package/.torusguard/schemas/finding.schema.json +164 -0
- package/.torusguard/schemas/provenance.schema.json +46 -0
- package/.torusguard/schemas/remediation.schema.json +59 -0
- package/.torusguard/schemas/retest.schema.json +53 -0
- package/.torusguard/schemas/runtime-evidence.schema.json +72 -0
- package/.torusguard/scripts/__pycache__/diff_guard.cpython-311.pyc +0 -0
- package/.torusguard/scripts/__pycache__/monorepo_detector.cpython-311.pyc +0 -0
- package/.torusguard/scripts/diff_guard.py +171 -0
- package/.torusguard/scripts/finding_scorer.py +86 -0
- package/.torusguard/scripts/manifest_builder.py +130 -0
- package/.torusguard/scripts/monorepo_detector.py +164 -0
- package/.torusguard/scripts/run_manager.py +89 -0
- package/.torusguard/scripts/safety_gate.py +64 -0
- package/.torusguard/scripts/sarif_exporter.py +116 -0
- package/.torusguard/scripts/stack_detect.py +152 -0
- package/.torusguard/skills/torusguard/SKILL.md +37 -0
- package/.torusguard/skills/torusguard/bootstrap.py +158 -0
- package/.torusguard/skills/torusguard/references/auth-and-sessions.md +56 -0
- package/.torusguard/skills/torusguard/references/business-logic-and-abuse.md +23 -0
- package/.torusguard/skills/torusguard/references/cache-and-sensitive-responses.md +10 -0
- package/.torusguard/skills/torusguard/references/client-code-exposure.md +55 -0
- package/.torusguard/skills/torusguard/references/csrf-and-cross-origin.md +11 -0
- package/.torusguard/skills/torusguard/references/dependency-and-supply-chain.md +22 -0
- package/.torusguard/skills/torusguard/references/django-security.md +43 -0
- package/.torusguard/skills/torusguard/references/drf-security.md +20 -0
- package/.torusguard/skills/torusguard/references/fastapi-security.md +20 -0
- package/.torusguard/skills/torusguard/references/flask-security.md +20 -0
- package/.torusguard/skills/torusguard/references/frontend-no-db.md +53 -0
- package/.torusguard/skills/torusguard/references/graphql-security.md +12 -0
- package/.torusguard/skills/torusguard/references/input-and-injection.md +51 -0
- package/.torusguard/skills/torusguard/references/mass-assignment-and-property-auth.md +22 -0
- package/.torusguard/skills/torusguard/references/platform-hardening.md +56 -0
- package/.torusguard/skills/torusguard/references/python-dependencies.md +16 -0
- package/.torusguard/skills/torusguard/references/python-security-overview.md +12 -0
- package/.torusguard/skills/torusguard/references/rate-limit-and-abuse.md +57 -0
- package/.torusguard/skills/torusguard/references/secrets-and-config.md +64 -0
- package/.torusguard/skills/torusguard/references/sqlalchemy-security.md +16 -0
- package/.torusguard/skills/torusguard/references/ssrf-and-outbound-requests.md +46 -0
- package/.torusguard/skills/torusguard/references/webhook-security.md +15 -0
- package/.torusguard/skills/torusguard/references/websocket-security.md +12 -0
- package/.torusguard/skills/torusguard-apply/SKILL.md +46 -0
- package/.torusguard/skills/torusguard-audit/SKILL.md +70 -0
- package/.torusguard/skills/torusguard-authorize/SKILL.md +47 -0
- package/.torusguard/skills/torusguard-exploit-check/SKILL.md +64 -0
- package/.torusguard/skills/torusguard-full/SKILL.md +70 -0
- package/.torusguard/skills/torusguard-harden/SKILL.md +63 -0
- package/.torusguard/skills/torusguard-init/SKILL.md +52 -0
- package/.torusguard/skills/torusguard-recheck/SKILL.md +53 -0
- package/.torusguard/skills/torusguard-report/SKILL.md +54 -0
- package/.torusguard/skills/torusguard-status/SKILL.md +42 -0
- package/.torusguard/skills/torusguard-verify/SKILL.md +55 -0
- package/.torusguard/skills/torusguard-web-validate/SKILL.md +64 -0
- package/.torusguard/templates/audit-report.template.md +54 -0
- package/.torusguard/templates/authorization.template.md +34 -0
- package/.torusguard/templates/finding-card.template.md +32 -0
- package/.torusguard/templates/remediation-bundle.template.md +35 -0
- package/.torusguard/workflows/apply.md +95 -0
- package/.torusguard/workflows/audit.md +93 -0
- package/.torusguard/workflows/authorize.md +95 -0
- package/.torusguard/workflows/exploit-check.md +97 -0
- package/.torusguard/workflows/harden.md +93 -0
- package/.torusguard/workflows/init.md +95 -0
- package/.torusguard/workflows/recheck.md +95 -0
- package/.torusguard/workflows/report.md +95 -0
- package/.torusguard/workflows/status.md +95 -0
- package/.torusguard/workflows/verify.md +95 -0
- package/.torusguard/workflows/web-validate.md +95 -0
- package/LICENSE +21 -0
- package/README.md +319 -0
- package/bin/torusguard.js +110 -0
- package/install.py +98 -0
- package/package.json +48 -0
- package/skills/torusguard/SKILL.md +41 -0
- package/skills/torusguard/__pycache__/bootstrap.cpython-311.pyc +0 -0
- package/skills/torusguard/bootstrap.py +256 -0
- package/skills/torusguard/payload/.manifest.json +95 -0
- package/skills/torusguard/payload/ARCHITECTURE.md +168 -0
- package/skills/torusguard/payload/TORUSGUARD.md +145 -0
- package/skills/torusguard/payload/agents/auditor.md +41 -0
- package/skills/torusguard/payload/agents/profiler.md +49 -0
- package/skills/torusguard/payload/agents/remediator.md +41 -0
- package/skills/torusguard/payload/agents/reviewer.md +39 -0
- package/skills/torusguard/payload/agents/validator.md +46 -0
- package/skills/torusguard/payload/config/scope.json +24 -0
- package/skills/torusguard/payload/config/slash-commands.json +102 -0
- package/skills/torusguard/payload/config/torusguard.json +30 -0
- package/skills/torusguard/payload/references/django-security.md +43 -0
- package/skills/torusguard/payload/references/drf-security.md +20 -0
- package/skills/torusguard/payload/references/express-security.md +103 -0
- package/skills/torusguard/payload/references/fastapi-security.md +20 -0
- package/skills/torusguard/payload/references/firebase-security.md +78 -0
- package/skills/torusguard/payload/references/flask-security.md +20 -0
- package/skills/torusguard/payload/references/nextjs-security.md +96 -0
- package/skills/torusguard/payload/references/react-vite-security.md +97 -0
- package/skills/torusguard/payload/references/sqlalchemy-security.md +16 -0
- package/skills/torusguard/payload/references/supabase-security.md +84 -0
- package/skills/torusguard/payload/rules/README.md +62 -0
- package/skills/torusguard/payload/rules/TORUSGUARD.md +145 -0
- package/skills/torusguard/payload/rules/active/.gitkeep +0 -0
- package/skills/torusguard/payload/rules/active/TG-DIFF-001.md +20 -0
- package/skills/torusguard/payload/rules/active/TG-DIFF-002.md +20 -0
- package/skills/torusguard/payload/rules/active/TG-DIFF-003.md +19 -0
- package/skills/torusguard/payload/schemas/authorization.schema.json +81 -0
- package/skills/torusguard/payload/schemas/confidence.schema.json +72 -0
- package/skills/torusguard/payload/schemas/evidence.schema.json +66 -0
- package/skills/torusguard/payload/schemas/finding.schema.json +164 -0
- package/skills/torusguard/payload/schemas/provenance.schema.json +46 -0
- package/skills/torusguard/payload/schemas/remediation.schema.json +59 -0
- package/skills/torusguard/payload/schemas/retest.schema.json +53 -0
- package/skills/torusguard/payload/schemas/runtime-evidence.schema.json +72 -0
- package/skills/torusguard/payload/scripts/diff_guard.py +171 -0
- package/skills/torusguard/payload/scripts/finding_scorer.py +86 -0
- package/skills/torusguard/payload/scripts/manifest_builder.py +130 -0
- package/skills/torusguard/payload/scripts/monorepo_detector.py +164 -0
- package/skills/torusguard/payload/scripts/run_manager.py +89 -0
- package/skills/torusguard/payload/scripts/safety_gate.py +64 -0
- package/skills/torusguard/payload/scripts/sarif_exporter.py +116 -0
- package/skills/torusguard/payload/scripts/stack_detect.py +152 -0
- package/skills/torusguard/payload/skills/torusguard/SKILL.md +37 -0
- package/skills/torusguard/payload/skills/torusguard/bootstrap.py +158 -0
- package/skills/torusguard/payload/skills/torusguard/references/auth-and-sessions.md +56 -0
- package/skills/torusguard/payload/skills/torusguard/references/business-logic-and-abuse.md +23 -0
- package/skills/torusguard/payload/skills/torusguard/references/cache-and-sensitive-responses.md +10 -0
- package/skills/torusguard/payload/skills/torusguard/references/client-code-exposure.md +55 -0
- package/skills/torusguard/payload/skills/torusguard/references/csrf-and-cross-origin.md +11 -0
- package/skills/torusguard/payload/skills/torusguard/references/dependency-and-supply-chain.md +22 -0
- package/skills/torusguard/payload/skills/torusguard/references/django-security.md +43 -0
- package/skills/torusguard/payload/skills/torusguard/references/drf-security.md +20 -0
- package/skills/torusguard/payload/skills/torusguard/references/fastapi-security.md +20 -0
- package/skills/torusguard/payload/skills/torusguard/references/flask-security.md +20 -0
- package/skills/torusguard/payload/skills/torusguard/references/frontend-no-db.md +53 -0
- package/skills/torusguard/payload/skills/torusguard/references/graphql-security.md +12 -0
- package/skills/torusguard/payload/skills/torusguard/references/input-and-injection.md +51 -0
- package/skills/torusguard/payload/skills/torusguard/references/mass-assignment-and-property-auth.md +22 -0
- package/skills/torusguard/payload/skills/torusguard/references/platform-hardening.md +56 -0
- package/skills/torusguard/payload/skills/torusguard/references/python-dependencies.md +16 -0
- package/skills/torusguard/payload/skills/torusguard/references/python-security-overview.md +12 -0
- package/skills/torusguard/payload/skills/torusguard/references/rate-limit-and-abuse.md +57 -0
- package/skills/torusguard/payload/skills/torusguard/references/secrets-and-config.md +64 -0
- package/skills/torusguard/payload/skills/torusguard/references/sqlalchemy-security.md +16 -0
- package/skills/torusguard/payload/skills/torusguard/references/ssrf-and-outbound-requests.md +46 -0
- package/skills/torusguard/payload/skills/torusguard/references/webhook-security.md +15 -0
- package/skills/torusguard/payload/skills/torusguard/references/websocket-security.md +12 -0
- package/skills/torusguard/payload/skills/torusguard-apply/SKILL.md +46 -0
- package/skills/torusguard/payload/skills/torusguard-audit/SKILL.md +70 -0
- package/skills/torusguard/payload/skills/torusguard-authorize/SKILL.md +47 -0
- package/skills/torusguard/payload/skills/torusguard-exploit-check/SKILL.md +64 -0
- package/skills/torusguard/payload/skills/torusguard-full/SKILL.md +70 -0
- package/skills/torusguard/payload/skills/torusguard-harden/SKILL.md +63 -0
- package/skills/torusguard/payload/skills/torusguard-init/SKILL.md +52 -0
- package/skills/torusguard/payload/skills/torusguard-recheck/SKILL.md +53 -0
- package/skills/torusguard/payload/skills/torusguard-report/SKILL.md +54 -0
- package/skills/torusguard/payload/skills/torusguard-status/SKILL.md +42 -0
- package/skills/torusguard/payload/skills/torusguard-verify/SKILL.md +55 -0
- package/skills/torusguard/payload/skills/torusguard-web-validate/SKILL.md +64 -0
- package/skills/torusguard/payload/templates/audit-report.template.md +54 -0
- package/skills/torusguard/payload/templates/authorization.template.md +34 -0
- package/skills/torusguard/payload/templates/finding-card.template.md +32 -0
- package/skills/torusguard/payload/templates/remediation-bundle.template.md +35 -0
- package/skills/torusguard/payload/workflows/apply.md +95 -0
- package/skills/torusguard/payload/workflows/audit.md +93 -0
- package/skills/torusguard/payload/workflows/authorize.md +95 -0
- package/skills/torusguard/payload/workflows/exploit-check.md +97 -0
- package/skills/torusguard/payload/workflows/harden.md +93 -0
- package/skills/torusguard/payload/workflows/init.md +95 -0
- package/skills/torusguard/payload/workflows/recheck.md +95 -0
- package/skills/torusguard/payload/workflows/report.md +95 -0
- package/skills/torusguard/payload/workflows/status.md +95 -0
- package/skills/torusguard/payload/workflows/verify.md +95 -0
- package/skills/torusguard/payload/workflows/web-validate.md +95 -0
- package/skills/torusguard/references/auth-and-sessions.md +56 -0
- package/skills/torusguard/references/business-logic-and-abuse.md +23 -0
- package/skills/torusguard/references/cache-and-sensitive-responses.md +10 -0
- package/skills/torusguard/references/client-code-exposure.md +55 -0
- package/skills/torusguard/references/csrf-and-cross-origin.md +11 -0
- package/skills/torusguard/references/dependency-and-supply-chain.md +22 -0
- package/skills/torusguard/references/django-security.md +43 -0
- package/skills/torusguard/references/drf-security.md +20 -0
- package/skills/torusguard/references/fastapi-security.md +20 -0
- package/skills/torusguard/references/flask-security.md +20 -0
- package/skills/torusguard/references/frontend-no-db.md +53 -0
- package/skills/torusguard/references/graphql-security.md +12 -0
- package/skills/torusguard/references/input-and-injection.md +51 -0
- package/skills/torusguard/references/mass-assignment-and-property-auth.md +22 -0
- package/skills/torusguard/references/platform-hardening.md +56 -0
- package/skills/torusguard/references/python-dependencies.md +16 -0
- package/skills/torusguard/references/python-security-overview.md +12 -0
- package/skills/torusguard/references/rate-limit-and-abuse.md +57 -0
- package/skills/torusguard/references/secrets-and-config.md +64 -0
- package/skills/torusguard/references/sqlalchemy-security.md +16 -0
- package/skills/torusguard/references/ssrf-and-outbound-requests.md +46 -0
- package/skills/torusguard/references/webhook-security.md +15 -0
- package/skills/torusguard/references/websocket-security.md +12 -0
- package/skills/torusguard-apply/SKILL.md +46 -0
- package/skills/torusguard-audit/SKILL.md +70 -0
- package/skills/torusguard-authorize/SKILL.md +47 -0
- package/skills/torusguard-exploit-check/SKILL.md +64 -0
- package/skills/torusguard-full/SKILL.md +70 -0
- package/skills/torusguard-harden/SKILL.md +63 -0
- package/skills/torusguard-init/SKILL.md +52 -0
- package/skills/torusguard-recheck/SKILL.md +53 -0
- package/skills/torusguard-report/SKILL.md +54 -0
- package/skills/torusguard-status/SKILL.md +42 -0
- package/skills/torusguard-verify/SKILL.md +55 -0
- package/skills/torusguard-web-validate/SKILL.md +64 -0
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
# Platform and HTTP Hardening
|
|
2
|
+
|
|
3
|
+
## When to load
|
|
4
|
+
|
|
5
|
+
Load during `/TorusGuard check platform`, deployment prep, or `/TorusGuard verify`.
|
|
6
|
+
|
|
7
|
+
## Linked rules
|
|
8
|
+
|
|
9
|
+
- [TG-PLATFORM-001](../../rules/TG-PLATFORM-001-wildcard-cors-with-credentials.md) โ Wildcard CORS + Credentials (High)
|
|
10
|
+
- [TG-PLATFORM-002](../../rules/TG-PLATFORM-002-missing-security-headers.md) โ Missing Security Headers (Medium)
|
|
11
|
+
- [TG-PLATFORM-003](../../rules/TG-PLATFORM-003-production-stack-trace-exposure.md) โ Stack Trace Exposure (Medium)
|
|
12
|
+
- [TG-PLATFORM-004](../../rules/TG-PLATFORM-004-missing-request-size-limits.md) โ Missing Request Size Limits (Medium)
|
|
13
|
+
|
|
14
|
+
## Hard bans
|
|
15
|
+
|
|
16
|
+
- No `Access-Control-Allow-Origin: *` with credentials
|
|
17
|
+
- No production stack traces or raw DB errors to clients
|
|
18
|
+
- No debug mode in production
|
|
19
|
+
- No missing body limits on public JSON endpoints
|
|
20
|
+
- No executable uploads in public web directories
|
|
21
|
+
|
|
22
|
+
## Safe defaults
|
|
23
|
+
|
|
24
|
+
- CORS explicit allowlist
|
|
25
|
+
- Helmet or equivalent: CSP, `X-Content-Type-Options`, HSTS (production), `Referrer-Policy`, clickjacking protection
|
|
26
|
+
- Generic user-facing errors; detailed logs server-side with request ID
|
|
27
|
+
- HTTPS enforced in production
|
|
28
|
+
- `express.json({ limit: '100kb' })` or appropriate caps
|
|
29
|
+
- Dependency audit before deploy
|
|
30
|
+
|
|
31
|
+
## Audit checklist
|
|
32
|
+
|
|
33
|
+
- [ ] CORS allowlist (TG-PLATFORM-001)
|
|
34
|
+
- [ ] Security headers configured (TG-PLATFORM-002)
|
|
35
|
+
- [ ] Errors sanitized (TG-PLATFORM-003)
|
|
36
|
+
- [ ] Request/upload limits set (TG-PLATFORM-004)
|
|
37
|
+
|
|
38
|
+
## Framework notes
|
|
39
|
+
|
|
40
|
+
- **Express** โ Helmet + central error handler
|
|
41
|
+
- **Next.js** โ headers in `next.config` or middleware
|
|
42
|
+
- **Reverse proxy** โ TLS termination, HSTS, rate limits
|
|
43
|
+
|
|
44
|
+
## Manual review
|
|
45
|
+
|
|
46
|
+
- CSP compatibility with actual script/style sources
|
|
47
|
+
- Infrastructure firewall and WAF rules
|
|
48
|
+
- Backup and monitoring configuration
|
|
49
|
+
|
|
50
|
+
## Related rules
|
|
51
|
+
|
|
52
|
+
TG-RATE-003, TG-SEC-004, TG-CLIENT-001
|
|
53
|
+
|
|
54
|
+
## Framework guide
|
|
55
|
+
|
|
56
|
+
[Express Security](../../guides/express-security.md)
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# TorusGuard Skill Reference: Python Dependencies and Supply Chain
|
|
2
|
+
|
|
3
|
+
> **Loaded When:** Python dependency manifests (`requirements.txt`, `pyproject.toml`, `Pipfile`, `poetry.lock`, `uv.lock`) or `.github/workflows/*.yml` are detected.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## ๐ก๏ธ Key Inspection Areas & Rules
|
|
8
|
+
|
|
9
|
+
### 1. Lockfile Integrity
|
|
10
|
+
* `TG-SUPPLY-001`: Verify that deterministic lockfiles exist alongside manifests and are not excluded in `.gitignore`.
|
|
11
|
+
|
|
12
|
+
### 2. Known CVE Vulnerability Auditing
|
|
13
|
+
* `TG-SUPPLY-002`: Check for vulnerable dependencies using `pip-audit`. Avoid recommending blind major-version upgrades that introduce breaking changes without tests.
|
|
14
|
+
|
|
15
|
+
### 3. CI/CD Workflow Hardening
|
|
16
|
+
* `TG-SUPPLY-004`: Inspect `.github/workflows/*.yml` for unpinned 3rd-party actions and overbroad default permissions.
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
# TorusGuard Skill Reference: Python Security Overview
|
|
2
|
+
|
|
3
|
+
> **Loaded When:** Any Python project is detected (`requirements.txt`, `pyproject.toml`, `Pipfile`, `.py` source files).
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## ๐ Python Platform Security Principles
|
|
8
|
+
|
|
9
|
+
1. **Explicit Boundaries Over Dynamic Magic:** Avoid unpacking arbitrary user dictionaries directly into database ORM models or data structures (`**req.dict()`, `**request.json`).
|
|
10
|
+
2. **Server-Side Authorization First:** Route decorators (`@login_required`) verify identity, but database queries must verify resource ownership (`user_id == current_user.id`).
|
|
11
|
+
3. **Outbound Request Bounding (SSRF):** Always validate scheme, resolve DNS, and block private CIDR blocks before calling `requests.get()` or `httpx.get()`.
|
|
12
|
+
4. **Deterministic Environments:** Always maintain virtual environment isolation and commit cryptographically verifiable lockfiles (`poetry.lock`, `uv.lock`, `requirements.lock`).
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
# Rate Limiting and Abuse Prevention
|
|
2
|
+
|
|
3
|
+
## When to load
|
|
4
|
+
|
|
5
|
+
Load during `/TorusGuard check rate-limit`, auth endpoint reviews, or public API design.
|
|
6
|
+
|
|
7
|
+
## Linked rules
|
|
8
|
+
|
|
9
|
+
- [TG-RATE-001](../../rules/TG-RATE-001-unlimited-auth-endpoint.md) โ Unlimited Auth Endpoint (High)
|
|
10
|
+
- [TG-RATE-002](../../rules/TG-RATE-002-unlimited-public-write-endpoint.md) โ Unlimited Public Write (Medium)
|
|
11
|
+
- [TG-RATE-003](../../rules/TG-RATE-003-unbounded-resource-consumption.md) โ Unbounded Resource Use (High)
|
|
12
|
+
|
|
13
|
+
## Hard bans
|
|
14
|
+
|
|
15
|
+
- Never rely only on frontend throttling
|
|
16
|
+
- Never leave login, reset, OTP, or contact endpoints unlimited in production
|
|
17
|
+
- Never use in-memory-only rate limits as sole protection in distributed production
|
|
18
|
+
|
|
19
|
+
## Configurable default limits
|
|
20
|
+
|
|
21
|
+
| Endpoint | Suggested starting point |
|
|
22
|
+
|----------|-------------------------|
|
|
23
|
+
| Login | 5 / IP / 15 min + account backoff |
|
|
24
|
+
| Password reset | 3 / email / hour |
|
|
25
|
+
| OTP | 3 / identifier / 15 min |
|
|
26
|
+
| Contact/feedback | 5 / IP / hour |
|
|
27
|
+
| Public API | 60 / IP / minute |
|
|
28
|
+
| Search | 30 / IP / minute |
|
|
29
|
+
| Upload | 10 / IP / hour + size limits |
|
|
30
|
+
| AI/LLM | Per-user and per-IP cost limits |
|
|
31
|
+
|
|
32
|
+
Adjust for your traffic profile โ these are defaults, not universal values.
|
|
33
|
+
|
|
34
|
+
## Safe defaults
|
|
35
|
+
|
|
36
|
+
- Per-IP limits on public endpoints
|
|
37
|
+
- Per-account limits on auth flows
|
|
38
|
+
- HTTP 429 with `Retry-After` when practical
|
|
39
|
+
- Body, upload, and pagination caps (TG-RATE-003)
|
|
40
|
+
- Timeouts and concurrency limits on expensive endpoints
|
|
41
|
+
- Shared store (Redis) for multi-instance deployments
|
|
42
|
+
|
|
43
|
+
## Audit checklist
|
|
44
|
+
|
|
45
|
+
- [ ] Auth endpoints rate-limited (TG-RATE-001)
|
|
46
|
+
- [ ] Public write/AI endpoints protected (TG-RATE-002)
|
|
47
|
+
- [ ] Body/upload/pagination limits set (TG-RATE-003)
|
|
48
|
+
|
|
49
|
+
## Manual review
|
|
50
|
+
|
|
51
|
+
- Webhook endpoints (signature + IP limits)
|
|
52
|
+
- GraphQL complexity/depth limits
|
|
53
|
+
- Spend alerts for metered third-party APIs
|
|
54
|
+
|
|
55
|
+
## Related rules
|
|
56
|
+
|
|
57
|
+
TG-AUTH-005, TG-PLATFORM-004, TG-INPUT-004
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
# Secrets and Environment Configuration
|
|
2
|
+
|
|
3
|
+
## When to load
|
|
4
|
+
|
|
5
|
+
Load during `/TorusGuard check secrets`, secret-related audits, or before adding environment variables, CI config, or deployment secrets.
|
|
6
|
+
|
|
7
|
+
## Linked rules
|
|
8
|
+
|
|
9
|
+
- [TG-SEC-001](../../rules/TG-SEC-001-hardcoded-secrets.md) โ Hardcoded Secret (Critical)
|
|
10
|
+
- [TG-SEC-002](../../rules/TG-SEC-002-public-environment-secrets.md) โ Public Environment Secret (Critical)
|
|
11
|
+
- [TG-SEC-003](../../rules/TG-SEC-003-tracked-env-file.md) โ Tracked Environment File (High)
|
|
12
|
+
- [TG-SEC-004](../../rules/TG-SEC-004-sensitive-logging.md) โ Sensitive Data Logging (Medium)
|
|
13
|
+
|
|
14
|
+
## Hard bans
|
|
15
|
+
|
|
16
|
+
- Never hardcode database URLs, JWT secrets, passwords, or API keys in source
|
|
17
|
+
- Never expose service-role or admin credentials to the browser
|
|
18
|
+
- Never put secrets in `VITE_*`, `NEXT_PUBLIC_*`, or `REACT_APP_*` variables
|
|
19
|
+
- Never log passwords, tokens, session IDs, API keys, or full authorization headers
|
|
20
|
+
- Never commit `.env`, credentials JSON, or private key files
|
|
21
|
+
|
|
22
|
+
## Frontend env prefixes are public
|
|
23
|
+
|
|
24
|
+
| Prefix | Reaches browser? |
|
|
25
|
+
|--------|------------------|
|
|
26
|
+
| `VITE_` | Yes |
|
|
27
|
+
| `NEXT_PUBLIC_` | Yes |
|
|
28
|
+
| `REACT_APP_` | Yes |
|
|
29
|
+
| (no prefix) | Server only |
|
|
30
|
+
|
|
31
|
+
Only intentionally public configuration may use client prefixes.
|
|
32
|
+
|
|
33
|
+
## Safe defaults
|
|
34
|
+
|
|
35
|
+
1. Server-only env for all secrets
|
|
36
|
+
2. `.env` in `.gitignore`
|
|
37
|
+
3. `.env.example` with placeholder values only
|
|
38
|
+
4. Rotate/revoke any discovered leaked secret immediately
|
|
39
|
+
5. Separate dev/test/production secret stores where applicable
|
|
40
|
+
|
|
41
|
+
## Audit checklist
|
|
42
|
+
|
|
43
|
+
- [ ] No real secrets in tracked source (TG-SEC-001)
|
|
44
|
+
- [ ] No sensitive values in public env vars (TG-SEC-002)
|
|
45
|
+
- [ ] `.env` not tracked by Git (TG-SEC-003)
|
|
46
|
+
- [ ] Logs redact auth material (TG-SEC-004)
|
|
47
|
+
- [ ] `.env.example` exists with safe placeholders
|
|
48
|
+
|
|
49
|
+
## Framework notes
|
|
50
|
+
|
|
51
|
+
- **Vite/CRA/Next public vars** โ treat as published in the client bundle
|
|
52
|
+
- **Supabase** โ anon key in browser OK; service-role server-only
|
|
53
|
+
- **Firebase** โ client config public; Admin SDK credentials server-only
|
|
54
|
+
- **CI/CD** โ use platform secret stores, not plaintext in workflow files
|
|
55
|
+
|
|
56
|
+
## Manual review
|
|
57
|
+
|
|
58
|
+
- Verify secret rotation after any exposure
|
|
59
|
+
- Review CI logs for accidental secret echo
|
|
60
|
+
- Confirm production secrets differ from development
|
|
61
|
+
|
|
62
|
+
## Related rules
|
|
63
|
+
|
|
64
|
+
TG-DB-002, TG-DB-003, TG-CLIENT-002
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# TorusGuard Skill Reference: SQLAlchemy Security
|
|
2
|
+
|
|
3
|
+
> **Loaded When:** Project uses `sqlalchemy` dependencies or imports.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## ๐ก๏ธ Key Inspection Areas & Rules
|
|
8
|
+
|
|
9
|
+
### 1. SQL Injection in Raw Query Clauses
|
|
10
|
+
* `TG-INPUT-003`: Search for `text(f"...")`, `text("..." + ...)`, or `.format()` inside `text()` constructs. Ensure parameter mapping `text("... WHERE col = :val")` is used.
|
|
11
|
+
|
|
12
|
+
### 2. Tenant Scoping & Object Ownership
|
|
13
|
+
* `TG-AUTH-007`: Verify queries on tenant-isolated tables include tenant/user ID predicates in `.filter()` or `.filter_by()`.
|
|
14
|
+
|
|
15
|
+
### 3. Mass Assignment via Bulk Updates
|
|
16
|
+
* `TG-AUTH-006`: Inspect `.update(dict)` calls to ensure input dictionaries are filtered against permitted field allowlists.
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
# SSRF and Outbound Requests
|
|
2
|
+
|
|
3
|
+
## When the reference applies
|
|
4
|
+
Applies to any endpoint that fetches a URL.
|
|
5
|
+
|
|
6
|
+
## User-controlled URL detection
|
|
7
|
+
Always check if the URL is user-controlled.
|
|
8
|
+
|
|
9
|
+
## URL scheme validation
|
|
10
|
+
Only allow expected schemes.
|
|
11
|
+
|
|
12
|
+
## Hostname and IP validation
|
|
13
|
+
Validate hostnames carefully.
|
|
14
|
+
|
|
15
|
+
## Private-network blocking
|
|
16
|
+
Block internal IP addresses.
|
|
17
|
+
|
|
18
|
+
## Cloud metadata protection
|
|
19
|
+
Block 169.254.169.254 and similar.
|
|
20
|
+
|
|
21
|
+
## Redirect handling
|
|
22
|
+
Disable redirects or validate them.
|
|
23
|
+
|
|
24
|
+
## DNS rebinding considerations
|
|
25
|
+
Check DNS at resolution time.
|
|
26
|
+
|
|
27
|
+
## Timeout and response-size limits
|
|
28
|
+
Enforce timeouts and max response sizes.
|
|
29
|
+
|
|
30
|
+
## Network isolation
|
|
31
|
+
Run fetches from isolated networks if possible.
|
|
32
|
+
|
|
33
|
+
## Safe logging
|
|
34
|
+
Avoid logging raw URLs with credentials.
|
|
35
|
+
|
|
36
|
+
## Manual-review checklist
|
|
37
|
+
- [ ] Is the outbound URL user-controlled?
|
|
38
|
+
- [ ] Is HTTPS required?
|
|
39
|
+
- [ ] Is the hostname allowlisted?
|
|
40
|
+
- [ ] Are loopback and private IPs blocked?
|
|
41
|
+
- [ ] Are cloud metadata endpoints blocked?
|
|
42
|
+
- [ ] Are redirects disabled or revalidated?
|
|
43
|
+
- [ ] Is DNS resolution checked safely?
|
|
44
|
+
- [ ] Is there a timeout?
|
|
45
|
+
- [ ] Is response size limited?
|
|
46
|
+
- [ ] Is the server isolated from sensitive networks?
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# Webhook Security
|
|
2
|
+
|
|
3
|
+
- Signature verification over the raw request body.
|
|
4
|
+
- Timestamp tolerance.
|
|
5
|
+
- Replay protection.
|
|
6
|
+
- Event-type allowlisting.
|
|
7
|
+
- Payload schema validation.
|
|
8
|
+
- Idempotency keys or event IDs.
|
|
9
|
+
- Safe retry behavior.
|
|
10
|
+
- Rate and size limits.
|
|
11
|
+
- Generic response errors.
|
|
12
|
+
- No trust in event fields before signature verification.
|
|
13
|
+
|
|
14
|
+
## Workflow
|
|
15
|
+
Receive raw body โ Verify signature โ Verify timestamp โ Check event ID/idempotency โ Validate event schema โ Authorize event source/tenant โ Process within transaction โ Return safe response
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
# WebSocket Security
|
|
2
|
+
|
|
3
|
+
- Authentication during handshake.
|
|
4
|
+
- Re-authentication or token expiry.
|
|
5
|
+
- Origin validation.
|
|
6
|
+
- Per-room and per-channel authorization.
|
|
7
|
+
- Message schema validation.
|
|
8
|
+
- Message-size limits.
|
|
9
|
+
- Connection and subscription limits.
|
|
10
|
+
- Tenant isolation.
|
|
11
|
+
- Disconnect behavior.
|
|
12
|
+
- Logging and abuse detection.
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: torusguard-apply
|
|
3
|
+
description: Apply governed remediation patches to disk with pre-apply rollback snapshots and Human Gate validation.
|
|
4
|
+
version: 0.9.2
|
|
5
|
+
workflow: .torusguard/workflows/apply.md
|
|
6
|
+
tools: Read, Grep, Glob, Bash, Edit, Write
|
|
7
|
+
scripts-binding:
|
|
8
|
+
- .torusguard/scripts/run_manager.py
|
|
9
|
+
- .torusguard/scripts/diff_guard.py
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
# TorusGuard Apply โ Governed Patch Application & Rollback Snapshot
|
|
13
|
+
|
|
14
|
+
## Objective
|
|
15
|
+
Safely apply approved remediation bundles to disk source files, capturing a byte-for-byte pre-apply backup snapshot and asserting syntax validity post-patch.
|
|
16
|
+
|
|
17
|
+
---
|
|
18
|
+
|
|
19
|
+
## Execution Steps
|
|
20
|
+
|
|
21
|
+
1. **Load Bundle:** Read `patch.diff` and metadata from `.torusguard/runs/<run_id>/remediation/<finding_id>/`.
|
|
22
|
+
2. **Pre-Apply Snapshot:** Save exact backup to `.torusguard/runs/<run_id>/pre_apply/<filename>.bak`.
|
|
23
|
+
3. **Obtain Human Gate:** Confirm user approval for proposed diff.
|
|
24
|
+
4. **Apply Patch:** Execute surgical modification using `replace_file_content` or `patch`.
|
|
25
|
+
5. **Assert Integrity:** Verify modified file compiles cleanly without syntax errors.
|
|
26
|
+
6. **Record Ledger:** Log timestamp, file path, and post-patch SHA-256 in `apply-log.json`.
|
|
27
|
+
|
|
28
|
+
---
|
|
29
|
+
|
|
30
|
+
## Governance & Safety Rules
|
|
31
|
+
- Hard limit: additions $\le 35$, deletions $\le 25$ lines.
|
|
32
|
+
- Always create a rollback snapshot before modifying disk code.
|
|
33
|
+
- If compile or syntax error occurs, instantly restore from `.bak`.
|
|
34
|
+
- Require explicit operator confirmation before writing changes.
|
|
35
|
+
|
|
36
|
+
---
|
|
37
|
+
|
|
38
|
+
## Output Format
|
|
39
|
+
```markdown
|
|
40
|
+
๐ [TorusGuard] Patch Applied Successfully
|
|
41
|
+
- Finding Target: <Finding ID> | File: <Path>
|
|
42
|
+
- Churn: +<Additions> / -<Deletions>
|
|
43
|
+
- Rollback Backup: `.torusguard/runs/<run_id>/pre_apply/<file>.bak`
|
|
44
|
+
- Compile Check: PASSED
|
|
45
|
+
Next: Run `/torusguard recheck` to verify vulnerability is closed.
|
|
46
|
+
```
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: torusguard-audit
|
|
3
|
+
description: Static security AST scanning, stable fingerprinting, root-cause clustering, and 0โ100 confidence scoring.
|
|
4
|
+
version: 0.9.2
|
|
5
|
+
workflow: .torusguard/workflows/audit.md
|
|
6
|
+
tools: Read, Grep, Glob, Write
|
|
7
|
+
scripts-binding:
|
|
8
|
+
- .torusguard/scripts/finding_scorer.py
|
|
9
|
+
- .torusguard/scripts/run_manager.py
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
# TorusGuard Audit โ Static Code Analysis & Finding Clustering
|
|
13
|
+
|
|
14
|
+
## Objective
|
|
15
|
+
Execute static analysis across ASTs, generate line-shift invariant fingerprints, group findings into root causes, compute 0โ100 confidence scores, and persist findings to `.torusguard/runs/`.
|
|
16
|
+
|
|
17
|
+
---
|
|
18
|
+
|
|
19
|
+
## Execution Steps
|
|
20
|
+
|
|
21
|
+
1. **Setup Run Directory:** Initialize `.torusguard/runs/run-YYYYMMDD-HHMMSS-audit/` via `run_manager.py`.
|
|
22
|
+
2. **Load Active Rules:** Load rules from `.torusguard/rules/active/` and thresholds from `torusguard.json`.
|
|
23
|
+
3. **AST Scan Sinks:** Match files against active rules:
|
|
24
|
+
- `TG-SEC-*`: Leaked API keys, secrets.
|
|
25
|
+
- `TG-INPUT-*`: Unescaped SQL or unvalidated payloads.
|
|
26
|
+
- `TG-DB-*`: Unscoped queries omitting tenant filters (`Model.get(id=id)`).
|
|
27
|
+
- `TG-AUTH-*`: Missing `HttpOnly`/`Secure` flags; open CORS.
|
|
28
|
+
- `TG-CLIENT-*`: Admin credentials in client bundles.
|
|
29
|
+
4. **Stable Fingerprinting:** Compute SHA-256 hash of normalized 3 surrounding AST lines.
|
|
30
|
+
5. **Root-Cause Clustering:** Group findings by root cause (`cluster-tenant-isolation`, `cluster-raw-sql-sink`).
|
|
31
|
+
6. **Confidence Scoring:** Calculate 0โ100 score across 5-factor rubric via `finding_scorer.py`.
|
|
32
|
+
7. **Write Run Artifacts:** Persist `findings.md`, `findings.json`, and `summary.md`.
|
|
33
|
+
|
|
34
|
+
---
|
|
35
|
+
|
|
36
|
+
## Confidence Scoring Rubric
|
|
37
|
+
- **1. Evidence (35):** AST flow (35), regex match (20), indirect (10).
|
|
38
|
+
- **2. Reproduction (25):** Deterministic test (25), simulated (15), hypothesis (0).
|
|
39
|
+
- **3. Corroboration (15):** >=3 files (15), 2 files (10), single (5).
|
|
40
|
+
- **4. Environment (15):** Explicit route (15), minor ambiguity (8), unknown (0).
|
|
41
|
+
- **5. Review Status (10):** Human verified (10), agent consensus (5), auto (0).
|
|
42
|
+
- **Bands:** 90โ100 (`Confirmed`), 70โ89 (`High`), 50โ69 (`Medium`), <50 (`Review`).
|
|
43
|
+
|
|
44
|
+
---
|
|
45
|
+
|
|
46
|
+
## Finding Card Format
|
|
47
|
+
```markdown
|
|
48
|
+
### [TG-DB-004] Missing Tenant Scoping in /invoices/
|
|
49
|
+
- **Severity**: High | **Confidence**: 90/100 (Confirmed)
|
|
50
|
+
- **File**: `views.py:42` | **Cluster**: `cluster-tenant-isolation`
|
|
51
|
+
- **Evidence**: Unscoped query leaks records.
|
|
52
|
+
- **Remediation**: Scope by `tenant=request.user.tenant`.
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
---
|
|
56
|
+
|
|
57
|
+
## Safety Constraints
|
|
58
|
+
- Read-only execution; zero code modifications.
|
|
59
|
+
- Exclude build folders (`node_modules/`, `.venv/`, `dist/`).
|
|
60
|
+
- Redact secrets before saving to `findings.md`.
|
|
61
|
+
|
|
62
|
+
---
|
|
63
|
+
|
|
64
|
+
## Output Format
|
|
65
|
+
```markdown
|
|
66
|
+
๐ก๏ธ [TorusGuard] Static Code Audit Completed
|
|
67
|
+
- Run ID: run-YYYYMMDD-HHMMSS-audit | Files: <Count> | Findings: <Count>
|
|
68
|
+
- Clusters: <Count> identified | Posture: ACTION REQUIRED
|
|
69
|
+
Next: Run `/torusguard harden` to formulate surgical fixes.
|
|
70
|
+
```
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: torusguard-authorize
|
|
3
|
+
description: Register and validate runtime target authorization boundaries โ scope boundaries, ownership proofs, TTL expiration, and Safety Gate enforcement.
|
|
4
|
+
version: 0.9.2
|
|
5
|
+
workflow: .torusguard/workflows/authorize.md
|
|
6
|
+
tools: Read, Grep, Glob, Write
|
|
7
|
+
scripts-binding:
|
|
8
|
+
- .torusguard/scripts/safety_gate.py
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
# TorusGuard Authorize โ Legal Scope & Safety Gate Registration
|
|
12
|
+
|
|
13
|
+
## Objective
|
|
14
|
+
Define and validate legal runtime authorization boundaries, verify target ownership, enforce maximum rate limits, and persist a cryptographically auditable `.torusguard/config/scope.json`.
|
|
15
|
+
|
|
16
|
+
---
|
|
17
|
+
|
|
18
|
+
## Execution Steps
|
|
19
|
+
|
|
20
|
+
1. **Capture Scope Parameters:** Collect target host URL, allowed path prefixes, forbidden prefixes, and session TTL.
|
|
21
|
+
2. **Validate Environment:** Assert target is local (`localhost`, `127.0.0.1`) or staging (`*.staging.*`). Block production targets without explicit override.
|
|
22
|
+
3. **Verify Host Ownership:** Confirm ownership token or local process socket binding.
|
|
23
|
+
4. **Invoke Safety Gate:**
|
|
24
|
+
```bash
|
|
25
|
+
python .torusguard/scripts/safety_gate.py check --url <target_url>
|
|
26
|
+
```
|
|
27
|
+
5. **Write Scope Record:** Persist authorized targets, rate limits, and expiration timestamp into `.torusguard/config/scope.json`.
|
|
28
|
+
6. **Validate Schema:** Confirm `scope.json` adheres to `auth-boundary.schema.json`.
|
|
29
|
+
|
|
30
|
+
---
|
|
31
|
+
|
|
32
|
+
## Safety Constraints
|
|
33
|
+
- Never authorize wildcard hosts (`*`) or third-party domains.
|
|
34
|
+
- State-changing destructive actions (`DELETE`, bulk drops) are disabled by default.
|
|
35
|
+
- Set strict TTL (default 4 hours, maximum 24 hours).
|
|
36
|
+
|
|
37
|
+
---
|
|
38
|
+
|
|
39
|
+
## Output Format
|
|
40
|
+
```markdown
|
|
41
|
+
๐ [TorusGuard] Target Scope Authorized
|
|
42
|
+
- Target Host: <Host URL> | Environment: <Local / Staging>
|
|
43
|
+
- Allowed Paths: <Prefixes> | Rate Limit: <Max Req/sec>
|
|
44
|
+
- Expiration TTL: <Timestamp>
|
|
45
|
+
- Scope File: `.torusguard/config/scope.json`
|
|
46
|
+
Next: Run `/torusguard web-validate` to begin safe runtime probing.
|
|
47
|
+
```
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: torusguard-exploit-check
|
|
3
|
+
description: Safe, non-destructive confirmation of exploitability using inert canary tokens and sentinels.
|
|
4
|
+
version: 0.9.2
|
|
5
|
+
workflow: .torusguard/workflows/exploit-check.md
|
|
6
|
+
tools: Read, Grep, Glob, Bash, Write
|
|
7
|
+
scripts-binding:
|
|
8
|
+
- .torusguard/scripts/safety_gate.py
|
|
9
|
+
- .torusguard/scripts/finding_scorer.py
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
# TorusGuard Exploit Check โ Bounded Exploitability Confirmation
|
|
13
|
+
|
|
14
|
+
## Objective
|
|
15
|
+
Confirm whether candidate findings are practically exploitable using safe, single-step sentinel canaries without data loss or weaponized execution.
|
|
16
|
+
|
|
17
|
+
---
|
|
18
|
+
|
|
19
|
+
## Authorization Gate Check
|
|
20
|
+
Before dispatching any exploitability probe:
|
|
21
|
+
1. Verify target route is explicitly authorized in `.torusguard/config/scope.json`.
|
|
22
|
+
2. Verify authorization TTL has not expired.
|
|
23
|
+
3. Assert probe passes `.torusguard/scripts/safety_gate.py`.
|
|
24
|
+
|
|
25
|
+
---
|
|
26
|
+
|
|
27
|
+
## Bounded Probe Strategies
|
|
28
|
+
- **SQLi:** Mathematical identity canary (`' OR 1=1--`) asserting differential response without altering data.
|
|
29
|
+
- **XSS:** Inert HTML marker tag (`<tg-canary-tag>`) checking unescaped reflection in DOM.
|
|
30
|
+
- **IDOR:** Cross-tenant GET using secondary tenant session; assert 403 vs leak.
|
|
31
|
+
- **Auth:** Omit auth header on protected route; assert 401.
|
|
32
|
+
|
|
33
|
+
---
|
|
34
|
+
|
|
35
|
+
## Execution Steps
|
|
36
|
+
|
|
37
|
+
1. **Verify Scope:** Read `scope.json`; assert authorized endpoint.
|
|
38
|
+
2. **Select Canary:** Choose matching non-destructive probe strategy.
|
|
39
|
+
3. **Dispatch Probe:** Send request with header `X-TorusGuard-AuthID`.
|
|
40
|
+
4. **Classify Status:** Transition finding into one of 5 canonical outcomes:
|
|
41
|
+
- `Confirmed`: Canary reflected or secondary tenant data leaked.
|
|
42
|
+
- `Not Reproducible`: Endpoint responded with 401/403 or sanitized input.
|
|
43
|
+
- `Needs Review`: Ambiguous status code or incomplete response.
|
|
44
|
+
- `Blocked by Controls`: WAF or rate limiter stopped probe.
|
|
45
|
+
- `Out of Scope`: Target endpoint is not authorized.
|
|
46
|
+
5. **Record Evidence:** Save trace in `.torusguard/runs/<run_id>/exploit-evidence.md`.
|
|
47
|
+
|
|
48
|
+
---
|
|
49
|
+
|
|
50
|
+
## Safety Constraints
|
|
51
|
+
- Zero destructive payloads (`DROP`, `DELETE`, `UPDATE`).
|
|
52
|
+
- No denial-of-service or continuous fuzzing loops.
|
|
53
|
+
- Redact tokens before recording traces.
|
|
54
|
+
|
|
55
|
+
---
|
|
56
|
+
|
|
57
|
+
## Output Format
|
|
58
|
+
```markdown
|
|
59
|
+
๐ฏ [TorusGuard] Exploitability Confirmation
|
|
60
|
+
- Finding ID: <Finding ID> | Target: <Route>
|
|
61
|
+
- Status: <Confirmed / Not Reproducible / Blocked>
|
|
62
|
+
- Evidence: <Response snippet or status code>
|
|
63
|
+
Next: Run `/torusguard harden` to formulate surgical remediation bundle.
|
|
64
|
+
```
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: torusguard-full
|
|
3
|
+
description: Master 7-stage security pipeline orchestrator โ coordinates discovery, authorization, static audit, runtime validation, governed remediation, recheck, and reporting.
|
|
4
|
+
version: 0.9.2
|
|
5
|
+
workflow: .torusguard/workflows/audit.md
|
|
6
|
+
tools: Read, Grep, Glob, Bash, Edit, Write
|
|
7
|
+
scripts-binding:
|
|
8
|
+
- .torusguard/scripts/stack_detect.py
|
|
9
|
+
- .torusguard/scripts/safety_gate.py
|
|
10
|
+
- .torusguard/scripts/finding_scorer.py
|
|
11
|
+
- .torusguard/scripts/run_manager.py
|
|
12
|
+
- .torusguard/scripts/sarif_exporter.py
|
|
13
|
+
---
|
|
14
|
+
|
|
15
|
+
# TorusGuard Full โ Master 7-Stage Pipeline Orchestrator
|
|
16
|
+
|
|
17
|
+
## Objective
|
|
18
|
+
Execute the full, closed-loop TorusGuard security lifecycle from stack discovery through static scanning, runtime validation, Ponytail remediation, differential re-check, and SARIF export under strict governance.
|
|
19
|
+
|
|
20
|
+
---
|
|
21
|
+
|
|
22
|
+
## 7-Stage Security Pipeline
|
|
23
|
+
0. Init (Baseline) โโโบ 1. Authorize (Scope) โโโบ 2. Audit (AST Scan) โโโบ 3. Validate (Evidence/Exploit) โโโบ 4. Harden (Ponytail Patch) โโโบ 5. Apply (Backup & Edit) โโโบ 6. Recheck (Regression) โโโบ 7. Report (SARIF)
|
|
24
|
+
|
|
25
|
+
---
|
|
26
|
+
|
|
27
|
+
## Specialist Skill Routing
|
|
28
|
+
- **Phase 0:** `torusguard-init` (`profiler`)
|
|
29
|
+
- **Phase 1:** `torusguard-authorize` (`reviewer`)
|
|
30
|
+
- **Phase 2:** `torusguard-audit` (`auditor`)
|
|
31
|
+
- **Phase 3:** `torusguard-verify` / `torusguard-exploit-check` (`validator`)
|
|
32
|
+
- **Phase 4:** `torusguard-harden` (`remediator`)
|
|
33
|
+
- **Phase 5:** `torusguard-apply` (`remediator`)
|
|
34
|
+
- **Phase 6:** `torusguard-recheck` (`reviewer`)
|
|
35
|
+
- **Phase 7:** `torusguard-report` (`reviewer`)
|
|
36
|
+
|
|
37
|
+
---
|
|
38
|
+
|
|
39
|
+
## Pipeline Execution Instructions
|
|
40
|
+
1. **Init:** Detect stack via `stack_detect.py` and activate rules in `.torusguard/rules/active/`.
|
|
41
|
+
2. **Authorize:** Verify target ownership and TTL in `.torusguard/config/scope.json`.
|
|
42
|
+
3. **Audit:** Scan ASTs; assign fingerprints; cluster root causes; compute confidence scores.
|
|
43
|
+
4. **Validate:** Audit evidence sufficiency; optionally send bounded probe canary.
|
|
44
|
+
5. **Harden:** Formulate surgical diffs bound by Ponytail limits ($\le 35$ add, $\le 25$ del).
|
|
45
|
+
6. **Apply:** Save `.bak` snapshot in `pre_apply/`; obtain Human Gate; apply patch.
|
|
46
|
+
7. **Recheck:** Re-scan modified files; assert findings are `Fixed` with zero regressions.
|
|
47
|
+
8. **Report:** Export OASIS SARIF v2.1.0 and emit signed markdown summary.
|
|
48
|
+
|
|
49
|
+
---
|
|
50
|
+
|
|
51
|
+
## Confidence Scoring Rubric
|
|
52
|
+
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).
|
|
53
|
+
|
|
54
|
+
---
|
|
55
|
+
|
|
56
|
+
## Safety & Governance
|
|
57
|
+
- Human Gate mandatory before code modifications in Phase 5.
|
|
58
|
+
- Enforce Ponytail line bounds ($\le 35$ additions, $\le 25$ deletions).
|
|
59
|
+
- Never dispatch network probes outside authorized scope in `scope.json`.
|
|
60
|
+
|
|
61
|
+
---
|
|
62
|
+
|
|
63
|
+
## Output Format
|
|
64
|
+
```markdown
|
|
65
|
+
๐ [TorusGuard] 7-Stage Security Pipeline Complete
|
|
66
|
+
- Run ID: run-YYYYMMDD-HHMMSS | Status: SECURE / AUDITED
|
|
67
|
+
- Findings: <Total> (<Fixed> Fixed ยท <Open> Remaining)
|
|
68
|
+
- SARIF Log: `.torusguard/runs/<run_id>/results.sarif`
|
|
69
|
+
- Report: `.torusguard/runs/<run_id>/report.md`
|
|
70
|
+
```
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: torusguard-harden
|
|
3
|
+
description: Package surgical remediation bundles conforming to the Ponytail Protocol (<= 35 additions, <= 25 deletions).
|
|
4
|
+
version: 0.9.2
|
|
5
|
+
workflow: .torusguard/workflows/harden.md
|
|
6
|
+
tools: Read, Grep, Glob, Write
|
|
7
|
+
scripts-binding:
|
|
8
|
+
- .torusguard/scripts/run_manager.py
|
|
9
|
+
- .torusguard/scripts/diff_guard.py
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
# TorusGuard Harden โ Governed Remediation & Bundle Packaging
|
|
13
|
+
|
|
14
|
+
## Objective
|
|
15
|
+
Formulate minimal, surgical code fixes bound by the Ponytail Protocol ($\le 35$ additions, $\le 25$ deletions), packaging unified diffs into auditable 4-artifact remediation bundles ready for review.
|
|
16
|
+
|
|
17
|
+
---
|
|
18
|
+
|
|
19
|
+
## The Ponytail Protocol
|
|
20
|
+
- **Limits:** Additions $\le 35$, Deletions $\le 25$ lines per bundle.
|
|
21
|
+
- **Invariants:** Zero full-file rewrites; preserve public APIs and tests.
|
|
22
|
+
- **Overflow:** Partition into sequential sub-bundles.
|
|
23
|
+
|
|
24
|
+
---
|
|
25
|
+
|
|
26
|
+
## Bundle Directory Structure
|
|
27
|
+
```
|
|
28
|
+
.torusguard/runs/<run_id>/remediation/<finding_id>/
|
|
29
|
+
โโโ patch.diff # Standard unified diff with line numbers
|
|
30
|
+
โโโ plan.md # Rationale and root-cause breakdown
|
|
31
|
+
โโโ verification.md # Test instructions proving fix works
|
|
32
|
+
โโโ rollback.md # Command or steps to revert patch
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
---
|
|
36
|
+
|
|
37
|
+
## Execution Steps
|
|
38
|
+
|
|
39
|
+
1. **Select Finding:** Choose prioritized verified flaw from active run's `findings.md`.
|
|
40
|
+
2. **Read AST Context:** View target file surrounding lines (ยฑ15) using `view_file`.
|
|
41
|
+
3. **Formulate Minimal Fix:** Parameterize SQL, add tenant filters, insert validation schemas.
|
|
42
|
+
4. **Validate Line Churn:** Assert additions $\le 35$ and deletions $\le 25$.
|
|
43
|
+
5. **Package Bundle:** Write 4 artifacts (`patch.diff`, `plan.md`, `verification.md`, `rollback.md`).
|
|
44
|
+
6. **Flag Sensitive Paths:** Mark changes touching auth or billing with `Requires Sensitive-Path Sign-Off`.
|
|
45
|
+
|
|
46
|
+
---
|
|
47
|
+
|
|
48
|
+
## Safety Constraints
|
|
49
|
+
- Dry-run only; do NOT apply modifications to source code during harden.
|
|
50
|
+
- Keep surrounding formatting and comments intact.
|
|
51
|
+
- Never touch files outside the targeted vulnerable sink.
|
|
52
|
+
|
|
53
|
+
---
|
|
54
|
+
|
|
55
|
+
## Output Format
|
|
56
|
+
```markdown
|
|
57
|
+
๐ ๏ธ [TorusGuard] Remediation Bundle Packaged
|
|
58
|
+
- Finding Target: <Finding ID> | File: <Path>
|
|
59
|
+
- Line Churn: +<Additions> / -<Deletions> (Ponytail: PASS)
|
|
60
|
+
- Sensitive Path: <Yes/No>
|
|
61
|
+
- Bundle Path: `.torusguard/runs/<run_id>/remediation/<finding_id>/`
|
|
62
|
+
Next: Run `/torusguard apply` to review diff and apply with rollback backup.
|
|
63
|
+
```
|