llm-app-security
llm-app-security is an code AI skill with a core value of Secure LLM-powered applications with input validation, output controls, tenant isolation, and abuse prevention. It
helps developers solve real-world problems in the code domain, boosting
efficiency, automating repetitive tasks, and optimizing workflows.
Secure LLM-powered applications with input validation, output controls, tenant isolation, and abuse prevention.
Quick Facts
mkdir -p ./skills/llm-app-security && curl -sfL https://raw.githubusercontent.com/sickn33/antigravity-awesome-skills/main/skills/llm-app-security/SKILL.md -o ./skills/llm-app-security/SKILL.md Run in terminal / PowerShell. Requires curl (Unix) or PowerShell 5+ (Windows).
Skill Content
# LLM Application Security
Harden chatbots, RAG pipelines, and AI features embedded in SaaS products against prompt injection, data leakage, abuse, and compliance violations.
---
OWASP LLM Top 10 -- Risk Map and Mitigations
The OWASP Top 10 for LLM Applications (2025) defines the most critical risks. The table below maps each risk to concrete controls implemented later in this document.
| # | Risk | Key Mitigation | Section |
|---|------|----------------|---------|
| LLM01 | Prompt Injection | Input validation, instruction hierarchy | Input Validation, System Prompt Protection |
| LLM02 | Insecure Output Handling | Output sanitization, PII scrubbing | Output Safety |
| LLM03 | Training Data Poisoning | Document ingestion scanning | Secure RAG Pipeline |
| LLM04 | Model Denial of Service | Per-user token budgets, rate limiting | Rate Limiting |
| LLM05 | Supply Chain Vulnerabilities | Pin model versions, verify checksums | Compliance |
| LLM06 | Sensitive Information Disclosure | PII detection, tenant isolation | Output Safety, Tenant Isolation |
| LLM07 | Insecure Plugin Design | Tool allowlists, parameter validation | System Prompt Protection |
| LLM08 | Excessive Agency | Least-privilege tool scopes | System Prompt Protection |
| LLM09 | Overreliance | Provenance tracking, confidence scores | Secure RAG Pipeline |
| LLM10 | Model Theft | Access controls, API key rotation | Rate Limiting, Compliance |
---
Input Validation
Every user message must be validated before it reaches the LLM. Validation has three layers: structural checks, injection detection, and content moderation.
Structural Checks (Python)
import re
from dataclasses import dataclass
@dataclass
class InputPolicy:
max_length: int = 4096
max_lines: int = 50
allowed_languages: set = None # None = all
def __post_init__(self):
if self.allowed_languages is None:
self.allowed_languages = {"en"}
def validate_structure(text: str, policy: InputPolicy) -> tuple[bool, str]:
"""Return (is_valid, reason)."""
if not text or not text.strip():
return False, "empty_input"
if len(text) > policy.max_length:
return False, f"exceeds_max_length_{policy.max_length}"
if text.count("\n") > policy.max_lines:
return False, f"exceeds_max_lines_{policy.max_lines}"
# Block null bytes and control characters (except newline/tab)
if re.search(r"[\x00-\x08\x0b\x0c\x0e-\x1f\x7f]", text):
return False, "contains_control_characters"
return True, "ok"Prompt Injection Detection (Python)
import re
from typing import Optional
# Patterns that signal an attempt to override system instructions
INJECTION_PATTERNS = [
# Direct instruction override
r"(?i)ignore\s+(all\s+)?(previous|prior|above)\s+(instructions?|prompts?|rules?)",
r"(?i)disregard\s+(all\s+)?(previous|prior|above)\s+(instructions?|prompts?)",
# System prompt extraction
r"(?i)(reveal|show|print|output|repeat)\s+(your\s+)?(system\s+prompt|instructions|rules)",
r"(?i)what\s+(are|were)\s+your\s+(initial\s+)?(instructions|rules|prompt)",
# Role override
r"(?i)you\s+are\s+now\s+(a|an|the)\s+",
r"(?i)(act|behave|respond)\s+as\s+(if\s+)?(you\s+)?(are|were)\s+",
# Delimiter injection
r"(?i)<\/?system>",
r"(?i)\[INST\]|\[\/INST\]",
r"(?i)###\s*(system|instruction|human|assistant)",
# Encoding evasion (base64 instructions)
r"(?i)decode\s+(the\s+)?following\s+(base64|hex|rot13)",
]
_compiled = [re.compile(p) for p in INJECTION_PATTERNS]
def detect_injection(text: str) -> Optional[str]:
"""Return the matched pattern name if injection is detected, else None."""
for pattern in _compiled:
match = pattern.search(text)
if match:
return pattern.pattern
return NonePrompt Injection Detection (Node.js)
const INJECTION_PATTERNS = [
/ignore\s+(all\s+)?(previous|prior|above)\s+(instructions?|pro🎯 Best For
- Security auditors
- DevSecOps teams
- Compliance officers
- Claude users
- Software engineers
💡 Use Cases
- Auditing dependencies for known CVEs
- Scanning API endpoints for auth gaps
- Code quality improvement
- Best practice enforcement
📖 How to Use This Skill
- 1
Install the Skill
Copy the install command from the Terminal tab and run it. The SKILL.md file downloads to your local skills directory.
- 2
Load into Your AI Assistant
Open Claude and reference the skill. Paste the SKILL.md content or use the system prompt tab.
- 3
Apply llm-app-security to Your Work
Open your project in the AI assistant and ask it to apply the skill. Start with a small module to verify the output quality.
- 4
Review and Refine
Review AI suggestions before committing. Run tests, check for regressions, and iterate on the skill output.
❓ Frequently Asked Questions
Can this replace a dedicated SAST tool?
AI-based security review is complementary to SAST tools. Use it as a first-pass filter, not a replacement.
Is llm-app-security compatible with Cursor and VS Code?
Yes — this skill works with any AI coding assistant including Cursor, VS Code with Copilot, and JetBrains IDEs.
Do I need specific dependencies for llm-app-security?
Check the install command and Works With section. Most code skills only require the AI assistant and your codebase.
How do I install llm-app-security?
Copy the install command from the Terminal tab and run it. The skill downloads to ./skills/llm-app-security/SKILL.md, ready to use.
Can I customize this skill for my team?
Absolutely. Edit the SKILL.md file to add team-specific instructions, examples, or workflows.
⚠️ Common Mistakes to Avoid
Only scanning surface-level issues
Deep security review requires understanding your app architecture, not just regex patterns.
Skipping validation
Always test AI-generated code changes, even for simple refactors.
Missing dependency updates
Check if the skill requires updated dependencies or new packages.