Memory Poisoning Scanner

io.github.4hmetuyar由 GitHub 帳號 4hmetuyar 發布v0.1.2更新於 Nov 3, 2026

Scans agent code for untrusted input poisoning persistent cross-session memory

發布方自己的服務:Memory.fit

概覽

AI 產生的概覽

本機 MCP 伺服器,掃描代理程式原始碼中的記憶體投毒模式:不受信任的輸入被寫入持久記憶,或被召回進受信任的提示詞。

可以做什麼
  • 掃描程式碼片段、單一檔案,或遞迴掃描整個目錄,找出記憶體投毒模式
  • 依類別列出支援的記憶寫入與記憶回讀模式
  • 輸出從 medium 到 critical 的嚴重性結果,可選 SARIF 2.1.0 格式供 CI/CD 使用
  • 讀取 guardbee.yml 設定,例如失敗門檻、檔案數量上限與排除規則
適用情境
適合在檢視或稽核具有長期記憶、歸檔/核心記憶或向量知識庫的代理程式程式碼庫時使用,確認不受信任的輸入是否未經清理就寫入其中,或被召回進 system/assistant 訊息。也適合在 CI 流程中對高嚴重性結果直接失敗。
執行需求
透過 npx 從 npm 套件 @guardbee/mcp-memory-poisoning-scanner 以本機程序執行,需要 Node.js 以及下載套件的網路存取。未宣告帳號、API 金鑰或標頭。可透過 guardbee.yml 檔案進行選用設定。
安裝前請注意
結果是啟發式模式比對,並非已證實的資料流漏洞鏈,且涵蓋範圍依賴 MemGPT 術語或通用命名,自訂記憶系統可能被漏檢。它檢查的是程式碼,而非執行時實際儲存的記憶。遙測預設關閉;設定 GUARDBEE_TELEMETRY=1 會把伺服器、工具、成功與否、耗時以及檔案路徑等短參數值傳送給第三方。

安裝

在 SourceWeft 中

  1. 開啟 儀表板中的 Memory Poisoning Scanner,將其新增到工作區。
  2. 為需要使用其工具的對話啟用該服務。

Desktop only,透過 STDIO。 STDIO 服務會啟動本機處理程序,因此需要 SourceWeft 桌面主機。

其他 MCP 客戶端

參照 儲存庫 中的啟動說明。

README

@guardbee/mcp-memory-poisoning-scanner

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

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

An MCP (Model Context Protocol) server that scans agent code for memory poisoning — untrusted input written into an agent's persistent, cross-session memory that later gets recalled and fed back to the model as trusted context, potentially in a completely unrelated future session.

prompt-injection-scanner catches an injection payload sitting in content the model reads once (a document, a scraped page). This package catches something structurally different: the code pattern that lets an injection payload become part of what the model treats as its own long-term knowledge — the same gap between reflected and stored XSS, applied to an agent's memory instead of a browser's DOM.

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.

Claude ──► memory-poisoning-scanner ──► Your agent's source              │              ├─ memory-write     (untrusted input persisted into archival/core memory or a vector KB)              └─ memory-readback  (recalled memory fed into a system/assistant-role message or prompt)

Why ordinary conversation memory is out of scope

A ConversationBufferMemory holding raw chat turns, or a plain chatHistory.push({role: "user", content: userInput}), is completely normal — that's just conversation history, not a vulnerability. This package deliberately does not flag that.

What it targets is narrower and higher-stakes: writes to persistent memory that outlives the current conversation — MemGPT-style archival memory (recalled across future, unrelated sessions) and core memory (re-injected into the system prompt on every turn by design), or a vector store used as a long-term knowledge base rather than per-conversation RAG context. If untrusted input lands there unsanitized, it doesn't just influence the current exchange — it becomes part of what the agent believes is true, for anyone, indefinitely, until someone happens to notice.

