Implementation:OWASP Www project top 10 for large language model applications SandboxManager Deploy
| Knowledge Sources | OWASP/www-project-top-10-for-large-language-model-applications |
|---|---|
| Domains | GenAI Red Team Testing, Containerized Sandboxing, LLM Application Security |
| Last Updated | 2026-02-14 |
Overview
Concrete tool documentation for deploying sandboxed LLM applications using Podman with Gradio UI and FastAPI endpoints, provided by the OWASP GenAI Red Team Handbook.
Description
This implementation covers the deployment of two sandbox types defined in the GenAI Red Team Handbook: RAG_local and llm_local. Each sandbox runs as a Podman container exposing a Gradio web interface on port 7860 and a FastAPI REST API on port 8000. The RAG_local sandbox includes mock services (Pinecone-compatible vector database, S3-compatible object storage, and a mock LLM API) for testing retrieval-augmented generation vulnerabilities. The llm_local sandbox provides a lightweight OpenAI-compatible API backed by Ollama for testing prompt injection and direct interaction vulnerabilities.
The deployment process uses Makefiles to orchestrate container build and launch steps, abstracting Podman commands behind simple targets such as make build and make run.
Usage
Use this implementation when you need to stand up a target LLM application for red team testing. Select the appropriate sandbox type based on the attack surface you intend to evaluate: RAG_local for retrieval and data pipeline attacks, or llm_local for prompt-level attacks against a local model.
Code Reference
Source Location
initiatives/genai_red_team_handbook/README.md lines 16 through 38 (Architecture diagram) and lines 104 through 117 (Sandboxes index).
Signature
SandboxManager.deploy(sandbox_type: str, config: SandboxConfig) -> SandboxInstance
Import or Command
Build and run the RAG_local sandbox:
cd initiatives/genai_red_team_handbook/sandboxes/RAG_local
make build
make run
Build and run the llm_local sandbox:
cd initiatives/genai_red_team_handbook/sandboxes/llm_local
make build
make run
I/O Contract
Inputs
| Parameter | Type | Description |
|---|---|---|
| sandbox_type | str | The type of sandbox to deploy. Valid values: "RAG_local" (full RAG pipeline with mock services) or "llm_local" (lightweight OpenAI-compatible endpoint via Ollama). |
| config | SandboxConfig | Configuration object containing model_name (str), gradio_port (int, default 7860), fastapi_port (int, default 8000), and optional mock service settings. |
Outputs
| Field | Type | Description |
|---|---|---|
| container_id | str | Podman container identifier for the running sandbox. |
| gradio_url | str | URL of the Gradio web interface (e.g., "http://localhost:7860"). |
| fastapi_url | str | URL of the FastAPI endpoint (e.g., "http://localhost:8000"). |
| status | str | Deployment status: "running", "failed", or "starting". |
| mock_services | list[str] | List of active mock services (e.g., ["vector_db", "s3", "llm_api"] for RAG_local, or [] for llm_local). |
Usage Examples
Example 1: Deploy RAG_local Sandbox
# Navigate to the RAG_local sandbox directory
cd initiatives/genai_red_team_handbook/sandboxes/RAG_local
# Build the container image
make build
# Launch the sandbox
make run
# Verify Gradio UI is accessible
curl -s -o /dev/null -w "%{http_code}" http://localhost:7860
# Verify FastAPI endpoint is accessible
curl -s http://localhost:8000/docs | head -5
Example 2: Deploy llm_local Sandbox
# Navigate to the llm_local sandbox directory
cd initiatives/genai_red_team_handbook/sandboxes/llm_local
# Build the container image
make build
# Launch the sandbox
make run
# Verify Gradio UI is accessible
curl -s -o /dev/null -w "%{http_code}" http://localhost:7860
# Verify FastAPI endpoint is accessible
curl -s http://localhost:8000/docs | head -5
Example 3: Programmatic Deployment and Health Check
import subprocess
import requests
def deploy_sandbox(sandbox_type: str) -> dict:
sandbox_dir = f"initiatives/genai_red_team_handbook/sandboxes/{sandbox_type}"
# Build
subprocess.run(["make", "build"], cwd=sandbox_dir, check=True)
# Run
subprocess.run(["make", "run"], cwd=sandbox_dir, check=True)
# Health check
gradio_ok = requests.get("http://localhost:7860").status_code == 200
fastapi_ok = requests.get("http://localhost:8000/docs").status_code == 200
return {
"sandbox_type": sandbox_type,
"gradio_url": "http://localhost:7860",
"fastapi_url": "http://localhost:8000",
"status": "running" if (gradio_ok and fastapi_ok) else "degraded",
}
result = deploy_sandbox("RAG_local")
print(result)