All skills
semgrep avatar

/llm-security

@327da93 official
by semgrepsemgrep/skills317 stars
31

Security guidelines for LLM applications based on OWASP Top 10 for LLM 2025. Use when building LLM apps, reviewing AI security, implementing RAG systems, or asking about LLM vulnerabilities like 'prompt injection' or 'check LLM security'. IMPORTANT: Always consult this skill when building chatbots, AI agents, RAG pipelines, tool-using LLMs, agentic systems, or any application that calls an LLM API (OpenAI, Anthropic, Gemini, etc.) — even if the user doesn't explicitly mention security. Also use when users import 'openai', 'anthropic', 'langchain', 'llamaindex', or similar LLM libraries.

Use this Skill: https://skilld.dev/gh/semgrep/skills/llm-security

This session only. Nothing lands on disk.

rules_sections.md

≈1k tokens on demand. Your agent reads this file only when SKILL.md points to it.

Sections

This file defines all sections, their ordering, impact levels, and descriptions. The section ID (in parentheses) is the filename prefix used to group rules.

Based on the OWASP Top 10 for Large Language Model Applications 2025.


Critical Impact

1. Prompt Injection (prompt-injection)

Impact: CRITICAL Description: Prevents direct and indirect prompt manipulation through input validation, external content segregation, output filtering, and privilege separation. OWASP LLM01.

2. Sensitive Information Disclosure (sensitive-disclosure)

Impact: CRITICAL Description: Protects sensitive data through data sanitization before training, output filtering for sensitive patterns, permission-aware RAG systems, and no secrets in system prompts. OWASP LLM02.

3. Supply Chain (supply-chain)

Impact: CRITICAL Description: Secures the LLM supply chain through model verification and integrity checks, safe model loading (safetensors vs pickle), dependency management with pinning, and ML Bill of Materials (ML-BOM). OWASP LLM03.

4. Data and Model Poisoning (data-poisoning)

Impact: CRITICAL Description: Prevents data poisoning through training data validation, poisoning indicator detection, data version control, and anomaly detection during training. OWASP LLM04.

5. Improper Output Handling (output-handling)

Impact: CRITICAL Description: Secures output handling through context-aware encoding (HTML, SQL, shell), parameterized queries for database operations, URL validation and allowlisting, and Content Security Policy. OWASP LLM05.


High Impact

6. Excessive Agency (excessive-agency)

Impact: HIGH Description: Controls LLM agency through minimizing tool functionality, least privilege permissions, human-in-the-loop for high-impact actions, and rate limiting and audit logging. OWASP LLM06.

7. System Prompt Leakage (system-prompt-leakage)

Impact: HIGH Description: Prevents prompt leakage through no secrets in system prompts, external guardrails (not prompt-based), input filtering for extraction attempts, and security logic in code, not prompts. OWASP LLM07.

8. Vector and Embedding Weaknesses (vector-embedding)

Impact: HIGH Description: Secures RAG systems through permission-aware vector retrieval, multi-tenant data isolation, document validation before embedding, and embedding inversion protection. OWASP LLM08.

9. Misinformation (misinformation)

Impact: HIGH Description: Mitigates misinformation through Retrieval-Augmented Generation (RAG), fact verification pipelines, domain-specific validation, and confidence scoring and disclaimers. OWASP LLM09.

10. Unbounded Consumption (unbounded-consumption)

Impact: HIGH Description: Controls resource consumption through input validation and size limits, multi-tier rate limiting, budget controls and cost tracking, and model theft detection. OWASP LLM10.


Quick Reference Matrix

# Category Filename Impact
1 Prompt Injection prompt-injection.md CRITICAL
2 Sensitive Disclosure sensitive-disclosure.md CRITICAL
3 Supply Chain supply-chain.md CRITICAL
4 Data Poisoning data-poisoning.md CRITICAL
5 Output Handling output-handling.md CRITICAL
6 Excessive Agency excessive-agency.md HIGH
7 System Prompt Leakage system-prompt-leakage.md HIGH
8 Vector/Embedding vector-embedding.md HIGH
9 Misinformation misinformation.md HIGH
10 Unbounded Consumption unbounded-consumption.md HIGH

Related Frameworks

  • MITRE ATLAS - Adversarial Threat Landscape for AI Systems
  • NIST AI RMF - AI Risk Management Framework
  • OWASP ASVS - Application Security Verification Standard
  • CWE - Common Weakness Enumeration

References

Source: SKILL.md on GitHub

1 alert16d5 checks · Risk SAFE
  • Gen Agent Trust Hub16d

    The skill provides comprehensive security guidelines and code examples for building secure LLM applications, based on the OWASP Top 10 for LLMs 2025. It serves as an educational resource to help developers mitigate risks like prompt injection and sensitive data exposure. While the skill contains examples of vulnerable code with hardcoded credentials, these are clearly labeled as insecure patterns for demonstration and educational purposes, using non-functional example values.

  • Socket16d

    No alerts

  • Snyk16d

    Risk: MEDIUM · 1 issue

  • Runlayer6mo

    12/14 files flagged

  • ZeroLeaks5mo

    Score: 93/100 · 2 sections analyzed

Signed by skilld at 327da93. This ties the file your Agent reads to that commit on GitHub. It does not review the instructions.

Last checked against GitHub 2 months ago.

Steadyupdated 7 months ago
  • llm-security
  • prompt-injection
  • owasp
  • rag
  • ai-agents
  • data-poisoning
  • sensitive-disclosure
  • output-handling
  • vector-embeddings

README badge

README badge for semgrep/skills/llm-security

Provides security guidelines for LLM applications based on OWASP Top 10 for LLM 2025, covering prompt injection, sensitive disclosure, data poisoning, excessive agency, and other LLM-specific risks. Use when building chatbots, RAG systems, AI agents, or any application calling LLM APIs to identify relevant vulnerabilities and apply secure patterns.

Generated from the current SKILL.md.

Does this skill cover prompt injection attacks?
Yes. Prompt Injection (LLM01) is a critical category with dedicated rules for preventing both direct and indirect prompt manipulation in chatbots, RAG systems, and tool-using LLMs.
What LLM APIs and libraries does this apply to?
This skill applies to any application calling OpenAI, Anthropic, Gemini, or similar LLM APIs, and to code using LangChain, LlamaIndex, or comparable LLM frameworks.
Should I use this skill only when the user explicitly asks about security?
No. The skill is designed for proactive use: automatically check for relevant security risks whenever building or reviewing LLM applications, chatbots, RAG pipelines, or AI agents — regardless of whether the user mentions security.
Does this cover RAG system security?
Yes. RAG systems have priority rules for Vector/Embedding Weaknesses (LLM08), Prompt Injection (LLM01), Sensitive Disclosure (LLM02), and Misinformation (LLM09).
Are there code examples for each vulnerability?
Yes. Each of the 10 OWASP categories has a dedicated rule file in `rules/` with vulnerable and secure code examples.

Generated from the current SKILL.md. These answers refresh after source changes.