Codesafer

io.github.goldmembrane由 GitHub 账号 goldmembrane 发布v1.0.1更新于 Oct 24, 2026

Scans AI-generated code for invisible Unicode, Trojan Source, and supply-chain threats.

已验证STDIO仅桌面开发者工具安全与监控

概览

AI 生成的概览

在本地扫描 AI 生成的代码和 AI 规则文件,发现隐藏 Unicode、Trojan Source、同形字、混淆和依赖威胁。

可以做什么
CodeSafer 是一个本地 MCP 服务器,提供六个工具:scan_file、scan_directory、scan_rules_file、check_dependencies、ai_analyze 和 explain_finding。它结合八个针对已知攻击类别的确定性静态扫描器,以及一个 CodeBERT 变换器分类器,用于将代码片段判定为恶意或良性。结果以内联方式返回,包含严重程度、行号和修复建议,同时还会检查 .cursorrules、CLAUDE.md 等 AI 配置文件是否被植入后门。
适用场景
当助手编写或审查代码,而你希望在代码运行前做一次安全检查时使用,尤其针对隐藏 Unicode、BiDi/Trojan Source、同形字、隐写、混淆和仿冒依赖风险。它也适合审计 AI 规则和配置文件是否被注入指令。
运行要求
需要 Node.js 18 或更高版本,以及兼容 MCP 的客户端,例如 Claude Code、Cursor、VS Code + Copilot 或 Cline。它以本地 stdio 进程运行,通常用 node 指向构建后的入口文件启动。未声明任何账户、API 密钥、环境变量或请求头。
安装前请注意
README 称分析在本地运行、不上传代码,但 ai_analyze 被描述为针对分词器服务器运行。静态工具无限制,但 ai_analyze 每个会话包含 10 次免费运行,更高配额需付费计划,因此反复深度分析可能产生费用。该服务器会读取你指定的文件和目录,包括 AI 配置文件。

安装

在 SourceWeft 中

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

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

其他 MCP 客户端

参照 仓库 中的启动说明。

README

CodeSafer (cleaner-code)

AI code security scanner as a Model Context Protocol (MCP) server. Detects hidden threats in AI-generated code that traditional linters miss.

[npm] [license: ISC] [Node]

Website: codesafer.org  ·  MCP Clients: Claude Code, Cursor, VS Code + Copilot, Cline


Why CodeSafer?

AI coding assistants generate code fast — but who's checking it for hidden threats?

Recent supply-chain attacks show that malicious code can hide in ways human reviewers and traditional linters routinely miss:

  • Invisible Unicode characters injected into identifiers (30+ variants)
  • BiDi / Trojan Source attacks that reorder how code is displayed vs. executed (CVE-2021-42574)
  • Homoglyphs — Cyrillic characters masquerading as Latin (CVE-2021-42694)
  • Glassworm-style Unicode steganography hiding payloads in whitespace
  • Rules file backdoors planted in .cursorrules, CLAUDE.md, and other AI config files
  • Typosquatted dependencies in package.json
  • Obfuscation patterns — eval + base64, reverse shells, packed payloads

CodeSafer scans for all of these before the code runs on your machine.


How it works

CodeSafer runs as a local MCP server. Your AI client (Claude Code, Cursor, etc.) calls its tools when reviewing or generating code, and findings are returned inline.

Hybrid detection:

  1. 8 static analysis scanners — deterministic rules for known attack categories (fast, zero false-negatives on the patterns they cover).
  2. CodeBERT deep analysis — transformer model classifies code chunks as malicious/benign with confidence scores. Catches obfuscated or novel patterns that static rules miss.

Nothing leaves your machine. The AI analysis runs locally against a tokenizer server.


Features

CapabilityDetails
Invisible character detection30+ Unicode variants including Zero-Width Space, Mongolian Vowel Separator
BiDi / Trojan SourceFull CVE-2021-42574 coverage
Homoglyph detectionCyrillic/Greek/Latin confusables (CVE-2021-42694)
Unicode steganographyGlassworm-style whitespace payloads
Rules file backdoorsScans .cursorrules, CLAUDE.md, .claude/, Cursor rules
Dependency scanningTyposquatting + suspicious install scripts in package.json
Obfuscation detectioneval + base64, reverse shells, packed payloads
AI deep analysisCodeBERT transformer classifier with confidence scores
MCP native6 MCP tools, stdio transport
Local-firstNo code uploaded — runs entirely on your machine

