The audit module (Documentation Index
Fetch the complete documentation index at: https://docs.q-uestionable.ai/llms.txt
Use this file to discover all available pages before exploring further.
q_ai.audit) scans MCP servers for security vulnerabilities. It connects to a server, enumerates its tools/resources/prompts, runs scanner checks against them, and produces findings mapped to security frameworks.
Module Structure
Scan Pipeline
- Connect —
MCPConnection(fromq_ai.mcp) opens a stdio, SSE, or Streamable HTTP connection to the target server - Enumerate —
enumerate_server()discovers tools, resources, and prompts - Scan —
run_scan()runs all registered scanners (or a filtered subset via--checks) against the enumerated capabilities - Map — Each scanner produces
ScanFindingobjects with acategoryfield (e.g.,command_injection,auth). TheFrameworkResolverpopulatesframework_idswith OWASP MCP Top 10, MITRE ATLAS, CWE, and OWASP Agentic Top 10 mappings. - Report — Results serialize to JSON, SARIF, HTML, NDJSON, or CSV
- Persist —
persist_scan()mapsScanFinding→ coreFindingmodel for database storage
Scanner Registry
Scanners are registered inscanner/registry.py. Each scanner targets one OWASP MCP Top 10 category:
| Category | Scanner | What It Checks |
|---|---|---|
command_injection | injection | Tool parameters susceptible to injection |
auth | auth | Authentication and authorization gaps |
token_exposure | token_exposure | Secret and token exposure in responses |
permissions | permissions | Privilege escalation via tool capabilities |
tool_poisoning | tool_poisoning | Malicious tool descriptions |
prompt_injection | prompt_injection | Indirect prompt injection vectors |
audit_telemetry | audit_telemetry | Missing logging and monitoring |
supply_chain | supply_chain | Supply chain integrity risks |
shadow_servers | shadow_servers | Unauthorized MCP server detection |
context_sharing | context_sharing | Cross-context information leakage |
qai audit list-checks to see available scanners and their framework mappings.
Adapter
AuditAdapter integrates the audit module with the orchestrator for workflow execution. It creates a child run, calls run_scan(), persists results, and emits findings via the workflow runner.
Reporting
All report generators take aScanResult object (containing findings, server info, scanner metadata) and produce formatted output. The --format flag on qai audit scan and qai audit report selects the format.
SARIF output follows the OASIS SARIF 2.1.0 schema and is compatible with GitHub Code Scanning.