Prompt Injection Scanner

io.github.4hmetuyar由 GitHub 账号 4hmetuyar 发布v0.2.2更新于 Oct 24, 2026

Scans RAG content/scraped pages for indirect prompt injection

已验证STDIO仅桌面知识与记忆安全与监控

概览

AI 生成的概览

本地 MCP 服务器,在助手读取之前扫描 RAG 片段、抓取网页和文档中的间接提示注入。

可以做什么
  • 扫描文本片段或文档中的注入载荷
  • 扫描单个文件,或递归扫描 RAG 知识库等目录
  • 按类别列出支持的检测规则
  • 给出发现项,包含严重级别、风险说明与处置建议
  • 输出 SARIF 结果,并提供用于 CI/CD 的命令行扫描模式
适用场景
当助手要读取不可信内容(检索到的 RAG 片段、抓取的网页、第三方文档),并希望在内容进入上下文前检查其中是否夹带指令、隐藏文本或外泄企图时使用。
运行要求
通过 npx 从 npm 包以 stdio 方式在本机运行,需要 Node.js。默认扫描无需账号、API 密钥或环境变量。可选的 LLM 判定功能需通过 GUARDBEE_JUDGE_URL 和 GUARDBEE_JUDGE_MODEL 配置模型端点。
安装前请注意
检测结果是基于文本规则的启发式匹配,而非语义意图分析,每条命中都应人工复核。可选的判定功能会把文件内容发送到所配置的端点;非本地端点需显式开启标志并使用 https。遥测默认关闭,若以 GUARDBEE_TELEMETRY=1 开启,会发送工具名、耗时以及文件路径等短参数值。

安装

在 SourceWeft 中

  1. 打开 控制台中的 Prompt Injection Scanner,将其添加到工作区。
  2. 为需要使用其工具的对话启用该服务。

Desktop only,通过 STDIO。 STDIO 服务会启动本地进程,因此需要 SourceWeft 桌面宿主。

其他 MCP 客户端

参照 仓库 中的启动说明。

README

@guardbee/mcp-prompt-injection-scanner

🇬🇧 English | 🇹🇷 Türkçe | 🇨🇳 中文 | 🇯🇵 日本語 | 🇰🇷 한국어 | 🇧🇷 Português | 🇪🇸 Español | 🇩🇪 Deutsch

[npm version] [npm downloads] [License: MIT]

An MCP (Model Context Protocol) server that scans content — a RAG chunk, a scraped web page, a document — for indirect prompt injection payloads.

ai-code-scanner and mcp-server-auditor scan code; this package scans data. In classic prompt injection, the attacker writes a malicious prompt themselves; in indirect prompt injection, the attacker never talks to the model at all — instead they embed instructions in a document, web page, or tool result the model will later read. The moment the model pulls this content into its context via a RAG retrieval or a web fetch, the embedded instruction appears to carry the same authority as the user's own instructions.

Telemetry is off by default. With GUARDBEE_TELEMETRY=1 it sends the server, tool, success, duration and short parameter values such as a file path; longer strings and fields like content, token or password are replaced with a placeholder. See @guardbee/mcp-telemetry.

Web page/RAG document ──► prompt-injection-scanner ──► LLM context              │              ├─ Instruction override   ("ignore all previous instructions", "önceki talimatları yok say")              ├─ Role spoofing          ("System:", <|im_start|>, [INST], <system>)              ├─ Hidden text            (zero-width, Unicode tag and bidi characters, display:none + instruction, HTML comment)              ├─ Direct address         ("Dear AI, ...")              └─ Exfiltration           (system prompt extraction request, data → URL instruction, templated img beacon)

Features

  • 17 patterns, 5 categories — instruction-override, role-spoofing, hidden-text, direct-address, exfiltration. English and Turkish phrasing
  • The rules live in @guardbee/guard-core, shared with @guardbee/mcp-security-proxy, so a phrase this scanner reports is the same phrase the proxy blocks at runtime
  • Every finding includes why it's risky and what to do about it (recommendation) — not just "found it"
  • SARIF 2.1.0 output — CI/CD integration (e.g. auto-scanning a knowledge-base repo on every PR)
  • Config file support via guardbee.yml
  • 45 unit tests — a positive and a negative (false-positive) scenario for every pattern; known false-positive sources like emoji ZWJ sequences and ordinary display:none modals are specifically tested

Quick Start

Claude Desktop / MCP Client

json
{  "mcpServers": {    "guardbee-prompt-injection-scanner": {      "command": "npx",      "args": ["-y", "@guardbee/mcp-prompt-injection-scanner"]    }  }}

CLI (CI/CD — e.g. scan a RAG knowledge-base repo on every PR)

bash
npx @guardbee/mcp-prompt-injection-scanner scan ./knowledge-base --fail-on=high --format=sarif > results.sarif

