How PromptGuard Works
PromptGuard acts as a pre-execution security barrier, ensuring no untrusted prompt reaches downstream language models without comprehensive threat analysis.
Step 1: User submits prompt
A user submits a prompt via web frontend, mobile application, API endpoint, or agent retrieval pipeline.
Step 2: PromptGuard receives the input
FastAPI gateway intercepts the request. Enforces CORS, rate-limiting, and 1 MB payload size constraints before payload enters memory buffers.
Step 3: Six-layer detection engine analyses prompt
Input is evaluated across Unicode normalization, 9 threat rule signatures, instruction hierarchy boundaries, Base64/Hex obfuscation, behavioral intent, and semantic proximity.
Step 4: Adaptive risk engine calculates risk score
Detection signals are multiplied by calibrated risk weights. The final synthesized score is strictly bounded from 0 to 100 with zero mathematical overflow.
Step 5: Policy engine determines appropriate action
The risk score is evaluated against configured organizational thresholds (ALLOW, FLAG, ISOLATE, BLOCK).
Step 6: Result is processed & enforced
Clean prompts reach downstream LLMs; flagged prompts receive defensive system delimiters; high/critical threats are terminated at the boundary with zero tokens dispatched.
Automated Downstream Actions
When Step 5 determines policy, the PromptGuard engine dispatches one of four deterministic actions:
Forward to LLM
The prompt is validated clean. Transmitted to downstream provider (OpenAI, Gemini, Claude, or Local Simulator) without alteration.
Apply Safeguards
Prompt has elevated risk markers. Encapsulated in strict defensive boundary delimiters before LLM processing to prevent instruction escape.
Isolate from Model
High-confidence adversarial intent. Kept away from production model execution and routed to the forensic review buffer.
Hard Cutoff
Execution stopped immediately. Zero tokens reach the downstream model. Incident logged to SQLite audit database with alert telemetry.
Explore Technical Architecture
Read the complete system architecture, REST API reference, and database ERD.