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 分