Security guardrails, governed remediation, and authorized runtime validation for AI-built web applications.
AI coding assistants accelerate software engineering, but they frequently introduce high-risk security anti-patterns: querying databases directly from client-side bundles, exposing service-role keys, omitting tenant isolation scopes, or trusting unsanitized proxy headers.
TorusGuard is an open-source, Markdown-first security guidance system and verification engine. It bridges static security audits with governed, minimal-churn remediation and safe, authorized runtime validationβguaranteeing that vulnerabilities are identified, confirmed, patched, and verified without breaking codebases or deploying weaponized exploits.
"If the browser receives it, users can inspect it."
DevTools, Inspect Element, and network breakpoints cannot be disabled. TorusGuard enforces that database credentials, sensitive business logic, and authorization boundaries must always reside on trusted server-side code.
Every candidate vulnerability transitions through an auditable, deterministic state machine:
βββββββββββββ ββββββββββββββ βββββββββββββ βββββββββββββββ ββββββββββββ βββββββββββββ βββββββββββββ
β 1. Detect β βββΊ β 2.Classify β βββΊ β 3. Verify β βββΊ β 4.Remediate β βββΊ β 5. Apply β βββΊ β 6.Recheck β βββΊ β 7.Archive β
βββββββββββββ ββββββββββββββ βββββββββββββ βββββββββββββββ ββββββββββββ βββββββββββββ βββββββββββββ
-
Detect (
/torusguard audit): Scans source code, manifests, and configurations against 64 canonical security rules. -
Classify: Derives AST-invariant
FindingFingerprinthashes and collapses repeated alerts into systemic root-cause clusters. -
Verify (
/torusguard web-validate/exploit-check): Executes bounded, passive HTTP/browser probes against authorized endpoints to confirm reachability. -
Remediate (
/torusguard harden): Generates self-contained 5-file Remediation Bundles with framework-idiomatic Before/After fixes. -
Apply (
/torusguard apply): Employs the Ponytail engine to apply surgical, minimal patches governed by strict line churn limits ($\le 35$ additions,$\le 25$ deletions). -
Recheck (
/torusguard recheck): Scopes differential re-audits strictly to modified files, assertingConfirmed Fixedor detecting regressions. - Archive: Preserves cryptographic SHA-256 evidence digests and exports OASIS-compliant SARIF v2.1.0 reports for GitHub Code Scanning.
TorusGuard is organized into three decoupled architectural tiers in core/:
TORUSGUARD ENGINE (v0.7.0)
+---------------------------------------------------------------------------------------+
| TIER 3: AUTHORIZED RUNTIME VALIDATION & MULTI-AGENT GOVERNANCE |
| - TargetScope & AuthorizationManager (Explicit legal consent & host/path whitelist) |
| - SafetyGate (Auto-Allowed GETs vs Approval Required state changes vs Manual Only) |
| - WebValidator & RedactionEngine (Bounded HTTP probing with Bearer/token redaction) |
| - ExploitChecker (Safe verification for Auth, IDOR, Header Trust, Path Traversal) |
| - BrowserVerifier (Client route guards & unauthenticated DOM inspection) |
| - RoleOrchestrator (Profiler, Validator, Remediator, Reviewer handoffs) |
| - ReplayManager (Deterministic JSON replay traces) |
+-------------------------------------------+-------------------------------------------+
| Extends & Enriches
+-------------------------------------------v-------------------------------------------+
| TIER 2: GOVERNED REMEDIATION & RESILIENT DETECTION |
| - IdentityEngine (Line-shift invariant finding fingerprints) |
| - ClusteringEngine (Systemic root-cause grouping & hotspot analysis) |
| - BundleManager (5-file structured remediation packaging) |
| - PatchGovernor (Minimal churn limits & sensitive-path escalation) |
| - TargetedRechecker (Scoped differential verification & regression alerts) |
| - SarifExporter (GitHub Code Scanning deduplication via primaryLocationLineHash) |
| - StackProfiler (Framework version families & package manager detection) |
+-------------------------------------------+-------------------------------------------+
| Builds Upon
+-------------------------------------------v-------------------------------------------+
| TIER 1: CANONICAL MODELS, LIFECYCLE & PROVENANCE |
| - Finding, Evidence, Remediation data models (16 JSON schemas) |
| - FindingLifecycleManager (Deterministic 7-stage state machine) |
| - ReportFormatter (Human-First card layout & sensitive secret masking) |
+---------------------------------------------------------------------------------------+
Install TorusGuard into Cursor, Antigravity, Claude Code, Cline, Codex, or Gemini CLI using the open skills CLI:
npx skills add https://github.com/githubmofo/TorusGuard --skill "torusguard"| Command | Role / Phase | Purpose | Modifies Code? |
|---|---|---|---|
/torusguard init |
Setup | Generates a project SECURITY.md, threat model, and baseline. |
β Docs only |
/torusguard audit |
Profiler / Detect | Scans codebase, generates stable IDs, and clusters findings. | β No |
/torusguard authorize |
Safety Gate | Enforces target ownership proof and strict scope allowlists. | β No |
/torusguard web-validate |
Validator | Bounded HTTP probing and session tracking with secret redaction. | β No |
/torusguard exploit-check |
Validator | Safe, single-step exploitability confirmation across 5 statuses. | β No |
/torusguard harden |
Remediator | Emits 5-file remediation bundles and surgical patch plans. | β No |
/torusguard apply |
Remediator | Applies bounded, governed patches ( |
|
/torusguard recheck |
Reviewer | Differentially audits modified files to verify fixes and catch regressions. | β No |
Every execution is completely self-contained within an isolated directory (runs/<run-id>/):
runs/run-20260901-113000/
βββ manifest.json # Execution metadata, git commit hash, and summary counts
βββ summary.md # Executive summary and root-cause cluster matrix
βββ findings.md # Detailed finding cards with code excerpts and remediation
βββ web-validation.md # HTTP interaction log and endpoint status codes
βββ requests.json # Redacted request payloads (tokens/passwords masked)
βββ responses.json # Redacted response payloads
βββ session-notes.md # Active session cookies and tenant context
βββ replay.json # Deterministic replay trace for regression verification
βββ sarif.json # OASIS SARIF v2.1.0 export for CI/CD & GitHub Code Scanning
βββ logs/ # Execution telemetry and safety gate audit log
- Django Guide: Settings, CSRF, ORM queries, ModelForms, object ownership, and async coroutines (
aget()). - Django REST Framework Guide: Default permissions, ViewSets, serializers, throttles, and pagination.
- FastAPI Guide: Pydantic v2 schemas,
Annotateddependency injection, SSRF boundaries, and HMAC webhooks. - Flask Guide: Factory patterns, secure session cookies,
CSRFProtect, and path traversal storage limits. - SQLAlchemy Guide: Bound query parameters, 2.0
select()statements, and multi-tenant isolation. - Python Dependencies & CI/CD: Deterministic lockfiles (
uv, Poetry, pip-tools),pip-audit, and GitHub Actions SHA pinning.
- React + Vite Guide: Frontend env variable boundaries, build artifact leakage, and source maps.
- Next.js Guide: App Router / Pages Router security, Server Components, and Next.js 14 Server Action authorization (
"use server"). - Supabase Guide: Row-Level Security (RLS), service-role key isolation, and secure client queries.
- Firebase Guide: Firestore Security Rules, client SDK boundaries, and privileged admin tasks.
| Document | Purpose |
|---|---|
| π‘οΈ Security Philosophy | Strict legal authorization, non-destructive probing, and safety review gates |
| π§ͺ Testing Playbook | Step-by-step verification guide using internal fixtures and OWASP Juice Shop |
| πΊοΈ Development Roadmap | Prioritized v0.7.1+ backlog (TG-AGENT-*, diff line scanning, GraphQL/WebSockets) |
| π₯ Maintainer Guide | Maintainer security hygiene, mandatory MFA, branch protection, and release signing |
| π Refactoring Notes | Structural refactoring log, module decomposition, and merge verification |
To maintain technical honesty and safety:
- Not a weaponized offensive pentest tool: TorusGuard strictly avoids brute-forcing, denial-of-service, memory corruption, and autonomous lateral movement.
- Not an unbounded vulnerability scanner: Probes are bounded, single-step assertions against authorized endpoints with strict request budgets.
- Not client-side DRM: Browser-delivered JavaScript cannot be hidden from DevTools; security must reside on the backend.
- Not an "unhackable" guarantee: Security is continuous; TorusGuard provides structured guardrails, not absolute immunity.
- Creator & Lead Maintainer: Jenish Lad (@githubmofo)
- Contributing: Please review CONTRIBUTING.md and CODE_OF_CONDUCT.md before opening a pull request.
- Security Inquiries: Please follow our Security Policy for private vulnerability reporting.
- License: Open source under the MIT License.