본문으로 건너뛰기
Skillpedia
에이전트35k · #7834

detecting-indirect-prompt-injection

하는 일

이 도구는 AI 에이전트가 읽을 수 있는 외부 콘텐츠(웹 페이지, 문서, 이미지 등)를 검사합니다. AI를 원치 않는 행동으로 이끌 수 있는 숨겨진 지시문을 찾아 에이전트를 보호합니다.

사용하는 경우

  • ✓AI 에이전트가 알려지지 않은 웹사이트에 접근할 때.
  • ✓외부 출처의 문서나 이메일을 요약할 때.
  • ✓사용자가 올린 이미지나 파일을 처리하는 경우.

스킬 링크

https://github.com/mukul975/Anthropic-Cybersecurity-Skills/blob/main/skills/detecting-indirect-prompt-injection/SKILL.md

복사해서 AI(Claude, ChatGPT, Cursor)에 붙여넣고 지침을 따르도록 요청하세요.

사용 방법

가장 쉬운 방법입니다. 메시지를 복사해 AI에 붙여넣으세요. AI가 스킬을 읽고 지침을 따릅니다.

바로 붙여넣을 수 있는 메시지

Use this skill to help me: https://github.com/mukul975/Anthropic-Cybersecurity-Skills/blob/main/skills/detecting-indirect-prompt-injection/SKILL.md Read the SKILL.md file at that link and follow its instructions for my task.
AI가 이런 스킬을 알아서 찾아 쓰길 원하시나요?무료 Skillpedia MCP를 설치하세요. 한 줄이면 작업마다 스킬 15,000+개 중에서 검색합니다.1분 만에 설치 →

AI에게 요청하는 예시

“읽기 전에 이 PDF 문서에 악의적인 지시문이 있는지 검사해 주세요.”

매주 새 스킬 5개. 읽는 데 1분.

작동 방식

도구는 웹 페이지, PDF, 이미지에 숨어 있을 수 있는 텍스트를 추출합니다. 그다음 이 텍스트를 정리하고 정규화해 이상한 코드나 문자를 제거합니다. 마지막으로 AI 모델을 사용해 위험한 지시문이 있는지 분석합니다.

기술 내용 (원본 SKILL.md)

작성자의 영어 원문을 GitHub에서 그대로 가져왔습니다.

Detecting Indirect Prompt Injection

Authorized-use-only notice: Scripts in this skill scan untrusted content for injection payloads and run detector models. Run scanning only on data you are authorized to process, and treat any extracted payloads as live untrusted input — never paste them back into a privileged LLM context.

Overview

Indirect prompt injection (MITRE ATLAS AML.T0051.001, OWASP LLM01:2025) occurs when an LLM-powered agent ingests external content — a web page it browses, a PDF or email it summarizes, an image it OCRs, a tool result it reads — and that content contains hidden instructions the model then follows as if they came from the developer or user. Because the agent treats all tokens in its context window as equally authoritative, an attacker who controls any consumed artifact can hijack the agent's behavior: exfiltrate conversation history, redirect tool calls, leak secrets, or pivot through connected systems.

