Skip to main content
Glama
ako2345

Android Security Analyzer

by ako2345

Android SecurityAnalyzer

Androidアプリケーションのソースコードを静的セキュリティ解析するためのMCPサーバーです。Cloudflare Workers上でリモートMCPサーバーとして動作し、Streamable HTTPを介して通信します。

機能

Androidプロジェクトのソースファイルを解析し — プロジェクトをビルドすることなく — 構造化されたセキュリティレポートを返します。解析対象は以下の通りです:

  • Manifest解析 — エクスポートされたコンポーネント、危険なパーミッション、平文トラフィック、デバッグフラグ、バックアップ設定、SDKバージョン

  • Gradle/ビルド設定 — リリースビルドの設定ミス、古いSDK、不審な依存関係、ハードコードされたシークレット

  • ソースコード(Java/Kotlin) — 安全でないWebView、SSL/TLSバイパス、脆弱な暗号化、SQLインジェクションパターン、プロセス実行、安全でないファイル保存、PendingIntentの問題

  • XML設定 — ネットワークセキュリティ設定の脆弱性、過度に広いfile providerパス

  • シークレットスキャン — APIキー、トークン、パスワード、秘密鍵、クラウド認証情報、高エントロピー文字列

すべての解析は正規表現/パターンベースで、Workersランタイム内でネイティブに実行されます。外部ツール、Java、Android SDKは不要です。

Related MCP server: APK Security Guard MCP Suite

アーキテクチャ

POST /mcp ──► McpServer (JSON-RPC 2.0) ──► Tool Router
                                              │
              ┌───────────────────────────────┘
              ▼
         Orchestrator
              │
    ┌─────────┼─────────┬─────────────┬──────────────┐
    ▼         ▼         ▼             ▼              ▼
 Manifest  Gradle   Source Code   XML Config    Secret
 Analyzer  Analyzer  Analyzer     Analyzer     Scanner
    │         │         │             │              │
    └─────────┴─────────┴─────────────┴──────────────┘
              │
              ▼
     Scoring + Deduplication ──► AnalysisReport

主要な設計上の決定:

  • ステートレス — セッションなし、Durable Objectsなし

  • 最小限のMCP JSON-RPC 2.0実装(重いSDK依存なし)

  • 拡張可能なルールレジストリを備えたデータ駆動型ルールエンジン

  • 統一されたFinding型を持つ独立したアナライザー

  • fast-xml-parserによる軽量なXML解析

  • zodによる入力検証

  • バンドルサイズ: ~66KB gzip圧縮後

MCPツール

ツール

説明

analyze_android_project

プロジェクトファイルの完全なセキュリティ解析

list_android_security_checks

実装済みの全セキュリティルールを一覧表示

explain_finding

特定のルールの詳細な説明

health

サーバーの状態とルールエンジンの統計

インストール

ホスト型サーバー(Cline / MCPクライアント推奨): ローカルインストールは不要です。サーバーは以下で実行されています:

https://android-security-analyzer.ako-labs.workers.dev/mcp

このURLをMCPクライアント設定に追加してください(下記のMCPクライアントからの接続を参照)。

ローカル開発:

npm install

開発

npm run dev

これによりローカルのWrangler開発サーバーが起動します。MCPエンドポイントは http://localhost:8787/mcp で利用可能です。

デプロイ

npm run deploy

Cloudflare Workersにデプロイします。wrangler の認証(npx wrangler login)が必要です。

テスト

npm test              # Run all tests
npm run test:watch    # Watch mode
npm run typecheck     # TypeScript type checking

ローカルMCPテスト

接続の初期化

Unix:

curl -X POST http://localhost:8787/mcp \
  -H "Content-Type: application/json" \
  -d '{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2025-03-26","capabilities":{},"clientInfo":{"name":"test","version":"1.0"}}}'

Windows(PowerShell):

