Memory Poisoning Scanner

io.github.GuardBee由 GitHub 账号 GuardBee 发布v0.3.1更新于 Nov 3, 2026

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

发布方自己的服务:Memory.fit

概览

AI 生成的概览

扫描 AI 代理源码中的记忆投毒模式:不可信输入被写入持久记忆,或召回的记忆被当作可信指令回灌给模型。

可以做什么
  • 扫描代码片段、单个文件或递归扫描整个目录,查找记忆写入与记忆回读模式
  • 识别原始输入被写入 MemGPT 式归档记忆或核心记忆、向量库,以及自定义命名的长期记忆或知识库
  • 识别记忆或向量检索结果流入 system/assistant 角色消息或提示词模板
  • 按类别列出全部支持的检测模式及其严重级别
  • 输出可供 CI/CD 使用的结果,包括 SARIF 格式与 guardbee.yml 配置文件
适用场景
适用于审查或审计带有长期记忆或向量知识库的代理代码,找出不可信输入可能变成可信上下文的代码位置。它是针对代码形态的静态启发式检查,而非对已存记忆的运行时检查。
运行要求
以 stdio 方式在本机运行,通常通过 npx 启动 npm 包 @guardbee/mcp-memory-poisoning-scanner,因此需要 Node.js 以及获取该包的网络访问。未声明认证、环境变量或请求头。
安装前请注意
检测结果是启发式模式匹配,并非已证实的数据流,命名不同的自建记忆系统可能被漏检。遥测默认关闭;设置 GUARDBEE_TELEMETRY=1 后会向第三方发送服务器、工具、成功与否、耗时以及文件路径等短参数值,较长字符串及 content、token、password 等字段会被替换为占位符。

安装

在 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,提交 bc5997d

工具

4

scan_text

Scan agent code for memory-poisoning risks: untrusted input written into persistent, cross-session memory (MemGPT-style archival/core memory, or a vector store used as a long-term knowledge base) without visible sanitization, and memory retrievals fed into a system/assistant-role message or prompt template as trusted context.

输入参数labelcontent必填

scan_file

Scan a single file for memory-write and memory-readback poisoning patterns

输入参数path必填

scan_directory

Recursively scan a directory of agent source code for memory-poisoning patterns

输入参数path必填excludeincludemaxFiles

list_patterns

List every memory-write and memory-readback pattern this scanner detects, grouped by category

无需输入参数。

版本历史

3
  1. v0.3.1最新Oct 30, 2026
  2. v0.2.2Oct 22, 2026
  3. v0.1.3Oct 13, 2026

评分

已满足适用检查项的 90%

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

  • 近 30 天内可连通25 分
  • 已声明认证方式10 分

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

  • 已列出工具必需15 分
  • 描述必需15 分
  • 图标10 分
  • 文档15 分
  • 许可证10 分

其他 Memory 集成