prompt-injection-defense

Sanitize inputs, validate tool calls, and redact leaked secrets in LLM pipelines.

Updated Apr 15, 2026
One-click install
npx skills add https://github.com/ToanPV90/dotfiles --skill prompt-injection-defense-toanpv90
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: prompt-injection-defense
Source: https://github.com/ToanPV90/dotfiles/tree/main/agents/.agents/skills/prompt-injection-defense
Command: npx skills add https://github.com/ToanPV90/dotfiles --skill prompt-injection-defense-toanpv90

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Prompt injection and indirect instruction attacks can trick LLMs into leaking secrets, ignoring safety rules, or performing unauthorized actions, especially when user input or retrieved documents are untrusted.

Core Features & Use Cases

  • Detect injection attempts: Identify common prompt-injection patterns in user messages and retrieved content using configurable detection logic.
  • Sanitize inputs and context: Truncate and normalize inputs, strip risky control characters, and wrap retrieved documents with clear boundary markers to reduce instruction smuggling.
  • Enforce tool safety: Validate tool calls against an explicit allow-list and apply safe defaults to prevent tool abuse.
  • Validate and redact outputs: Detect leaked secrets (including canary tokens), enforce output limits, and redact sensitive matches.
  • Add canary token monitoring: Inject traceable canary tokens into prompts or documents and alert when they appear in model outputs.

Quick Start

Deploy prompt sanitization, tool allow-list validation, output validation/redaction, and canary token checks in your LLM request pipeline so injection attempts are detected and contained before any high-impact actions occur.

Frequently Asked Questions about prompt-injection-defense

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I prevent prompt injection attacks in my LLM application?

Prevent prompt injection by deploying input sanitization, retrieved-context isolation with boundary markers, and tool allow-list validation in your LLM request pipeline to detect and contain injection attempts before high-impact actions occur.

What is the best way to secure a RAG pipeline against indirect instruction attacks?

Secure RAG pipelines by isolating retrieved context with clear boundary markers, stripping risky control characters from inputs, and validating tool calls against an explicit allow-list. This prevents untrusted documents from hijacking the model's instructions.

How do canary tokens detect LLM secret exfiltration?

Canary tokens detect LLM secret exfiltration by injecting traceable markers into prompts or retrieved documents. If these tokens appear in model outputs, the system alerts you that sensitive data leakage has occurred.

Does this prompt injection defense work with agentic workflows that use tool-calling?

Yes, it works with agentic workflows by validating tool calls against an explicit allow-list and applying safe defaults. This prevents tool abuse when tool outputs or user inputs contain malicious instructions.

How do I redact leaked secrets from LLM outputs?

Redact leaked secrets from LLM outputs using output policy checks that detect sensitive matches, including canary tokens. The system enforces output limits and automatically redacts sensitive information before returning responses.

What are the limitations of input sanitization for LLM security?

Input sanitization reduces instruction smuggling by truncating and normalizing inputs, but cannot fully eliminate all injection vectors. It must be combined with retrieved-context isolation, tool permissioning, and output validation for comprehensive defense.