LLM Guard Input/Output Security Scanner
Self-hosted Python & REST security scanner sanitizing PII, secrets, toxicity, and prompt injection at runtime.
Prerequisites & Step-by-Step Installation
Copy & run inside isolated labBefore You Start (Prerequisites)
- + Python 3.10-3.12 or Docker Engine (4 GB+ RAM for DeBERTa/ONNX models)
- + ONNX runtime for fast CPU inference inside production containers
- + PII/Secret policy thresholds configured in scanner YAML
Install LLM Guard with ONNX acceleration inside Python virtualenv
python3 -m venv ~/venv-llmguard && source ~/venv-llmguard/bin/activate
pip install llm-guard onnxruntime
ONNX cuts CPU scanner latency significantly vs raw PyTorch.
Test Secrets and InvisibleText input scanners locally
python -c "from llm_guard.input_scanners import Secrets, InvisibleText; s=InvisibleText(); print(s.scan('clean text'))"
Strips zero-width prompt injection markers automatically before LLM inference.
python -c "import llm_guard; print(llm_guard.__version__)"
Client Integration & Configuration Files
Review scope limits before wiringpip install llm-guard
python -c "from llm_guard.input_scanners import PromptInjection, Secrets; print('LLM-GUARD READY')"
docker run -p 127.0.0.1:8000:8000 --read-only laiyer/llm-guard-api:latest
How to Use & Defensive Workflow
Authorized assessment protocolTypical Scenario: Scrub user-submitted tickets for SSNs/API keys before sending to an external LLM and re-hydrate sanitized placeholders securely afterward.
- 01. Enable Anonymize, Secrets, InvisibleText, and PromptInjection on the input chain.
- 02. Enable Sensitive and MaliciousURLs scanners on the model output chain.
- 03. Benchmark latency and false-positive rate against your real application dataset.
python -c "from llm_guard.input_scanners import PromptInjection; sc=PromptInjection(); print(sc.scan('Summarize this public CVE advisory.'))"
Bind the LLM Guard API strictly behind internal service authentication and never trust classifier scores alone without RBAC boundaries.
Technical Architecture & Deployment Brief
Overview & Role in Security Engineering
LLM Guard Input/Output Security Scanner (Guardrail & Eval) is engineered to support practitioners focused on inline prompt Anonymize/Vault PII redaction, DeBERTa injection scoring, secret scanning, and invisible character stripping. Within the ToolWar ecosystem, it serves as an explicit bridge between AI reasoning layers and verifiable cybersecurity telemetry.
Technical Architecture & Data Flow
This entry bridges classical cybersecurity engineering with modern AI workflows while preserving strict human review, deterministic boundary checks, and verifiable outputs.
Unlike ad-hoc prompt wrappers that execute unconstrained strings directly in a shell, structured integration enforces typed parameter validation, bounded scope allowlists, and explicit separation between untrusted analyzed artifacts (source files, telemetry logs, network banners, or binary samples) and system-level control instructions.
Recommended Deployment Practice
- Isolate the Execution Boundary: Deploy integrations inside ephemeral containers or dedicated analysis VMs so untrusted repositories, binaries, or HTTP responses cannot affect primary workstations.
- Enforce Least-Privilege Scoping: Use read-only filesystem mounts, non-privileged service tokens, and target CIDR allowlists before enabling interactive assistant sessions.
- Verify Outputs Deterministically: Validate every generated output against deterministic static scanners or runtime guardrails before applying changes to production infrastructure.
Integration & Operational Caveats
- Treat all external content ingested by an LLM (including code comments, HTML titles, log lines, and MCP responses) as potential prompt-injection vectors.
- Review configuration JSON and
SKILL.mdmanifests carefully before binding credentials or running inside automated CI/CD pipelines.