(Invoke-WebRequest -Method Post -Uri "http://localhost:8787/mcp" -ContentType "application/json" -Body '{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2025-03-26","capabilities":{},"clientInfo":{"name":"test","version":"1.0"}}}' -UseBasicParsing).Content

利用可能なツールの一覧表示

Unix:

curl -X POST http://localhost:8787/mcp \
  -H "Content-Type: application/json" \
  -d '{"jsonrpc":"2.0","id":2,"method":"tools/list"}'

Windows(PowerShell): 応答は result.tools に含まれます。JSONとして一覧を表示するには、生の応答を使用してください:

(Invoke-WebRequest -Method Post -Uri "http://localhost:8787/mcp" -ContentType "application/json" -Body '{"jsonrpc":"2.0","id":2,"method":"tools/list"}' -UseBasicParsing).Content

またはオブジェクト経由: (Invoke-RestMethod ...).result.tools | ConvertTo-Json -Depth 5

ヘルスチェック

Unix:

curl -X POST http://localhost:8787/mcp \
  -H "Content-Type: application/json" \
  -d '{"jsonrpc":"2.0","id":3,"method":"tools/call","params":{"name":"health","arguments":{}}}'

Windows(PowerShell):

(Invoke-WebRequest -Method Post -Uri "http://localhost:8787/mcp" -ContentType "application/json" -Body '{"jsonrpc":"2.0","id":3,"method":"tools/call","params":{"name":"health","arguments":{}}}' -UseBasicParsing).Content

解析の実行(最小限の例)

Unix:

curl -X POST http://localhost:8787/mcp \
  -H "Content-Type: application/json" \
  -d '{
    "jsonrpc": "2.0",
    "id": 4,
    "method": "tools/call",
    "params": {
      "name": "analyze_android_project",
      "arguments": {
        "projectName": "TestApp",
        "files": [
          {
            "path": "app/src/main/AndroidManifest.xml",
            "content": "<manifest><application android:debuggable=\"true\" android:allowBackup=\"true\"></application></manifest>"
          }
        ]
      }
    }
  }'

Windows(PowerShell):

$body = @{
  jsonrpc = "2.0"
  id = 4
  method = "tools/call"
  params = @{
    name = "analyze_android_project"
    arguments = @{
      projectName = "TestApp"
      files = @(
        @{
          path = "app/src/main/AndroidManifest.xml"
          content = "<manifest><application android:debuggable=`"true`" android:allowBackup=`"true`"></application></manifest>"
        }
      )
    }
  }
} | ConvertTo-Json -Depth 10
(Invoke-WebRequest -Method Post -Uri "http://localhost:8787/mcp" -ContentType "application/json" -Body $body -UseBasicParsing).Content

MCPクライアントからの接続

MCPクライアント設定に以下を追加してください:

{
  "mcpServers": {
    "android-security-analyzer": {
      "url": "http://localhost:8787/mcp"
    }
  }
}

本番環境(ホスト型)の場合:

{
  "mcpServers": {
    "android-security-analyzer": {
      "url": "https://android-security-analyzer.ako-labs.workers.dev/mcp"
    }
  }
}

セキュリティルール

アナライザーは5つのカテゴリにわたる53のセキュリティルールを実装しています:

カテゴリ

プレフィックス

ルール数

例

Manifest

MAN-*

17

debuggable、allowBackup、エクスポートされたコンポーネント、パーミッション

Gradle

GRD-*

9

リリース設定、SDKバージョン、依存関係、シークレット

Source

SRC-*

17

WebView、SSL/TLS、暗号化、インジェクション、ファイル保存

XML Config

XML-*

4

ネットワークセキュリティ設定、file providerパス

Secret

SEC-*

7

APIキー、トークン、パスワード、クラウド認証情報

各Findingには以下が含まれます:

  • 安定したルールID

  • 重大度(critical/high/medium/low/info)と信頼度(high/medium/low)

  • ファイルパスと行番号(特定できる場合)

  • 証拠スニペット

  • CWEおよびOWASP Mobile Top 10のマッピング

  • 実践可能な推奨事項

