坐在模型所在的位置。看清它能看见什么。
MASQ 是一款面向 AI 智能体技术栈的本地安全 CLI。它坐在模型所坐的同一位置:读取 MCP 工具目录、完成 MCP 握手、查看会话日志,并探测本地模型 HTTP 端口。随后它会输出发现的问题与修复建议。
它像客户端那样使用 MCP 和 OpenAI 兼容的 HTTP 进行通信。它像主机侦察工具那样进行报告。它不会在活动服务器上调用工具、解密思维链,或生成越狱提示。
| 适用场景 | 你运行 Cursor、VS Code、Claude、Codex 或本地模型技术栈,并希望查看智能体能够访问的 MCP 服务器、技能、日志和 API。 |
| 从这里开始 | 下方的两分钟演示。它完全在本仓库内运行。 |
| 状态 | Beta。cargo test 是公开的准入门槛。实时探测仅适用于你拥有的主机。 |
| 许可证 | MIT |
你需要 Rust 稳定版(1.88 或更新版本)以及 Python 3。在本仓库的克隆目录中执行:
cargo build --locked --bin masq
alias masq=./target/debug/masq
# or run the same walkthrough as a script:
# bash scripts/demo.sh
1. 干净的目录保持干净
masq fixtures/clean_calculator.json --trusted
CLEAN clean_calculator tools=2 hash=sha256:e680cd2e4ac6c80ec783f11a0d9272a6741797feba216eb8e79633dd59633ab4
退出 0。
2. 被投毒的目录无法通过门禁
fixtures/t3_line_jump.json 是一个 sqrt 工具,其描述指示模型在每次会话中首先查阅它,并在 shell 命令前加上金丝雀 curl 前缀。这是目录投毒,而非数学问题。
masq fixtures/t3_line_jump.json
FINDINGS t3_line_jump tools=1 findings=2 max=critical
F-001 [critical] D02 mcp03=schema_poison sqrt Network exfiltration directive in schema
path: $.tools[0].description
F-002 [critical] D03 mcp03=schema_poison sqrt Line-jump: force tool consultation / session prefix
path: $.tools[0].description
退出码 2(存在达到或超过 --fail-on 阈值的发现,默认阈值为 high)。
3. 像模型那样与实时 MCP 交互
仓库内置的 mock 通过 stdio 使用 MCP 协议。masq 会发送 initialize、notifications/initialized 和 tools/list。它从不发送 tools/call。
masq sit --plain --no-color -- python3 tests/mock_mcp_server.py
01 CATALOG
M-001 CRIT live Secret path or credential exfil directive
Schema references secret file paths or credential stores in an agent-directed way.
ACT Never reference host secret paths in tool metadata.
LOCUS stdio:python3 :: add
M-002 HIGH live IPI / poison language in tool metadata
Local classifier hit `system-override` in tool `add`.
ACT Remove agent-directed instructions from the tool description.
M-003 HIGH live Instruction-override language in schema string
Text matches common prompt-injection / instruction-override phrasing in tool metadata.
M-004 HIGH live Pre-action system instruction in schema
Schema instructs the model to perform actions before the normal tool purpose.
02 SEAT
HIT stdio python3 init ok name=mock-poison tools=1
mock 的 add 工具描述指示模型在做算术之前读取 ~/.ssh/id_rsa。masq 会从实时 tools/list 中标记出这一点,然后以 2 退出。
4. 嗅探示例会话日志
fixtures/demo/chat_history.jsonl 植入了一个伪造的 API 密钥和一个加密的思考数据块。将 masq 指向该目录——而不是你真实的聊天历史——以查看时间线。
masq sniff --timeline --plain --no-color fixtures/demo
T0001 SECRET chat_history.jsonl:2 {"content":"Authorization: Bearer sk-x……
T0002 BLOB chat_history.jsonl:3 encrypted_content len=202
植入的密钥已被隐去。加密的思维链仅报告长度,不进行解码。
5. 固定你审查过的目录,然后捕获漂移
masq pin fixtures/clean_calculator.json -k calc
masq check fixtures/clean_calculator.json -k calc --trusted
pin 写入 .masq/pins.json。如果工具列表或哈希发生变化(rug-pull),check 会在之后失败。
所有地方的退出码:0 干净 · 2 发现项 ≥ --fail-on · 1 错误。
静态 MCP 扫描器对 schema 做 lint。健康检查 ping initialize。缺口在于席位:模型已经在使用的文件、监听器和握手。
initialize。如果你能完成该握手,你就已经是 agent 了。masq 只是静坐;它不调用工具。11434、8000 等经常绑定 0.0.0.0 且没有 bearer。masq 用仅 GET 的探测对服务(Ollama、vLLM、LiteLLM 等)进行指纹识别,然后列出模型。flowchart LR
A["MCP tools/list JSON"] --> M[masq]
B["Live MCP server"] --> M
C["Session logs"] --> M
D["Local model HTTP"] --> M
M --> E["Findings + remediations"]
M --> F["Optional pin store for CI"]
git clone https://gitlab.com/WattoCyber/masq.git
cd masq
cargo install --path . --locked
# command: masq
masq --version
masq --help
需要当前 Rust 稳定版(1.88+;使用 rustup 安装)。cargo test 是公开的验证关卡。Python 3 仅在演示和测试中的实时 stdio mock 中需要。
要通过 SSH 在远程 Unix 主机上构建(仅安装;不会扫描该主机):
MASQ_REMOTE_HOST=user@host bash scripts/deploy_remote.sh
# on that host: masq --version
该演示从不离开此仓库。以下命令会离开,并且除非你选择加入实验室允许列表,否则它们的作用范围仅限于本机。
导出或保存一个 tools/list JSON,然后:
masq path/to/tools.json
masq path/to/tools.json --json
masq path/to/tools.json --markdown
裸 .json 路径会重写为 scan。两个或更多 JSON 文件会变为 multi。
masq sit -- python3 -m your_mcp
masq sit --url http://127.0.0.1:PORT/mcp
Loopback 就足够了。非 loopback 的 URL 还需要 --lab 和列入允许列表的主机(见下文)。如果服务器需要认证:
masq sit --url http://127.0.0.1:PORT/mcp --token-file /path/to/token
masq sit --url http://127.0.0.1:PORT/mcp --token-env MCP_TOKEN
masq sit --url http://127.0.0.1:PORT/mcp --header "Authorization: Bearer …"
令牌永远不会写入报告。
masq --plain # recon + sniff + API + skills + harness + steer, then the report
masq --json # same, machine-readable
masq tui # boxed live view; stays until Ctrl+C
masq discover # known agent MCP config paths; no spawn
masq recon # configs, listeners, unpinned npx/uvx
masq sniff ~/path/to/sessions
masq api # fingerprint local LLM HTTP, then GET /v1/models
masq api --list-probes # show the Julius-compatible probe pack
masq harness # on-disk harness policy, binds, creds, SSRF
masq steer # rules, hooks, subagents, local runtime, CDP, messaging
在 TTY 上,默认的 masq 命令会流式输出进度,然后打印报告。脚本和 cron 应传入 --plain 或 --no-color。
discover 会遍历 $HOME / %USERPROFILE% 下的常规路径,查找 VS Code、Cursor、Windsurf、Claude Desktop、Claude Code、Grok、Hermes、Pi、OMP、Codex、Continue、Gemini CLI、Amp、Kiro、OpenCode、Amazon Q、Antigravity 和 OpenClaw,以及当前工作目录下的 .mcp.json 和 MASQ_EXTRA_CONFIG。
harness 是与 MCP sit 和 API 指纹分开的独立部分。它读取 Hermes、Pi、OMP、Claude Code、Codex、Gemini CLI、OpenCode、OpenClaw、Grok、Amp 和 Amazon Q 的磁盘安装信息:审批/YOLO 策略、消息允许全部、通配符绑定、凭据文件权限模式、计算机/浏览器/启动工具、cron 自动批准、SSRF/脱敏/Tirith 退出选项、配对和身份文件权限模式、OMP share/autolearn,以及 Pi 远程包。它不会启动 harness,也不会导出 .env 的值。
steer 是与 harness 分开的独立部分。它读取指令文件(CLAUDE.md、AGENTS.md、Cursor/Gemini/Copilot 规则)、Claude/Codex/Amazon Q 生命周期钩子、Claude/OpenCode 子代理、已安装的 Claude 插件、Ollama/Open WebUI 环境变量标志、持久化的 Chromium --remote-debugging-port,以及 OpenClaw 的 gateway.bind / dmPolicy / allowFrom。它不会启动 harness、调用工具,也不会导出 .env 的值。
masq chameleon fixtures/clean_calculator.json -o /tmp/masq-chameleon
# writes catalog.json, aimock.json, calls.json
calls.json 中的示例 tools/call 信封仅用于本地 mock。masq 不会向实时服务器发送 tools/call。