Skip to main content
Glama
ako2345

Android Security Analyzer

by ako2345

Android Security Analyzer

用于 Android 应用程序源代码静态安全分析的 MCP 服务器。运行在 Cloudflare Workers 上,作为通过 Streamable HTTP 的远程 MCP 服务器。

功能

分析 Android 项目源文件——无需构建项目——并返回结构化的安全报告。分析涵盖:

  • Manifest 分析 — 导出的组件、危险权限、明文流量、调试标志、备份设置、SDK 版本

  • Gradle/构建配置 — release 构建错误配置、过时的 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 gzipped

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

release 配置、SDK 版本、依赖、密钥

源代码

SRC-*

17

WebView、SSL/TLS、加密、注入、文件存储

XML 配置

XML-*

4

网络安全配置、file provider 路径

密钥

SEC-*

7

API 密钥、令牌、密码、云凭据

每条发现包括:

  • 稳定的规则 ID

  • 严重性(critical/high/medium/low/info)和置信度(high/medium/low)

  • 文件路径和行号(在可确定时)

  • 证据片段

  • CWE 和 OWASP Mobile Top 10 映射

  • 可操作的建议

评分

风险评分(0-100)根据发现严重性计算:

  • 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

F
license - not found
Not graded
quality - not tested
D
maintenance

Maintenance

Maintainers
Response time
Release cycle
Releases (12mo)
Commit activity

Resources

Unclaimed servers have limited discoverability.

Looking for Admin?

If you are the server author, to access and configure the admin panel.

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
    B
    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

View all related MCP servers

Related MCP Connectors

View all MCP Connectors

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/ako2345/android-security-analyzer'

If you have feedback or need assistance with the MCP directory API, please join our Discord server