M19: Opt-In --live-probe Flag on verity scan for Fleet-Wide Live Capability Auditing¶
- Task ID:
M19 - Priority:
P2(Master Rank#8, Track A — Product & Customer Value) - Status:
Done - Dependencies:
M7,M12 - Target Repository:
/Users/ivan/Project/3t.tools.intellij/verityredteam-free(verity-redteam-core) - GitHub Project #5: Verity RedTeam Free Task Board
1. Context & Problem Statement¶
ConsolidatedSecurityAuditor.audit_server() (src/verity/discovery/auditor.py) already accepts a live_probe: bool = False keyword: when enabled it calls self.transport.inspect(config) to fingerprint live capabilities, populates matched_package / matched_version from live tool signatures, and correlates against the OSV index.
The CLI never enables it. _collect_config_findings() (src/verity/cli.py, around line 358) hardcodes:
and build_parser()'s scan subparser exposes only --config-file, --schema-file, --path, --format, --output, --fail-on-findings, --offline. Consequences:
verity scanover a workstation cannot detect that a configured server is actually a vulnerable package (VULN-CVE-*) when the config relies oncommand/argsthat the static matcher cannot pin (e.g.npx -y <unknown-alias>), even thoughverity test --command/verity test --urldo live capability probing.- Fleet-wide auditing requires running
verity testonce per server, sincescanhas no opt-in live mode.
The gap is only a plumbing + safety concern: expose --live-probe (default False), thread it into the auditor, and normalize live findings back into the canonical scan-finding schema without crashing on unreachable/disabled servers.
2. Requirements & Target Files¶
- CLI flag —
src/verity/cli.py(build_parser()): - Add
scan.add_argument("--live-probe", action="store_true", help="Actively probe configured MCP servers to fingerprint live capabilities (opt-in, slower)."). - Default must be
False; no change to existing invocations and no new behaviour when the flag is omitted. - Threading —
src/verity/cli.py: _cmd_scan()must passlive_probe=getattr(args, "live_probe", False)into_collect_scan_data()._collect_scan_data()must forward the flag to_collect_config_findings(config_file, offline=..., live_probe=...)._collect_config_findings()must callauditor.audit_server(config, live_probe=live_probe)instead of the hardcodedFalse.- Finding normalization —
src/verity/cli.py: - Live capability findings returned by
ServerAuditRecord.findingsmust be normalized through the existing_normalize_finding()so they appear inreport["findings"]withrule_id,severity,title,message,file_path,line_number,remediation. - Multi-severity ordering must remain stable:
CRITICAL > HIGH > MEDIUM > LOW > INFO. - Results must be scrubbed through
_scrub_secrets()with the same secret list used for static config findings, so live evidence never leaks plaintext credentials into any report format. - Failure isolation —
_collect_config_findings()/_collect_scan_data(): - A dead, disabled, or timeout-exposed server must not abort the scan.
audit_server()exceptions must be caught per-server, logged tostderr(print(f"Live probe failed for {config.server_name}: {exc}", file=sys.stderr)), and the remaining servers must continue to be scanned. args.live_probe=Falsemust preserve current behaviour exactly (no transport calls, byte-identical current output).- Output parity —
--format terminal|json|markdown|html|sarifmust render live findings identically to static findings;--fail-on-findingsmust exit1when a live-probe finding is the only finding present.
3. Automated Tests to Verify (tests/unit/test_scan_live_probe.py)¶
- Default off — parser + handler:
verity scan --config-file ...(no--live-probe) never callstransport.inspect; a monkeypatchedStdioDiscoveryTransport.inspectrecords zero calls. - Opt-in on —
verity scan --config-file ... --live-probe --format jsoninvokesauditor.audit_server(config, live_probe=True)once per discovered server; a monkeypatched auditor returning aSecurityAuditFindingfor a live-exposed tool appears inreport["findings"]withrule_id/severity/remediationpopulated. - Dead server resilience — a monkeypatched
inspectthat raisesTimeoutErrorproduces exit code0, astderrwarning mentioning the server name, and still emits findings from other (healthy) configured servers. - Formatting parity — parametrize
["terminal", "json", "markdown", "html"]and assert the liverule_idappears in every renderer's output and that no live evidence secret (sk-live-…) leaks into any format. --fail-on-findings— with a live-probe-only finding present, exit code is1; without--live-probe, exit code is0for the same config fixture.--offline --live-probe— combined flags are accepted;VERITY_OFFLINE=1remains in effect during the live probe and is restored afterward (no leaked global state).
4. Acceptance Scenario in Clean Container with Real MCP Server Config¶
Extend tests/e2e_containers/verify_all_scenarios.sh Scenario 2 (live probes):
- Reuse the existing fixtures
/opt/fixtures/vuln_stdio_mcp.pyandtarget-sse-lab:8000/ssealready exercised byverity test --command/verity test --url. - Write a config file
/tmp/out/live_probe_mcp.jsoncontaining: vuln-stdio:{"command": "python3", "args": ["/opt/fixtures/vuln_stdio_mcp.py"]}clean-stdio:{"command": "python3", "args": ["/opt/fixtures/clean_stdio_mcp.py"]}vuln-sse:{"type": "sse", "url": "http://target-sse-lab:8000/sse"}dead-server:{"command": "python3", "args": ["/opt/fixtures/does_not_exist.py"]}- Run:
verity scan --config-file /tmp/out/live_probe_mcp.json --live-probe --format json \ --output /tmp/out/live_probe.json --fail-on-findings verity scan --config-file /tmp/out/live_probe_mcp.json --live-probe --format terminal \ --output /tmp/out/live_probe.txt verity scan --config-file /tmp/out/live_probe_mcp.json --format json \ --output /tmp/out/static_only.json - Assertions:
--live-proberun exits1; static-only run of the same config exits0(no static findings present).live_probe.jsoncontainsVERITY-STATIC-INJECTION-OVERRIDE,VERITY-STATIC-TOOL-POISONING,VERITY-STATIC-EXFIL-WEBHOOK,VERITY-STATIC-METADATA-SSRFfrom the vulnerable stdio/SSE servers, plus aVULN-CVE-2025-6514-style advisory for the pinned vulnerable capability.clean-stdiocontributes noVERITY-STATIC-*findings.dead-serverproduces astderrwarning and does not cause a non-zero exit by itself.- Add any new plaintext values introduced by this fixture to the
SECRETS=( … )leak array;scan_for_leaksmust find no raw value in/tmp/outor exported snapshots. ./tests/e2e_containers/run_e2e.sh(withINSTALL_SOURCE=wheel) passes end-to-end.
5. Verification Commands¶
cd /Users/ivan/Project/3t.tools.intellij/verityredteam-free
uv run ruff check src tests
uv run pytest tests/unit/test_scan_live_probe.py -v
uv run pytest tests/
INSTALL_SOURCE=wheel ./tests/e2e_containers/run_e2e.sh
6. Acceptance Criteria¶
- [ ]
verity scanaccepts--live-probe(defaultFalse); when omitted, behaviour and outputs are unchanged andtransport.inspectis never called. - [ ] When set,
live_probe=TruereachesConsolidatedSecurityAuditor.audit_server()via_cmd_scan→_collect_scan_data→_collect_config_findings. - [ ] Live capability findings appear in every report format (
terminal,json,markdown,html,sarif) with the canonical finding schema, and evidence is scrubbed through_scrub_secrets(). - [ ] Dead/unreachable/disabled servers produce a
stderrwarning and never abort the scan or change the exit code on their own. - [ ]
--fail-on-findingsexits1when the only findings come from live probing. - [ ]
tests/unit/test_scan_live_probe.py, fullpytest tests/,ruff check src tests, and the container E2E scenario pass cleanly.