MCP Tools

CodeSafer exposes six tools to your MCP client:

ToolPurpose
scan_fileScan a single file for hidden malicious code patterns
scan_directoryRecursively scan a directory across all source files
scan_rules_fileScan an AI configuration/rules file for prompt injection and Rules File Backdoor attacks
check_dependenciesCheck package.json for typosquatting, suspicious install scripts, and dependency risks
ai_analyzeDeep AI analysis using the trained CodeBERT model (classifies chunks as malicious/benign with confidence)
explain_findingGet detailed explanation of a specific threat category, with attack scenarios and remediation

Installation

Prerequisites

  • Node.js 18 or later
  • An MCP-compatible client (Claude Code, Cursor, VS Code + Copilot, Cline)

From source

bash
git clone https://github.com/goldmembrane/cleaner-code.gitcd cleaner-codenpm installnpm run build

Configure your MCP client

Claude Code (~/.claude.json or project .mcp.json):

json
{  "mcpServers": {    "codesafer": {      "command": "node",      "args": ["/absolute/path/to/cleaner-code/dist/index.js"]    }  }}

Cursor (.cursor/mcp.json):

json
{  "mcpServers": {    "codesafer": {      "command": "node",      "args": ["/absolute/path/to/cleaner-code/dist/index.js"]    }  }}

Restart your client, and CodeSafer tools will appear in the tool picker.


Usage

Once configured, ask your AI client things like:

  • "Scan this file for hidden security issues."
  • "Check the dependencies in package.json for typosquatting."
  • "Scan .cursorrules for a rules-file backdoor."
  • "Run a deep AI analysis of src/auth.ts."
  • "Explain what a Trojan Source attack is and how to fix the finding above."

The client will call the appropriate MCP tool and return findings with severity, line numbers, and remediation guidance.


Free tier & Plans

CodeSafer is free to use. Static analysis (scan_file, scan_directory, scan_rules_file, check_dependencies, explain_finding) has no limits.

AI deep analysis (ai_analyze) includes 10 free runs per session. Paid plans for higher AI quotas are available at codesafer.org.


Detection categories

CodeSafer detects threats across 9 categories:

  1. Invisible Unicode characters — 30+ variants including Zero-Width Space, Zero-Width Joiner
  2. BiDi / Trojan Source attacks — CVE-2021-42574
  3. Homoglyphs — Cyrillic/Greek characters masquerading as Latin (CVE-2021-42694)
  4. Unicode steganography — Glassworm patterns in whitespace
  5. Rules file backdoors — malicious instructions in .cursorrules, CLAUDE.md, etc.
  6. Dependency risks — typosquatting and suspicious install scripts
  7. Obfuscation patterns — eval + base64, packed payloads, reverse shells
  8. Static analysis findings — 8 deterministic scanners
  9. AI deep analysis — CodeBERT transformer for novel and obfuscated threats

Project structure

cleaner-code/├── src/│   ├── index.ts           # MCP server entry point│   ├── api-server.ts      # Optional HTTP API server│   ├── types.ts           # Scanner interfaces│   ├── utils.ts           # File collection, summary formatting│   └── scanner/│       ├── invisible.ts       # Invisible Unicode scanner│       ├── bidi.ts            # BiDi / Trojan Source scanner│       ├── homoglyph.ts       # Homoglyph scanner│       ├── encoding.ts        # Encoding / charset scanner│       ├── obfuscation.ts     # Obfuscation pattern scanner│       ├── steganography.ts   # Unicode steganography scanner│       ├── rules-backdoor.ts  # Rules file backdoor scanner│       ├── dependency.ts      # Dependency risk scanner│       └── ai-analyzer.ts     # CodeBERT deep analyzer├── ml/                    # ML model assets and tokenizer├── functions/             # Cloud function deployments├── deploy/                # Deployment manifests└── web/                   # Landing page assets

License

ISC — see the LICENSE file for details.


Links

来源:README.md,提交 1fee55e

工具

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

版本历史

1
  1. v1.0.1最新Sep 16, 2026

评分

已满足适用检查项的 50%

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

  • 近 30 天内可连通25 分

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

  • 已声明认证方式10 分

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

  • 已列出工具15 分

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

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