Skip to main content
CTFWorld
AI SecDifficulty: Beginner -> Advanced

AI & LLM Security

AI & LLM Security is the fastest-growing modern CTF track. Challenges simulate real enterprise AI deployments—RAG assistants, tool-calling agents, guardrails, and classifiers—where attackers exploit indirect prompt injection, overly broad tool scopes, or adversarial inputs.

Core Attack Classes & Concepts

Direct & Indirect Prompt Injection

Overriding assistant instructions directly or via untrusted data retrieved from web pages, PDFs, or emails.

Key Techniques: Context separation tests, delimiter confusion, multi-turn payload splitting, and hidden document instructions.

Agentic Tool & Privilege Abuse

Coercing an AI agent with database, shell, or email tools into performing unauthorized actions.

Key Techniques: Confused-deputy attacks, parameter tampering, and chaining read-only RAG access with outbound tool calls.

Data & System Prompt Exfiltration

Leaking confidential RAG chunks, secrets in system context, or private tenant records.

Key Techniques: Markdown image beacon exfiltration, structured JSON translation tricks, and side-channel token extraction.

Adversarial ML & Model Security

Fooling image/malware classifiers or exploiting unsafe model serialization formats.

Key Techniques: FGSM/PGD adversarial perturbations, pickle deserialization in PyTorch checkpoints, and membership inference.

Competition Methodology Checklist

  1. 1

    Map the entire AI architecture: what inputs are untrusted, what retrieval sources exist, and which tools have side effects?

  2. 2

    Treat the LLM as an untrusted interpreter—look for where model output flows directly into SQL, HTML, shell, or HTTP requests.

  3. 3

    Test output filters independently from input filters (e.g., encoding transformations or partial-character leaks).

  4. 4

    Verify privilege isolation between tenants in RAG vector stores and session memory.

Reference Pattern

Deterministic Tool Authorization (Safe Pattern)
typescript
// Enforce tenant authorization in code—never trust the LLM to check it
async function readTicket(sessionUserId: string, ticketId: string) {
  const ticket = await db.tickets.findUnique({ where: { id: ticketId } });
  if (!ticket || ticket.ownerId !== sessionUserId) {
    throw new Error('Forbidden');
  }
  return ticket;
}

Even if prompt injection succeeds, strict server-side authorization stops unauthorized data access.

Recommended Practice Progression

Challenge / TrackPlatformLevelFocus
Gandalf Prompt Injection LevelsLakera GandalfBeginnerProgressive secret protection and guardrail testing
Crucible AI/ML ChallengesDreadnode CrucibleIntermediateReal adversarial ML, LLM agents, and classifier evasion
Prompt Airlines & AI VillagesWiz / DEF CON AI VillageIntermediateEnterprise chatbot and agent security scenarios

Defensive Engineering Takeaway

Never rely solely on prompt instructions for security boundaries; enforce deterministic least-privilege authorization on every tool call, sanitize rendered model outputs, and require user approval for sensitive actions.