codesafer
CodeSafer (cleaner-code)
Model Context Protocol (MCP) サーバーとして動作するAIコードセキュリティスキャナー。 従来のリンターでは見逃される、AI生成コード内の隠れた脅威を検出します。
ウェブサイト: codesafer.org · MCPクライアント: Claude Code, Cursor, VS Code + Copilot, Cline
CodeSaferを選ぶ理由
AIコーディングアシスタントは高速にコードを生成しますが、その中に隠れた脅威がないか誰がチェックしているのでしょうか?
近年のサプライチェーン攻撃では、人間のレビューアや従来のリンターが日常的に見逃してしまうような方法で悪意のあるコードが隠されることが明らかになっています:
不可視のUnicode文字:識別子に注入される(30種類以上)
BiDi / Trojan Source攻撃:コードの表示順序と実行順序を入れ替える(CVE-2021-42574)
ホモグラフ:ラテン文字になりすましたキリル文字など(CVE-2021-42694)
Glassworm形式のUnicodeステガノグラフィ:空白文字にペイロードを隠蔽
ルールファイルのバックドア:
.cursorrules、CLAUDE.md、その他のAI設定ファイルに仕込まれるタイポスクワッティングされた依存関係:
package.json内難読化パターン:
eval+ base64、リバースシェル、パックされたペイロード
CodeSaferは、コードがマシン上で実行される前に、これらすべてをスキャンします。
Related MCP server: guardvibe
仕組み
CodeSaferはローカルのMCPサーバーとして動作します。AIクライアント(Claude Code、Cursorなど)がコードのレビューや生成を行う際にツールを呼び出し、結果がインラインで返されます。
ハイブリッド検出:
8つの静的解析スキャナー — 既知の攻撃カテゴリに対する決定論的なルール(高速で、対象パターンに対する偽陰性はゼロ)。
CodeBERTディープ解析 — トランスフォーマーモデルがコードチャンクを悪意のあるものか良性のものか、信頼スコア付きで分類。静的ルールでは見逃される難読化されたパターンや新しいパターンを捕捉します。
データがマシンから外部へ送信されることはありません。AI解析はローカルのトークナイザーサーバーに対して実行されます。
機能
機能 | 詳細 |
不可視文字検出 | ゼロ幅スペース、モンゴル語母音分離記号を含む30以上のUnicodeバリアント |
BiDi / Trojan Source | CVE-2021-42574を完全網羅 |
ホモグラフ検出 | キリル文字/ギリシャ文字/ラテン文字の混同(CVE-2021-42694) |
Unicodeステガノグラフィ | Glassworm形式の空白文字ペイロード |
ルールファイルのバックドア |
|
依存関係スキャン |
|
難読化検出 |
|
AIディープ解析 | 信頼スコア付きのCodeBERTトランスフォーマー分類器 |
MCPネイティブ | 6つのMCPツール、stdioトランスポート |
ローカルファースト | コードのアップロードなし — すべてマシン上で実行 |
MCPツール
CodeSaferはMCPクライアントに対して6つのツールを提供します:
ツール | 目的 |
| 単一ファイルをスキャンして隠れた悪意のあるコードパターンを検出 |
| ディレクトリ内のすべてのソースファイルを再帰的にスキャン |
| AI設定/ルールファイルをスキャンしてプロンプトインジェクションやルールファイルバックドア攻撃を検出 |
|
|
| 学習済みCodeBERTモデルを使用したAIディープ解析(チャンクを悪意/良性に分類し信頼スコアを算出) |
| 特定の脅威カテゴリの詳細な説明、攻撃シナリオ、修正方法を取得 |
インストール
前提条件
Node.js 18以降
MCP対応クライアント(Claude Code, Cursor, VS Code + Copilot, Cline)
ソースからインストール
git clone https://github.com/goldmembrane/cleaner-code.git
cd cleaner-code
npm install
npm run buildMCPクライアントの設定
Claude Code (~/.claude.json またはプロジェクトの .mcp.json):
{
"mcpServers": {
"codesafer": {
"command": "node",
"args": ["/absolute/path/to/cleaner-code/dist/index.js"]
}
}
}Cursor (.cursor/mcp.json):
{
"mcpServers": {
"codesafer": {
"command": "node",
"args": ["/absolute/path/to/cleaner-code/dist/index.js"]
}
}
}クライアントを再起動すると、ツールピッカーにCodeSaferツールが表示されます。
使用方法
設定後、AIクライアントに以下のように指示を出します:
"このファイルをスキャンして隠れたセキュリティ上の問題がないか確認して。"
"package.jsonの依存関係にタイポスクワッティングがないかチェックして。"
"
.cursorrulesをスキャンしてルールファイルのバックドアがないか確認して。""
src/auth.tsに対してAIディープ解析を実行して。""Trojan Source攻撃とは何か、そして上記の検出結果をどう修正すればよいか説明して。"
クライアントは適切なMCPツールを呼び出し、重大度、行番号、修正ガイダンスを含む結果を返します。
無料枠とプラン
CodeSaferは無料で使用できます。静的解析(scan_file、scan_directory、scan_rules_file、check_dependencies、explain_finding)には制限がありません。
AIディープ解析(ai_analyze)には、セッションごとに10回の無料実行枠が含まれています。より高いAIクォータが必要な場合は、codesafer.orgで有料プランをご利用いただけます。
検出カテゴリ
CodeSaferは9つのカテゴリにわたる脅威を検出します:
不可視のUnicode文字 — ゼロ幅スペース、ゼロ幅結合子など30以上のバリアント
BiDi / Trojan Source攻撃 — CVE-2021-42574
ホモグラフ — ラテン文字になりすましたキリル文字/ギリシャ文字(CVE-2021-42694)
Unicodeステガノグラフィ — 空白文字内のGlasswormパターン
ルールファイルのバックドア —
.cursorrules、CLAUDE.md等に含まれる悪意のある指示依存関係のリスク — タイポスクワッティングおよび不審なインストールスクリプト
難読化パターン —
eval+ base64、パックされたペイロード、リバースシェル静的解析結果 — 8つの決定論的スキャナー
AIディープ解析 — 新規および難読化された脅威に対するCodeBERTトランスフォーマー
プロジェクト構造
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ライセンス
ISC — 詳細は LICENSE ファイルを参照してください。
リンク
ウェブサイト: codesafer.org
Model Context Protocol: modelcontextprotocol.io
問題を報告: GitHub Issues
Available Tools
6 toolsai_analyzeA
Deep AI analysis of code using the trained CodeBERT model. Classifies code chunks as malicious or benign with confidence scores. Detects obfuscated payloads, novel attack patterns, and threats that static rules may miss.
Inputs: file_path (required).
check_dependenciesB
Check package.json for typosquatting, suspicious install scripts, and dependency risks
Inputs: file_path (required).
explain_findingA
Get detailed explanation of a specific threat category including attack scenarios, real-world examples, and remediation steps
Inputs: category (required).
scan_directoryB
Recursively scan a directory for hidden malicious code patterns across all source files
Inputs: dir_path (required), extensions.
scan_fileB
Scan a single file for hidden malicious code patterns (invisible chars, BiDi, homoglyphs, steganography, obfuscation, etc.)
Inputs: file_path (required).
scan_rules_fileA
Scan an AI configuration/rules file for prompt injection and Rules File Backdoor attacks
Inputs: file_path (required).
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 6 tools
Each tool has a clearly distinct purpose: scan_file vs scan_directory differ by scope, ai_analyze uses ML, check_dependencies focuses on dependencies, and scan_rules_file is for configuration files. No ambiguity.
Tools mostly follow verb_noun snake_case pattern (e.g., scan_file, check_dependencies). The outlier is ai_analyze, which uses a prefix instead of a verb-noun structure, but it's still clear and consistent overall.
With 6 tools covering scanning, AI analysis, dependency checks, and explanations, the count is well-scoped for a focused security analysis server. Not too many or too few.
The tools cover core scanning and analysis tasks well, including file/directory scanning, dependency risks, AI-based analysis, and explanations. A minor gap is the lack of a tool for aggregated reporting or finding management, but the surface is largely complete for detection and explanation.
Maintenance
Related MCP Connectors
Audit your MCP servers for poisoned tools and leaked secrets, and check AI-generated code for flaws.
Zero-config MCP security scanner for AI-generated apps. 25K+ vulnerability patterns.
Security scanner for MCP servers. Detect vulnerabilities, prompt injection, and tool poisoning.
Security scanner for AI agents and MCP servers: injection, jailbreak, tool abuse.
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceSecurity scanner for MCP servers and AI-generated code. Detects leaked API keys, PII, prompt injection, and MCP misconfigs with A-F security grades.MIT
- AlicenseBqualityBmaintenanceSecurity MCP server with 300+ rules for AI-generated code. Scans Next.js, Supabase, Clerk, Stripe, Prisma, Hono, GraphQL and 20+ modules. Zero config, runs locally.392,686 npm6Apache 2.0
- AlicenseAqualityBmaintenanceMCP security server for AI coding agents. 12 tools: pre-install guardian, vulnerability audit, supply-chain attack detection via static code analysis, and CycloneDX 1.6 SBOM generation. Zero runtime dependencies.1581 npm15Apache 2.0
- AlicenseNot gradedqualityCmaintenanceScans MCP servers, AI agent skills, and plugins for 68+ malicious patterns including credential exfiltration, prompt injection, and code execution.65 npm5MIT