Skip to content
Back to skills

Security

ASecurity

Defend agentic systems against direct and indirect prompt injection using defense-in-depth.

  • 23 stars
  • 0 votes
  • 0 copies
  • 0 views
  • Added October 14, 2026
ai-agentsrustgorailssecurity

Works with

  • mcp

Security analysis

A100/100

Pro scans all 21 files and shows the line behind each finding

Scanned October 14, 2026

npx -y skills add andreibesleaga/GABBE --skill security --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Security?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Security
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/andreibesleaga-security-513c8923/badge)](https://www.skillsdirectory.com/skills/andreibesleaga-security-513c8923)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: prompt-injection-defense
description: Defend agentic systems against direct and indirect prompt injection using defense-in-depth.
triggers: [prompt injection, indirect injection, lethal trifecta, rule of two, jailbreak defense, tool output poisoning, untrusted content]
tags: [security]
core: false
context_cost: medium
---
# Prompt Injection Defense Skill

## Goal
Defend agentic systems against direct and indirect prompt injection using defense-in-depth. No single control is sufficient: frontier labs publicly acknowledge that prompt injection cannot be fully solved in current LLM architectures, so the objective is to layer controls, contain the blast radius, and gate high-impact actions behind a human. Grounded in OWASP LLM01:2025 (Prompt Injection).

## Steps

1. **Classify the injection surface**
   - **DIRECT injection**: a malicious instruction supplied in the user's own prompt.
   - **INDIRECT injection**: malicious instructions hidden inside content the agent ingests but did not author — tool output, RAG documents, web fetches, file contents, tool metadata/descriptions, image alt-text, and error strings.
   - Treat ALL external and tool-returned content as UNTRUSTED by default. Trust is earned by provenance, never assumed from format.

2. **Apply the LETHAL TRIFECTA test, then the RULE OF TWO**
   - Risk is highest when a single agent simultaneously has: (a) access to private/sensitive data, (b) exposure to untrusted content, and (c) the ability to exfiltrate data or act externally (send, write, call, commit).
   - Apply Meta's RULE OF TWO: an agent should hold at most **2 of those 3** capabilities at once without a human-in-the-loop gate. If all three are present, a trifecta-complete path exists and the action MUST be gated.
   - Record the assessment per agent/tool-chain, not per request.

3. **Apply layered defenses (defense-in-depth)**
   - **Instruction hierarchy**: enforce a strict priority — system > developer > user > tool-output. Lower tiers can never override higher-tier instructions.
   - **Spotlighting / delimiting**: wrap all untrusted content in explicit delimiters and explicitly mark it as untrusted data, never as instructions.
   - **DUAL-LLM / quarantine pattern**: a privileged planner LLM that never sees raw untrusted text, paired with a quarantined LLM that processes untrusted content and returns only structured/symbolic results (IDs, enums, validated fields) the planner can act on.
   - **Tool allowlisting**: restrict each agent to an explicit allowlist of tools and parameter shapes.
   - **Content-provenance tracking**: tag every datum with its source so trust decisions are traceable.
   - **Egress filtering**: constrain outbound destinations and payloads to block exfiltration channels.

4. **Add a detection pre-filter (necessary, not sufficient)**
   - Run a small, fast classifier as a pre-filter before privileged processing (named examples: Llama Guard, Prompt Guard, NeMo Guardrails).
   - Understand that detectors REDUCE but do not ELIMINATE risk. They are one layer behind the structural controls above, never the only line of defense.

5. **Require human-in-the-loop approval for high-impact or trifecta-complete actions**
   - Any action that is irreversible, externally visible, or completes the lethal trifecta requires explicit human approval before execution. The agent proposes; the human approves.

## Constraints
- NEVER rely on a single defense. Pattern-matching filters and "ask the LLM to detect the injection" are known-weak and trivially bypassed.
- Assume the LLM layer CAN be compromised; design so a compromised model still cannot reach private data or an exfiltration channel without passing a structural gate.
- Indirect injection is the dominant agentic threat — never exempt tool output, RAG, or file content from untrusted-content handling.
- Detection classifiers are pre-filters, not authorization. A "clean" classifier verdict does not grant a trifecta-complete action.

## Output Format
A defense report containing:
- **Surfaces identified**: direct and indirect injection surfaces for this agent/tool-chain.
- **Trifecta assessment**: which of (private data / untrusted content / external action) are present, and whether the Rule of Two holds.
- **Controls applied**: which layered defenses are in place (hierarchy, spotlighting, dual-LLM, allowlist, provenance, egress, detection).
- **Residual risk**: what remains unmitigated after the layers.
- **Required HITL gates**: the specific actions that must be human-approved.

## Security & Guardrails

### 1. Skill Security (Prompt Injection Defense)
- **Over-trusting a single classifier**: Treating a detection pass (e.g. `Prompt Guard` returning "benign") as authorization collapses defense-in-depth into one bypassable layer. The skill MUST keep structural controls (instruction hierarchy, dual-LLM quarantine, egress filtering) live and authoritative even when the classifier reports clean, and must never escalate privilege on a classifier verdict alone.
- **Defense bypass via the skill's own examples**: The delimiter/spotlighting tokens this skill recommends become attacker targets — an injected payload may spoof the closing delimiter to "break out" of the untrusted block. Delimiter tokens MUST be high-entropy, per-session, and stripped/escaped from untrusted content before wrapping, so the marker cannot be forged from within the payload.

### 2. System Integration Security
- **Exfiltration via tool feedback**: Indirect injection commonly weaponizes a benign tool (image fetch, link unfurl, URL parameter, DNS) as a covert exfiltration channel for private data the agent holds. Egress MUST be allowlisted by destination and payload shape, and any outbound call assembled from untrusted content MUST require a HITL gate when the trifecta is complete.
- **Tool-metadata poisoning**: A compromised or malicious MCP/tool server can inject instructions through tool names, descriptions, and parameter docs that the planner reads at bind time. Tool definitions MUST be provenance-checked and pinned; untrusted tool metadata is data, never an instruction the planner obeys.

### 3. LLM & Agent Guardrails
- **System-prompt leakage (OWASP LLM07)**: Injection frequently first targets disclosure of the system/developer prompt to map the agent's tools and guardrails for a follow-on attack. Treat the system prompt as non-secret-bearing (no secrets, tokens, or internal endpoints in it) and detect/deny verbatim-reflection requests, so leakage does not bootstrap a stronger attack.
- **Assumed-compromise containment**: The planner LLM must be designed as if it may already be injected. Containment — least-privilege tokens, the dual-LLM split, egress filtering, and HITL gates on trifecta-complete actions — limits blast radius. See `output-validation.skill` for safe handling of model output, `threat-model.skill` for surface enumeration, and `ai-safety-guardrails.skill` for the surrounding rails taxonomy.

Files in this skill

  • access-control.skill.md3.2 KB
  • agent-sandboxing.skill.md8.3 KB
  • ai-ethics-compliance.skill.md3.4 KB
  • ai-red-teaming.skill.md7.9 KB
  • ai-safety-guardrails.skill.md6.1 KB
  • api-security.skill.md1.9 KB
  • backup-recovery.skill.md3.5 KB
  • compliance-review.skill.md7.6 KB
  • cryptography-standards.skill.md1.9 KB
  • dependency-security.skill.md3.4 KB
  • hazard-analysis.skill.md3.4 KB
  • legal-review.skill.md3.3 KB
  • log-analysis.skill.md3.9 KB
  • network-security.skill.md3.8 KB
  • privacy-audit.skill.md7.3 KB
  • privacy-data-protection.skill.md1.9 KB
  • prompt-injection-defense.skill.md6.8 KB
  • reliability-engineering.skill.md3.9 KB
  • safety-scan.skill.md3.4 KB
  • secrets-management.skill.md3.8 KB

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.