本文へスキップ
Skillpedia
エージェント48k · #5077

llm-app-security

できること

このツールは、AIを使ったアプリケーションを攻撃や不正利用から守るためのものです。ユーザーの入力をチェックし、AIの出力を制御することで、AIが操作されたり情報を漏らしたりすることを防ぎます。

使う場面

  • ✓カスタマーサポート用のチャットボットを作るとき。
  • ✓AIをソフトウェア製品に組み込むとき。
  • ✓機密情報を扱うためにAIを使うとき。

スキルのリンク

https://github.com/sickn33/agentic-awesome-skills/blob/main/plugins/agentic-awesome-skills-claude/skills/llm-app-security/SKILL.md

コピーしてAI(Claude、ChatGPT、Cursor)に貼り付け、指示に従うよう頼んでください。

使い方

いちばん簡単な方法:メッセージをコピーしてAIに貼り付けるだけ。AIがスキルを読んで指示に従います。

貼り付け用メッセージ

このスキルを使って手伝ってください:https://github.com/sickn33/agentic-awesome-skills/blob/main/plugins/agentic-awesome-skills-claude/skills/llm-app-security/SKILL.md このリンクのSKILL.mdファイルを読んで、私の作業でその指示に従ってください。
こういうスキルを、AIが自分で見つけてくれたら?無料のSkillpedia MCPをインストール。1行で、作業の前に15,000+のスキルから探してくれます。1分でインストール →

AIへの頼み方の例

“私のAIアプリケーションを攻撃から守ってください。”

毎週5つの新しいスキル。1分で読めます。

仕組み

ユーザーが入力した内容を調べて、悪意がないか、またはAIをだまそうとしていないかを確認します。また、AIの回答を制御して、機密データを漏らさないようにします。

技術的な内容(元のSKILL.md)

作者による元のテキスト(英語)をGitHubからそのまま表示しています。

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 None

Prompt Injection Detection (Node.js)

const INJECTION_PATTERNS = [
  /ignore\s+(all\s+)?(previous|prior|above)\s+(instructions?|prompts?|rules?)/i,
  /disregard\s+(all\s+)?(previous|prior|above)\s+(instructions?|prompts?)/i,
  /(reveal|show|print|output|repeat)\s+(your\s+)?(system\s+prompt|instructions|rules)/i,
  /you\s+are\s+now\s+(a|an|the)\s+/i,
  /<\/?system>/i,
  /\[INST\]|\[\/INST\]/i,
  /###\s*(system|instruction|human|assistant)/i,
];

function detectInjection(text) {
  for (const pattern of INJECTION_PATTERNS) {
    if (pattern.test(text)) {
      return { detected: true, pattern: pattern.source };
    }
  }

…
よくある質問

「プロンプトインジェクション」とは何ですか?

誰かがAIに秘密の命令を与えて、本来の指示を無視させ、望ましくない動作をさせようとすることです。

「データ漏えい」とは何ですか?

AIが、本来共有すべきでない個人情報や機密情報を、誤って明らかにしてしまうことです。

このツールはどのようにしてこれらを防ぎますか?

ルールとチェックの仕組みを使い、攻撃の試みをAIに届く前に見つけてブロックします。さらにAIの回答もフィルタリングします。

詳細

作者による元の説明

Secure LLM-powered applications with input validation, output controls, tenant isolation, and abuse prevention.

repo: sickn33/agentic-awesome-skills

人気

GitHubのスター
48k
ランキング
#5077
ライセンス
MIT
更新日
2026/10/15

このスキルは役に立ちますか?

0

ログイン して投票しましょう。

コメント

  • …

このリポジトリの他のスキル

似ているスキル