Let AI work. Never let it overstep.
VAJRA AI is an execution-time security gateway for AI agents, plus Document Guard, a heuristic scanner for documents an agent is about to read. This repository is a hackathon prototype: the policy enforcement is real backend code with regression tests, and every tool it protects is a mock (no real email is sent and no files are deleted).
.txt file (web only), or load a clearly marked sample invoice. Deterministic backend rules flag prompt-injection phrases, external-sharing requests, email addresses, risky URLs, card-like numbers (Luhn-checked), phone numbers, credentials and hidden zero-width text. Results come back as findings with a severity of Review, Elevated or High and short, redacted evidence. These are heuristic risk signals, not a malware verdict. The document is processed in memory and is never stored or sent to an LLM.send_external_email; otherwise it proposes generate_local_summary. The proposal goes through the real gateway.POST /api/v1/gateway/execute). This is the only path to a mock executor. It checks, failing closed at each step: task exists and is runnable → agent registered → policy present → tool known → arguments match the tool schema → tool is in the task’s allowed_tools → the resource (taken from the tool argument) is in scope → the destination (taken from the tool argument, e.g. email to) is valid and on the allowlist → policy rule → approval. Every outcome is persisted as an audit event before the response is returned. Denied actions never call the executor.require_approval, the gateway creates a pending approval. The approval is bound to the task, agent, tool, a SHA-256 of the canonical arguments, the resource, the destination and the current policy fingerprint, and it expires after 10 minutes. You approve or reject it on the web or the phone. The agent then resubmits with approval_id, and the gateway re-validates everything and consumes the approval atomically, exactly once. Replayed, changed, expired, rejected or policy-changed approvals are denied..txt files; it does not parse PDFs or run OCR.docs/SECURITY_LIMITATIONS.md.Prerequisites: Python 3.11+, Node 20+.
Backend (FastAPI + SQLite, seeded with demo data on first start):
cd backend
pip install -r requirements.txt -r requirements-dev.txt
uvicorn app.main:app --reload --host 0.0.0.0 --port 8000
# API docs: http://localhost:8000/docs
Web dashboard:
cd dashboard
npm ci
npm run dev # http://localhost:5173, uses http://localhost:8000 by default in dev
# or point it at another backend:
VITE_BACKEND_BASE_URL=http://192.168.1.20:8000 npm run dev
Mobile companion (Expo):
cd mobile
npm ci
npm run start # Android emulator defaults to http://10.0.2.2:8000
ipconfig on Windows, ip addr or ifconfig on macOS/Linux), for example 192.168.1.20.uvicorn app.main:app --host 0.0.0.0 --port 8000.http://192.168.1.20:8000/health in the phone’s browser.EXPO_PUBLIC_API_BASE_URL=http://192.168.1.20:8000 npm run start$env:EXPO_PUBLIC_API_BASE_URL="http://192.168.1.20:8000"; npm run start.github/workflows/dashboard-pages.yml, served at https://nickroy07.github.io/VajraAi/). It does not host the FastAPI backend. Set the repository variable VITE_BACKEND_BASE_URL to a deployed backend. If it is not set, the site shows “Backend not configured” instead of guessing at localhost.backend/Dockerfile and render.yaml deploy the API as a Docker web service, for example on Render. SQLite is ephemeral there, so demo data resets on redeploy. No public backend URL exists until you deploy one.cd backend && pytest -q && python -m compileall -q app tests && python -c "from app.main import app; print(app.title)"
cd dashboard && npm run typecheck && npm run build
cd mobile && npm run typecheck
backend/tests/security/test_security_regressions.py covers the fail-closed scope rules, lookalike domains, conflicting destinations, approval approve/reject/expiry/changed-arguments/replay/policy-change/agent-binding, verified executor deltas, redaction, and Document Guard.
backend/ FastAPI gateway · dashboard/ React + Vite web app · mobile/ Expo app · shared/ JSON contracts · docs/ product, threat model and demo script.
See docs/DEMO_SCRIPT.md for the 3-minute presenter sequence.