Prompt Leak Scanner

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

Catches leaked credentials and PII in outbound LLM prompts

概览

AI 生成的概览

本地 MCP 服务器,用于扫描发往大模型的提示词中泄露的凭据和个人信息,并可通过反向代理进行脱敏或拦截。

可以做什么
扫描原始文本以及 OpenAI/Anthropic 风格的聊天请求体,查找密钥和个人信息,仅返回掩码后的结果。扫描单个文件或整个提示词日志与测试样本目录,可配置失败阈值和排除项。列出按类别划分的受支持检测模式。可选作为应用与真实 LLM API 之间的反向代理运行,支持监控、脱敏或拦截模式,仅检查出站请求。
适用场景
适用于应用从用户输入、客服工单或粘贴文本构建提示词的场景,希望在内容到达模型前检查 API 密钥、私钥、卡号、IBAN、身份证号、邮箱或电话号码。也适合在 CI 中检查已保存的提示词样本。
运行要求
通过 stdio 在本地运行,通常用 npx 启动,因此需要 Node.js。未声明账户、API 密钥或环境变量。代理模式需要上游 LLM API 地址及访问它的网络。
安装前请注意
代理模式位于真实 LLM API 之前,可对请求进行脱敏或拦截,配置错误可能改变或中断生产流量。遥测默认关闭,但通过 GUARDBEE_TELEMETRY 启用后会发送服务器、工具、成功状态、耗时以及文件路径等短参数值。检测基于模式和校验和,无法识别没有已知结构的个人信息,例如姓名或地址。

安装

在 SourceWeft 中

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

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

其他 MCP 客户端

参照 仓库 中的启动说明。

README

@guardbee/mcp-prompt-leak-scanner

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

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

An MCP (Model Context Protocol) server — and a standalone reverse proxy — that catches leaked credentials and PII in outbound LLM prompts, before they leave your application.

secret-scanner finds secrets sitting in your codebase. This package finds secrets and PII that made it into a runtime prompt — a support agent that pastes a customer's ticket (email, card number) straight into a system prompt, a debugging session where someone pastes an API key into a chat, an internal tool that forwards raw user input to an LLM without ever checking what's in it. That's a different moment in the pipeline, and a different failure mode than a leaked .env file.

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.

Your app ──► prompt-leak-scanner (proxy) ──► Real LLM API (OpenAI/Anthropic/...)                    │                    ├─ monitor: forward unchanged, log findings                    ├─ redact:  forward with matches replaced by [REDACTED:<id>]                    └─ block:   reject the request before it ever reaches the model

Two ways to use it

1. On-demand scanning (MCP tools) — scan_text/scan_messages/scan_file/scan_directory. Ask Claude to check a prompt, a chat-request-body fixture, or a directory of prompt logs before you ship something that builds prompts from user input.

2. A live reverse proxy (proxy CLI command) — sits between your application and the real LLM API. It buffers and inspects only the outbound request body (message/system text), then streams the upstream response straight back unmodified — so SSE/streaming completions pass through untouched; only the prompt going out is ever parsed. Point your app's baseURL at the proxy instead of the real API and nothing else in your integration needs to change.

bash
guardbee-prompt-leak-scanner proxy --upstream=https://api.openai.com --port=8788 --mode=redact# your app: baseURL = http://localhost:8788 instead of https://api.openai.com

Detection quality: checksums, not just regex

A bare regex for "11 digits" or "16 digits" would flag order numbers, phone extensions, and timestamps constantly. Every PII pattern that has a real checksum algorithm uses it:

  • TC Kimlik No — the actual 11-digit Turkish national ID checksum algorithm (not just a digit-count regex)
  • Credit card numbers — Luhn checksum
  • IBAN — ISO 7064 MOD97-10 checksum

A random 11-digit number has roughly a 1-in-10 chance of passing the TC Kimlik checksum by coincidence — regex alone would be far noisier. Credential patterns (API keys, JWTs, private keys) are matched against real provider-specific prefixes/structure (sk-, AKIA, ghp_, -----BEGIN...PRIVATE KEY-----, JWT's three-segment base64url shape), the same low-false-positive approach secret-scanner uses. The checksum validators come from @guardbee/guard-core, shared with @guardbee/mcp-security-proxy.

Findings never echo the real value. A finding's maskedMatch shows only the first 3 and last 2 characters (sk-…wx) — logging or displaying the very thing you just caught would defeat the point. The proxy's audit events go further: they record which pattern fired and where, never the matched text itself.


Features

  • 13 patterns, 4 categories: credential (9), financial-pii (2, checksum-validated), national-id (1, checksum-validated), contact-pii (2)
  • Chat-body aware — understands OpenAI/Anthropic-style messages[].content (string or content-block array) and system fields, not just flat text
  • Live reverse-proxy mode with monitor/redact/block policies — request-only inspection, response streamed through untouched
  • Masked findings and credential-free audit events — the tool never becomes a second copy of the leak
  • SARIF 2.1.0 output — CI/CD integration (GitHub Code Scanning, etc.)
  • Config file support via guardbee.yml
  • 29 unit tests — checksum validators verified against known-good/known-bad test vectors, proxy tested against a real local HTTP client/server round trip (not just in-process mocks) in all three modes

Quick Start

Claude Desktop / MCP Client

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

CLI (CI/CD)

bash
npx @guardbee/mcp-prompt-leak-scanner scan ./prompt-fixtures --fail-on=high --format=sarif > results.sarif

CLI (live proxy)

bash
npx @guardbee/mcp-prompt-leak-scanner proxy --upstream=https://api.openai.com --mode=block --fail-on-severity=critical

MCP Tools

ToolDescription
scan_textScans a raw text string
scan_messagesScans an OpenAI/Anthropic-style chat request body object
scan_fileScans a single file (plain text, or a JSON request-body fixture — auto-detected)
scan_directoryRecursively scans a directory of prompt logs/fixtures
list_patternsLists all supported patterns by category

Detected Patterns

CategoryPatternSeverity
credentialOpenAI / Anthropic / Google / Stripe API key, AWS access key ID, GitHub PAT, Slack token, PEM private key blockcritical
credentialJWThigh
financial-piiCredit card number (Luhn-validated)high
financial-piiIBAN (mod-97 validated)high
national-idTC Kimlik No (checksum-validated)high
contact-piiEmail addressmedium
contact-piiTurkish phone numbermedium

Configuration (guardbee.yml)

yaml
prompt-leak-scanner:  fail-on: high       # any | critical | high | medium | low | none  max-files: 5000  exclude:    - "fixtures/known-safe/"

Limitations (by design)

  • The proxy only inspects the request body; it does not parse or modify streaming SSE responses — those are piped through untouched.
  • Only messages[].content (string or {type:"text"} content blocks) and top-level system are extracted from a chat body; provider-specific fields outside that shape aren't scanned.
  • This is pattern/checksum-based detection, not a general-purpose NER/PII model — it won't catch PII that doesn't match a known structural pattern (e.g. a name or street address in free text).

Development

bash
npm run buildnpm test             # 29 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-leak-scanner/README.md,提交 ae591f4

工具

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

版本历史

3
  1. v0.1.6最新Oct 2, 2026
  2. v0.1.5Sep 30, 2026
  3. v0.1.2Sep 29, 2026

评分

已满足适用检查项的 50%

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

  • 近 30 天内可连通25 分

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

  • 已声明认证方式10 分

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

  • 已列出工具15 分

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

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