WorkLLM & Tool-Using Agent Security Lab

Own projectAI/LLM security2026

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
Figure2026
LLM08 · LLM02LLM01LLM06 · API1LLM05USERRAG RETRIEVERPROMPT ASSEMBLYMODELTOOL EXECUTORDOM RENDERER0201030405USERRAG RETRIEVERATTACK PATH 02PROMPT ASSEMBLYATTACK PATH 01MODELTOOL EXECUTORATTACK PATHS 03 · 04DOM RENDERERATTACK PATH 05
The five tested attack paths cross the pipeline: 02 at the retriever boundary, 01 riding untrusted data into the prompt, 03 and 04 at the tool gate, 05 at the renderer. Wide layouts draw dashed trust boundaries with teal markers, and small screens label the stages directly.

Lab verifier

Standalone project, deterministic engine

No live model call

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.

  1. 01RAG retrieverpassed
  2. 02Prompt assemblypassed
  3. 03Tool policy gateblocked
  4. 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

IDFindingSeverityCVSS v3.1Status
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

High8.1Blocked 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

High7.5Blocked 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

High7.5Blocked 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

High8.6Blocked 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

High7.3Blocked 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.