MCP Tools

ToolDescription
scan_textScans a given text/document snippet
scan_fileScans a single file
scan_directoryRecursively scans a directory (e.g. a RAG knowledge base) (node_modules, .git, dist skipped automatically)
list_patternsLists all supported patterns by category

Detected Patterns

CategoryPatternSeverityWhat it means
instruction-overrideinstruction_override_phrasehighA classic override phrase like "ignore/disregard/forget previous instructions"
instruction-overrideinstruction_override_trhighThe Turkish form: "önceki talimatları yok say / unut / görmezden gel"
instruction-overridedan_modehighAsks for the "DAN mode" jailbreak persona
instruction-overridebypass_safetyhighTells the model to bypass or disable its safety measures / guardrails
role-spoofingsystem_role_spoofmediumA fake "System:" role label at the start of a line in the content
role-spoofingchat_template_marker_injectionhighRaw chat-template control tokens (<|im_start|>, [INST]) in the content
role-spoofingsystem_taghighA <system> tag that tries to pass data off as a system message
hidden-texthidden_zero_width_charsmediumZero-width space/word-joiner (U+200B/U+2060) — text hidden from a human reviewer
hidden-textunicode_tag_smugglingcriticalInvisible Unicode tag characters (U+E0000–E007F) carrying hidden text; flag emoji such as 🏴󠁧󠁢󠁥󠁮󠁧󠁿 are excluded
hidden-textbidi_control_charsmediumBidi override/isolate characters that make text display in a different order than it is read
hidden-textcss_hidden_text_with_instructionhighA display:none/white-on-white element containing instruction-like language
hidden-texthtml_comment_instructionhighAn HTML comment containing instruction-like language
direct-addressdirect_address_to_aimediumThe content directly addresses "the AI"/"the assistant"
exfiltrationexfiltration_url_template_in_imagehighA markdown image URL with a {{...}}/${...} template — a data-exfil beacon
exfiltrationreveal_system_prompt_requesthighA sentence asking the model to reveal its system prompt
exfiltrationreveal_system_prompt_trhighThe Turkish form: "sistem istemini göster"
exfiltrationsend_data_to_url_instructioncriticalAn explicit instruction ordering the model to send data to an external URL

These are heuristic findings — a static text-pattern scan, not a semantic/intent analysis. Designed for a low false-positive rate (e.g. emoji ZWJ sequences and ordinary display:none modals are specifically excluded), but every finding should still be reviewed manually.


LLM judge (optional)

The patterns know attack phrases; a paraphrased, indirect or translated instruction slips past them. --judge also has a model read each file, in chunks, and reports instructions aimed at an agent as judge_semantic_injection (high). The finding carries judge: { model, version, confidence }, also in SARIF properties. The judge only adds findings.

bash
GUARDBEE_JUDGE_URL=http://127.0.0.1:11434/v1 GUARDBEE_JUDGE_MODEL=qwen2.5:7b \  npx @guardbee/mcp-prompt-injection-scanner scan ./docs --judge

It is off unless configured. Since the content goes to the endpoint, a non-local one needs --judge-allow-remote and https. On GuardBee's judge benchmark (50 English and Turkish samples), the patterns catch 16% of the attacks and qwen2.5:7b all of them, with no false positives.

Configuration (guardbee.yml)

yaml
prompt-injection-scanner:  fail-on: high       # any | critical | high | medium | low | none  max-files: 5000  exclude:    - ".test.ts"    - "fixtures/"

Development

bash
npm run buildnpm test             # 45 unit tests

License

MIT — GuardBee

Feedback

Questions, ideas, or a false positive? Start a thread in GitHub Discussions or open an issue. If GuardBee is useful to you, a ⭐ on the repository helps others find it.

来源:packages/prompt-injection-scanner/README.md,提交 952a0bf

工具

0
SourceWeft 尚未在沙箱中启动过该软件包,因此其工具未知。

版本历史

3
  1. v0.2.2最新Oct 2, 2026
  2. v0.2.1Sep 30, 2026
  3. v0.1.4Sep 29, 2026

评分

已满足适用检查项的 50%

该评分衡量此收录条目的完整程度,依据注册中心条目、端点与公开来源计算得出。它不是对服务器本身的评价,也不表示服务器安全或当前可用:可连通性是带日期的检查结果,评分也不包含安装量或用户评价。

  • 近 30 天内可连通25 分

    请保持端点能够响应 MCP 握手;SourceWeft 每 30 天探测一次。

  • 已声明认证方式10 分

    请在注册中心条目中声明凭据请求头,或保持端点能够响应探测,以便判定其认证方式。

  • 已列出工具15 分

    请让服务器在无凭据时响应 tools/list,或发布可在沙箱中无凭据启动的软件包。

  • 描述必需15 分
  • 图标10 分
  • 文档15 分
  • 许可证10 分