The second half of the risk is symmetric: a memory/vector retrieval result flowing directly into a system/assistant-role message or a prompt template is where a poisoned memory "cashes out" as an instruction the model obeys rather than data it merely reads.


Features

  • 5 memory-write patterns: MemGPT archival_memory_insert/core_memory_append/core_memory_replace fed raw input, vector store add_texts/add_documents/upsert fed raw input, and a generic catch-all for custom-named long-term-memory/knowledge-base stores
  • 3 memory-readback patterns: archival/vector retrieval results flowing into a system/assistant-role message, or interpolated directly into a prompt template
  • SARIF 2.1.0 output — CI/CD integration (GitHub Code Scanning, etc.)
  • Config file support via guardbee.yml
  • 17 unit tests — a positive and a negative (false-positive) scenario for every pattern, including an explicit check that ordinary conversation-buffer usage produces zero findings. End-to-end verified against a realistic planted-vulnerability fixture (caught both the write and the read-back) and the entire guardbee-mcp monorepo (386 files, zero false positives in production code)

Quick Start

Claude Desktop / MCP Client

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

CLI (CI/CD)

bash
npx @guardbee/mcp-memory-poisoning-scanner scan ./src --fail-on=high --format=sarif > results.sarif

MCP Tools

ToolDescription
scan_textScans a code snippet
scan_fileScans a single file
scan_directoryRecursively scans a directory
list_patternsLists all supported patterns by category

Detected Patterns

CategoryPatternSeverity
memory-writearchival_memory_insert_raw_inputcritical
memory-writecore_memory_write_raw_input (append/replace)critical
memory-writevector_store_add_raw_inputhigh
memory-writegeneric_named_memory_write_raw_inputmedium
memory-readbackarchival_memory_feeds_trusted_rolecritical
memory-readbackvector_retrieval_feeds_trusted_rolehigh
memory-readbackmemory_retrieval_feeds_prompt_templatehigh

Configuration (guardbee.yml)

yaml
memory-poisoning-scanner:  fail-on: high       # any | critical | high | medium | none  max-files: 5000  exclude:    - ".test.ts"

Limitations (by design)

  • Heuristic, not taint tracking. The write and read-back checks each look at one bounded location, not a proven data-flow path from a specific write to a specific later read. A finding means the shape of the risk is present in the code, not a mathematically confirmed exploit chain.
  • Pattern coverage is MemGPT-terminology and generic-JS-naming based. A custom-built long-term memory system using entirely different function/variable names won't be recognized unless it happens to match the generic patterns (*memory*/*knowledge_base* naming, or a vectorstore-style API).
  • This finds code patterns that enable memory poisoning, not an actual poisoned memory store at runtime — pair it with prompt-injection-scanner (for scanning what's actually stored) if you can inspect the memory contents directly.

Development

bash
npm run buildnpm test             # 17 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/memory-poisoning-scanner/README.md,提交 040e072

工具

0
SourceWeft 尚未在沙箱中啟動過該軟體包,因此其工具未知。

版本歷史

1
  1. v0.1.2最新Sep 29, 2026

評分

已滿足適用檢查項的 50%

該評分衡量此收錄條目的完整程度,依據註冊中心條目、端點與公開來源計算得出。它不是對伺服器本身的評價,也不表示伺服器安全或目前可用:可連通性是帶日期的檢查結果,評分也不包含安裝量或使用者評價。

  • 近 30 天內可連通25 分

    請保持端點能夠回應 MCP 握手;SourceWeft 每 30 天探測一次。

  • 已宣告認證方式10 分

    請在註冊中心條目中宣告憑證請求標頭,或保持端點能夠回應探測,以便判定其認證方式。

  • 已列出工具15 分

    請讓伺服器在無憑證時回應 tools/list,或發布可在沙箱中無憑證啟動的軟體包。

  • 描述必需15 分
  • 圖示10 分
  • 文件15 分
  • 授權條款10 分

其他 Memory 整合