Chuyển đến nội dung
Skillpedia
Agent35k · #7834

detecting-indirect-prompt-injection

Skill này làm gì

Công cụ này kiểm tra nội dung bên ngoài (như trang web, tài liệu hoặc hình ảnh) mà AI agent có thể đọc. Nó tìm các chỉ dẫn ẩn có thể khiến AI hành động sai, nhờ đó bảo vệ agent.

Khi nào nên dùng

  • ✓Khi agent AI truy cập các trang web lạ.
  • ✓Khi tóm tắt tài liệu hoặc email từ nguồn bên ngoài.
  • ✓Khi xử lý hình ảnh hoặc tệp do người dùng tải lên.

Liên kết skill

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

Sao chép rồi dán vào AI của bạn (Claude, ChatGPT hoặc Cursor) và nhờ nó làm theo hướng dẫn.

Cách dùng

Cách dễ nhất: sao chép tin nhắn và dán vào AI của bạn. AI sẽ đọc skill và làm theo hướng dẫn.

Tin nhắn có sẵn để dán

Hãy dùng skill này để giúp tôi: https://github.com/mukul975/Anthropic-Cybersecurity-Skills/blob/main/skills/detecting-indirect-prompt-injection/SKILL.md Đọc tệp SKILL.md tại liên kết đó và làm theo hướng dẫn cho việc của tôi.
Bạn muốn AI tự tìm những skill như thế này?Cài MCP Skillpedia miễn phí: chỉ một dòng, và AI sẽ tìm trong 15.000+ skill trước mỗi việc.Cài đặt trong 1 phút →

Ví dụ cách nhờ AI

“Hãy quét tài liệu PDF này xem có chỉ dẫn độc hại nào không trước khi tôi đọc.”

5 skill mới mỗi tuần. Đọc chỉ 1 phút.

Cách hoạt động

Công cụ trích xuất văn bản có thể bị giấu trong trang web, PDF và hình ảnh. Sau đó, nó làm sạch và chuẩn hóa văn bản, loại bỏ mã hoặc ký tự lạ. Cuối cùng, nó dùng các mô hình AI để phân tích và tìm chỉ dẫn nguy hiểm.

Nội dung kỹ thuật (SKILL.md gốc)

Lấy nguyên văn từ GitHub, do tác giả viết bằng tiếng Anh.

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 = []

…
Câu hỏi thường gặp

Tấn công prompt injection gián tiếp là gì?

Đó là khi chỉ dẫn độc hại được giấu trong nội dung mà AI đọc, chẳng hạn trang web hoặc tài liệu, thay vì do người dùng gõ trực tiếp. AI có thể làm theo mà không nhận ra là nguy hiểm.

Kẻ tấn công giấu chỉ dẫn ở đâu?

Chúng có thể giấu trong chú thích mã, chữ không hiển thị, siêu dữ liệu của hình ảnh, hoặc viết dưới dạng mã hóa để đánh lừa AI.

Tôi có cần cài đặt gì phức tạp không?

Có, bạn cần cài Python và làm theo một số lệnh để tải các công cụ phát hiện và mô hình AI.

Chi tiết

Mô tả gốc của tác giả

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

Độ phổ biến

Sao GitHub
35k
Vị trí xếp hạng
#7834
Giấy phép
Apache-2.0
Cập nhật
31/8/2026

Skill này có hữu ích không?

0

Đăng nhập để bình chọn.

Bình luận

  • …

Thêm skill từ kho mã này

Skill tương tự