スコアリング

リスクスコア(0〜100)はFindingの重大度から計算されます:

  • Critical: 9ポイント

  • High: 6ポイント

  • Medium: 3ポイント

  • Low: 1ポイント

  • Info: 0ポイント

生の合計は、想定される最大値50ポイントに対して正規化されます。

制限事項

  • SASTの代替ではない — パターン/正規表現ベースのヒューリスティックであり、完全なAST/データフロー解析ではない

  • ビルド不要 — 生のソースを解析するため、ビルド時の変換は見えない

  • 誤検知の可能性あり — 特にシークレットスキャンといくつかのコードパターンで発生し得る

  • Workersの制約 — 128MBのメモリ制限、CPU時間制限、ファイルシステムアクセスなし

  • APK/AAB解析なし — ソースコードのみ

  • プロシージャ間解析なし — パターンはファイル単位で照合され、コールグラフ全体では照合されない

プロジェクト構造

src/
├── index.ts                          # Worker entry point
├── server/
│   ├── mcp.ts                        # MCP JSON-RPC 2.0 handler
│   └── tools/                        # MCP tool implementations
│       ├── analyzeAndroidProject.ts
│       ├── listAndroidSecurityChecks.ts
│       ├── explainFinding.ts
│       └── health.ts
├── core/
│   ├── types.ts                      # TypeScript types & Zod schemas
│   ├── scoring.ts                    # Risk score computation
│   ├── registry.ts                   # Rule registry
│   └── orchestrator.ts              # Analysis orchestrator
├── analyzers/
│   ├── manifestAnalyzer.ts
│   ├── gradleAnalyzer.ts
│   ├── sourceAnalyzer.ts
│   ├── xmlConfigAnalyzer.ts
│   └── secretScanner.ts
├── parsers/
│   ├── xml.ts                        # XML parser wrapper
│   ├── gradle.ts                     # Gradle file parser
│   ├── source.ts                     # Source code pattern matcher
│   └── files.ts                      # File classifier
├── rules/
│   ├── manifestRules.ts
│   ├── gradleRules.ts
│   ├── sourceRules.ts
│   ├── xmlRules.ts
│   └── secretRules.ts
├── mappings/
│   ├── cwe.ts                        # CWE descriptions
│   └── owaspMobile.ts               # OWASP Mobile Top 10
└── utils/
    ├── lines.ts                      # Line number utilities
    ├── paths.ts                      # Path classification
    └── text.ts                       # Text utilities
test/
├── fixtures/                         # Sample Android project files
├── unit/                             # Unit tests per module
└── integration/                      # Full analysis integration tests

新しいルールの追加

  1. src/rules/ 配下の適切なファイルにルールを定義する

  2. src/analyzers/ 配下の対応するアナライザーに検出ロジックを追加する

  3. 必要に応じて src/mappings/cwe.ts にCWEマッピングを追加する

  4. テストケースを追加する

  5. ルールは src/core/registry.ts を介して自動的に登録される

ライセンス

MIT

Related MCP Connectors

Related MCP Servers

  • F
    license
    Not graded
    quality
    D
    maintenance
    Provides a one-stop automated solution for Android APK security analysis by integrating tools like JEB, JADX, APKTOOL, FlowDroid, and MobSF into unified MCP standard API interfaces.
    11
    -
  • A
    license
    A
    quality
    C
    maintenance
    MCP server for Android APK triage, providing tools to parse APK headers, list DEX classes, and decode AndroidManifest.xml using apktool or androguard backends.
    5
    1
    MIT
  • A
    license
    Not graded
    quality
    D
    maintenance
    Local static-analysis assistant for Android malware research that manages investigation cases, exposes MCP tools via a local server, and persists evidence-backed findings without cloud dependency.
    MIT