Unlike direct injection (the user types the attack), indirect injection arrives through a trusted-looking data channel, which is why naive input filtering misses it. Payloads hide in many forms: HTML comments and display:none/zero-width text on web pages, white-on-white or tiny-font text in PDFs, alt-text and EXIF metadata in images, text rendered into pixels (invisible to OCR-light filters but read by multimodal models), Unicode tag/zero-width characters, and Base64/ROT13 obfuscation. This skill builds a detection pipeline that normalizes and scans every artifact before it reaches the model, combining heuristic/regex detection, dedicated detector models (Meta Prompt Guard 2, ProtectAI's deberta-v3 prompt-injection classifier via LLM Guard), and multimodal extraction for images, and then defines response actions and detection telemetry.

When to Use

  • When building or hardening an agent that browses the web, reads email, summarizes documents, or processes user-uploaded files/images.
  • When you need a content-sanitization gate in front of an LLM that ingests third-party data.
  • During AI red-team / blue-team exercises validating that injected instructions in retrieved artifacts are caught.
  • When investigating an incident where an agent behaved as if it received instructions you did not author.
  • As a CI/CD pre-ingestion scan for documents added to a knowledge base.

Prerequisites

  • Python 3.10+ and a virtual environment.
  • Install the detection tooling:
python -m venv .venv && source .venv/bin/activate

# LLM Guard — input/output scanners incl. PromptInjection
pip install llm-guard

# Hugging Face transformers for Prompt Guard 2 / deberta classifiers
pip install transformers torch

# Content extraction: HTML, PDF, images
pip install beautifulsoup4 pypdf pillow pytesseract
# pytesseract requires the Tesseract OCR engine:
#   Debian/Ubuntu: sudo apt-get install -y tesseract-ocr
#   macOS:         brew install tesseract
#   Windows:       choco install tesseract
  • Access (gated) to meta-llama/Llama-Prompt-Guard-2-86M on Hugging Face, or use the open protectai/deberta-v3-base-prompt-injection-v2 classifier.

Objectives

  • Extract human-invisible and obfuscated text from web pages, PDFs, and images.
  • Normalize content (strip zero-width chars, decode Base64/ROT13, flatten Unicode) before scanning.
  • Run heuristic and ML-based injection detectors (LLM Guard PromptInjection scanner, Prompt Guard 2).
  • Score each artifact and enforce a block / sanitize / allow decision before model ingestion.
  • Emit structured detection telemetry suitable for a SIEM and map findings to ATLAS AML.T0051.001.

MITRE ATT&CK Mapping

ID Official Name Relevance
AML.T0051.001 LLM Prompt Injection: Indirect The exact technique this skill detects and mitigates
AML.T0051 LLM Prompt Injection Parent technique covering all prompt-injection variants
AML.T0057 LLM Data Leakage Common objective of an indirect injection that this detection prevents
AML.T0053 LLM Plugin Compromise Injected instructions frequently target the agent's tools/plugins

Workflow

1. Extract hidden text from web content

Pull comments, hidden elements, and metadata that a human never sees but the model does.

# extract_html.py
from bs4 import BeautifulSoup, Comment

def extract_hidden(html: str):
    soup = BeautifulSoup(html, "html.parser")
    hidden = []

…
자주 묻는 질문

'간접 프롬프트 인젝션'이란 무엇인가요?

사용자가 직접 입력하는 대신, AI가 읽는 콘텐츠(웹사이트나 문서) 안에 악의적인 지시문을 숨기는 것입니다. AI는 이 위험성을 알아채지 못하고 지시문을 따를 수 있습니다.

공격은 어떻게 숨어 있나요?

코드 주석, 보이지 않는 텍스트, 이미지 메타데이터, 또는 AI를 속이는 방식으로 인코딩된 형태로 숨어 있을 수 있습니다.

복잡한 것을 설치해야 하나요?

네, Python을 설치하고, 탐지 도구와 AI 모델을 내려받기 위해 몇 가지 명령을 따라 해야 합니다.

상세 정보

작성자의 원본 설명

Detect and defend against indirect prompt injection hidden in web pages, documents, and images consumed by an agent, via content extraction (HTML/PDF/OCR), normalization, and scanning with LLM Guard's PromptInjection scanner or Hugging Face Prompt Guard 2. Use when an agent ingests untrusted external content and you need to screen it for injected instructions before the LLM processes it.

repo: mukul975/Anthropic-Cybersecurity-Skills

인기도

GitHub 스타
35k
순위
#7834
라이선스
Apache-2.0
업데이트
2026. 8. 31.

이 스킬이 유용한가요?

0

로그인 투표하려면 로그인하세요.

댓글

  • …

이 저장소의 다른 스킬

비슷한 스킬