Prompt injection mitigation

From RedHatProductSecurity/prodsec-skills · View interactive version

Prompt injection mitigation is an AI agent skill from the GitHub repository RedHatProductSecurity/prodsec-skills. Mitigate prompt injection risks in LLM-based systems. Use when designing, building, or reviewing AI systems that accept user prompts, or when evaluating model safety for deployment.

How to use this skill

Skill file

Prompt Injection Mitigation

Security Recommendation

Prompt injection cannot be fully prevented. It can only be minimized. The approach combines multiple layers of defense rather than relying on a single control.

Mitigation Strategies

1. Leverage Runtime Security Controls

Use architectural components that reduce prompt injection probability:

2. Choose Safer Models

Model safety is primarily determined during pre-training and fine-tuning. If the solution does not pre-train or fine-tune its own models, select models that have been trained with safety as a priority.

| Evaluation Criteria | What to Look For |

|---|---|

| Safety benchmarks | Published safety evaluation scores and red-team results |

| Alignment training | RLHF, constitutional AI, or other alignment techniques applied |

| Known vulnerabilities | Check for disclosed prompt injection vulnerabilities |

| Provider reputation | Track record of the model provider on security and safety |

3. Human-in-the-Loop for Sensitive Actions

The best mitigation for prompt injection in agentic systems is keeping a human in the loop. Require explicit user confirmation before executing any sensitive or destructive action triggered by the LLM. This is especially critical for MCP-based agents where tool execution can have real-world impact.

4. Limit Model Capabilities

Reduce the impact of successful prompt injection by constraining what the model can do:

Defense-in-Depth Layers

Rate Limiting (API Gateway)
  → Input Guardrails (prompt filtering)
    → Safer Model (alignment training)
      → Output Guardrails (response filtering)
        → Output Validation Sandbox (if model generates actions)

Additional OWASP LLM Top 10 Threats

Beyond prompt injection, address these related LLM risks:

Insecure Plugin/Tool Design (LLM07)

Model Theft (LLM10)

Data Poisoning and Supply Chain (LLM03, LLM05)

Sensitive Information Disclosure (LLM06)

Denial of Service (LLM04)

Implementation Checklist

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.