Android Security Analyzer
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 工具
工具 | 描述 |
| 对项目文件进行完整安全分析 |
| 列出所有已实现的安全规则 |
| 特定规则的详细说明 |
| 服务器状态和规则引擎统计 |
安装
托管服务器(推荐用于 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添加新规则
在
src/rules/下的相应文件中定义规则在
src/analyzers/下的相应分析器中添加检测逻辑如有需要,在
src/mappings/cwe.ts中添加 CWE 映射添加测试用例
规则通过
src/core/registry.ts自动注册
许可证
MIT
This server cannot be deployed
Maintenance
Related MCP Connectors
MCP server for ScanMalware.com URL scanning, malware detection, and analysis.
MCP server for Appcircle mobile CI/CD platform.
MCP server: static security scanner for MCP servers, agent skills & plugins. 17 attack patterns.
MCP Server for an Agent Task Marketplace
Related MCP Servers
- FlicenseNot gradedqualityDmaintenanceProvides 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-
- FlicenseNot gradedqualityDmaintenanceIntegrates multiple Android APK security analysis tools into MCP standard APIs for automated static and dynamic analysis and vulnerability detection.-
- AlicenseAqualityCmaintenanceMCP server for Android APK triage, providing tools to parse APK headers, list DEX classes, and decode AndroidManifest.xml using apktool or androguard backends.51MIT
- AlicenseNot gradedqualityDmaintenanceLocal 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