
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.
概覽
在本機掃描 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 金鑰、環境變數或標頭。
安裝
在 SourceWeft 中
- 開啟 儀表板中的 Codesafer,將其新增到工作區。
- 為需要使用其工具的對話啟用該服務。
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.
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:
- 8 static analysis scanners — deterministic rules for known attack categories (fast, zero false-negatives on the patterns they cover).
- 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
MCP Tools
CodeSafer exposes six tools to your MCP client:
Installation
Prerequisites
- Node.js 18 or later
- An MCP-compatible client (Claude Code, Cursor, VS Code + Copilot, Cline)
From source
Configure your MCP client
Claude Code (~/.claude.json or project .mcp.json):
Cursor (.cursor/mcp.json):
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
.cursorrulesfor 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:
- Invisible Unicode characters — 30+ variants including Zero-Width Space, Zero-Width Joiner
- BiDi / Trojan Source attacks — CVE-2021-42574
- Homoglyphs — Cyrillic/Greek characters masquerading as Latin (CVE-2021-42694)
- Unicode steganography — Glassworm patterns in whitespace
- Rules file backdoors — malicious instructions in
.cursorrules,CLAUDE.md, etc. - Dependency risks — typosquatting and suspicious install scripts
- Obfuscation patterns —
eval+ base64, packed payloads, reverse shells - Static analysis findings — 8 deterministic scanners
- AI deep analysis — CodeBERT transformer for novel and obfuscated threats
Project structure
License
ISC — see the LICENSE file for details.
Links
- Website: codesafer.org
- Model Context Protocol: modelcontextprotocol.io
- Report issues: GitHub Issues
來源:README.md,提交 1fee55e
工具
0版本歷史
1- v1.0.1最新Sep 16, 2026
評分
已滿足適用檢查項的 50%
該評分衡量此收錄條目的完整程度,依據註冊中心條目、端點與公開來源計算得出。它不是對伺服器本身的評價,也不表示伺服器安全或目前可用:可連通性是帶日期的檢查結果,評分也不包含安裝量或使用者評價。
- 近 30 天內可連通25 分
請保持端點能夠回應 MCP 握手;SourceWeft 每 30 天探測一次。
- 已宣告認證方式10 分
請在註冊中心條目中宣告憑證請求標頭,或保持端點能夠回應探測,以便判定其認證方式。
- 已列出工具15 分
請讓伺服器在無憑證時回應 tools/list,或發布可在沙箱中無憑證啟動的軟體包。
- 描述必需15 分
- 圖示10 分
- 文件15 分
- 授權條款10 分