WorkLLM & Tool-Using Agent Security Lab
An own-built AI/LLM security lab testing indirect prompt injection, cross-tenant RAG retrieval leaks, BOLA tool calls, webhook SSRF and unsafe output handling against deterministic TypeScript controls.
Five repeatable LLM/agent attack paths reproduced in vulnerable mode and blocked by deterministic controls in CI.
- Role
- Author and security engineer
- Scope
- Own project (self-built lab)
- Stack
- TypeScript · Next.js · Zod · Node.js test runner · OWASP LLM Top 10 (2025)
- Year
- 2026
Lab verifier
Standalone project, deterministic engine
Run the lab against the real engine.
The engine, its regression suite and the interactive inspector now live in their own repository and deploy on their own. Switch a pipeline between the vulnerable baseline and the hardened build, then read the exact code that made the decision.
- 01RAG retrieverpassed
- 02Prompt assemblypassed
- 03Tool policy gateblocked
- 04Output sanitizerpassed
Synthetic tenants, invoices and tickets only. The hardened pipeline never prints a retrieved secret and never reports a refund as processed.
Summary
LLM features fail when applications treat model outputs or retrieved documents as trusted instructions. I built a multi-tenant support and billing triage agent pipeline with four explicit trust boundaries: RAG retrieval, prompt context assembly, tool execution, and browser output rendering.
The lab pairs a deliberately vulnerable baseline with a hardened reference implementation and runs an automated regression suite against five attack scenarios mapped to the OWASP Top 10 for LLM Applications (2025).
Threat model and trust boundaries
Boundary 1, Authenticated Session to Retriever (LLM08 / LLM02): Similarity search must never run globally across tenants and rely on the prompt to hide other tenants' records. Pre-retrieval ACL filtering must happen in the data query.
Boundary 2, Untrusted Data to Prompt Context (LLM01): External support tickets and community notes are untrusted input. Concatenating them directly into system instructions lets an attacker plant [SYSTEM OVERRIDE] directives that hijack downstream tool calls.
Boundary 3, Model Output to Tool Executor (LLM06 / API1): The model is not an authorization layer. State-changing tools (issue_refund), cross-tenant reads (lookup_invoice), and network egress tools (send_webhook_summary) must be gated by server-side session checks, Zod schemas, host allowlists, and human-in-the-loop confirmation tokens.
Boundary 4, Model Output to DOM Renderer (LLM05): Model responses can carry attacker-controlled HTML or markdown image beacons from retrieved chunks and must be sanitized before rendering.
Attack paths and enforced controls
| ID | Finding | Severity | CVSS v3.1 | Status |
|---|---|---|---|---|
| 01 | Indirect Prompt Injection to Unauthorized Refund Inbound ticket #409 instructs the model to call issue_refund for $450. The hardened pipeline isolates retrieved text inside <untrusted_data> tags and enforces role === 'support_agent' plus a human confirmation token at the tool gate. LLM01 / LLM06 | High | 8.1 | Blocked in CI |
| 02 | Cross-Tenant Vector Retrieval Leak A tenant-acme query matches a confidential tenant-globex renewal memo. The hardened retriever filters chunks by chunk.tenantId === session.tenantId || chunk.tenantId === 'public' before scoring. LLM08 / LLM02 | High | 7.5 | Blocked in CI |
| 03 | Model-Supplied Tenant Parameter BOLA A user asks the model to call lookup_invoice with tenantId: 'tenant-globex'. The hardened tool gate validates arguments with Zod and asserts args.tenantId === session.tenantId. LLM06 / API1 | High | 7.5 | Blocked in CI |
| 04 | Unconstrained Webhook Tool Exfiltration An injected directive points send_webhook_summary at collector.attacker.example. The hardened tool gate parses the URL and restricts egress to https://hooks.internal.example. LLM06 / LLM02 | High | 8.6 | Blocked in CI |
| 05 | Poisoned Chunk Output XSS and Beacon A poisoned note injects <img src=x onerror=...> and an external markdown tracking image. The hardened output sanitizer strips executable HTML tags, blocks javascript:/data: schemes, and strips external image beacons. LLM05 | High | 7.3 | Blocked in CI |
Verification and known limitations
Every attack scenario and positive authorization check is asserted in the standalone lab's engine.test.ts suite and runs on every push (npm test).
Known limitation: Delimiters (<untrusted_data>) and regex stripping reduce prompt-injection compliance, but no prompt-level filter can guarantee a probabilistic model will never emit a malicious tool call. That is why the security boundary in this lab is placed outside the model, at the pre-retrieval query filter, the deterministic tool policy gate, and the output sanitizer.