Skip to the content.

MCPSonar engineering audit (v0.5.0 → v0.6.0)

Date: 2026-10-20 · Baseline: 9098ccb (v0.5.0 + fixes), branch feat/mcpsonar-web-app Scope: src/mcpsonar/**, tests/, .github/workflows/, Dockerfile, compose files, action.yml, pyproject.toml, README.md.

Method

  1. Baseline: pytest -q gave 106 passed (44 s) and ruff check src tests was clean (Python 3.13.1, mcp 1.30.0, httpx 0.28.1, FastAPI 0.139).
  2. Review: every module was read. Each finding below is backed by a reproduction, a failing test written before the fix, or a cited line of code. The README was not taken as evidence.
  3. Fixes: each fix is one reviewable commit with its regression tests. Final state: 201 tests pass, ruff is clean, and pip-audit reports no known vulnerabilities.
  4. End-to-end checks:
    • scripts/smoke_e2e.sh: 20/20 against a running instance.
    • The container image was built and run on a root-owned volume.
    • The dashboard was driven in a browser: setup token, edit with masked credentials.
  5. References:

    Limitation: the external references were gathered by a research pass with web access. OWASP LLM Top 10 entries were confirmed only from secondary sources, and the MCP 2026-07-28 changes come from its changelog page, not a full read of the spec.

Status labels: IMPLEMENTED (code changed) · TESTED (automated regression test) · VERIFIED (manually reproduced end-to-end) · PARTIALLY IMPLEMENTED · PLANNED · ACCEPTED (risk documented, no change).

A. Confirmed vulnerabilities

SEC-01 · Critical · OWASP MCP05, MCP07 · IMPLEMENTED, TESTED, VERIFIED Commit fix(security): block cross-site writes…

SEC-02 · High · MCP07 · IMPLEMENTED, TESTED

SEC-03 · High · MCP07 · IMPLEMENTED, TESTED, VERIFIED

SEC-04 · High · MCP01, MCP10 · IMPLEMENTED, TESTED, VERIFIED

SEC-05 · Medium · MCP07 · IMPLEMENTED, TESTED

SEC-06 · Medium · MCP07 · IMPLEMENTED, TESTED

SEC-07 · Medium · MCP10 · IMPLEMENTED, TESTED, VERIFIED Commit fix(security): outbound connection policy…

SEC-08 · Medium · MCP01 · IMPLEMENTED, TESTED

SEC-09 · Medium · MCP03 · IMPLEMENTED, TESTED

SEC-10 · Low · IMPLEMENTED, TESTED

SEC-11 · Low · MCP08 · IMPLEMENTED, TESTED

SEC-12 · Low · IMPLEMENTED, VERIFIED

SEC-13 · Low · IMPLEMENTED, TESTED

SEC-14 · Low · MCP04 · IMPLEMENTED, VERIFIED

B. Confirmed reliability and protocol defects

REL-01 · High · MCP03 · IMPLEMENTED, TESTED

REL-02 · High · IMPLEMENTED, TESTED

REL-03 · Medium · IMPLEMENTED, TESTED

REL-04 · Medium · IMPLEMENTED, VERIFIED

REL-05 · Medium · MCP02, MCP05 · IMPLEMENTED, TESTED

REL-06 · Low · MCP03 · IMPLEMENTED, TESTED

REL-07 · Low · IMPLEMENTED, TESTED

REL-08 · Low · IMPLEMENTED, TESTED

C. Theoretical threats, accepted risks and limitations

T-01 · High (future compatibility) · IMPLEMENTED, TESTED, VERIFIED in v0.7.0 MCP spec 2026-07-28 removes the initialize handshake and ping, adds a mandatory server/discover, and deprecates HTTP+SSE (per its changelog). mcp 2.x (2.0 released 2026-07-28; 2.3.0 is current) implements it; MCPSonar pins mcp<2. Servers that speak only the new revision will appear down. A spike on SDK 2.x is the top v0.7/v1.0 protocol item (see the roadmap). Not attempted here: it is a major migration that needs its own evidence. Resolved by moving to mcp 2.x: one client negotiates both eras. 24/24 live servers were classified identically, with 42/42 tool fingerprints unchanged, and 5 of them already speak 2026-07-28. See ADR 0001, “Implementation notes”.

T-02 · Medium · ACCEPTED (documented) stdio servers are code execution by design. Mitigations: no shell, minimal environment, refused over an unauthenticated API, and the container runs unprivileged. Real sandboxing (seccomp, a separate container per server) is PLANNED as guidance.

T-03 · Medium · IMPLEMENTED, TESTED in v0.8 (opt-in) Credentials are stored in clear in SQLite (needed to monitor). Plan: a secret-reference syntax (${env:NAME} / ${file:/run/secrets/x}) resolved at check time. Implemented for header and stdio env values; literal credentials still work and are still stored in clear. The references themselves are a new read primitive, so they are allowlisted (MCPSONAR_SECRET_* variables, files under /run/secrets or MCPSONAR_SECRETS_DIR after resolving symlinks): otherwise an API write token, or a shared config file, could make mcpsonar read any variable or file and send it as a header to a server of the author’s choice. Not yet supported in URLs and webhook URLs.

T-04 · Low · ACCEPTED (documented) With HTTP(S)_PROXY set, connections go to the proxy, so IP-level policy is the proxy’s job.

T-05 · Low · ACCEPTED (guarded) The policy hooks httpcore through a private attribute (_pool._network_backend). test_transport_hook_is_installed fails loudly if an upgrade breaks it.

T-06 · Low · ACCEPTED The login throttle lives in memory: it is per process and resets on restart. That is enough for one instance.

T-07 · Low · ACCEPTED The Uptime Kuma push API takes its token in the URL (Kuma’s design). It is masked in every MCPSonar output.

T-08 · Medium · PLANNED (v0.8) Lint heuristics have known false positives and negatives. There is no adversarial corpus yet, no per-rule documentation, and no SARIF output.

T-09 · Medium · PLANNED (v0.7) Anomaly detection:

Addressed in v0.8 (IMPLEMENTED, TESTED): spike episodes are notified once and end with a latency_recovered event; slow checks are excluded from the baseline (resistance to burst poisoning; a gradual drift is still learned as normal, by design); a shift needs a sustained new level and then becomes the baseline; a provisional baseline covers the cold start; the mean absolute deviation replaces a zero MAD. Pinned by tests/corpus/anomaly_scenarios.py.

T-10 · Low · PLANNED Probe responses are read whole; there is no output-size limit.

T-11 · Low · IMPLEMENTED, TESTED in v0.8 SQLite uses one shared connection, no WAL, and ad-hoc ALTER TABLE migrations with no schema version. Resolved: versioned migrations (PRAGMA user_version) with a backup before migrating and a refusal of newer schemas; WAL with a separate read-only connection; one transaction per write under a single-writer lock. Tested against databases created by v0.5.0, v0.6.0 and v0.7.0. SQLite stays the only backend; the Storage class is the seam for an optional PostgreSQL backend if a real deployment needs one.

T-12 · Low · PLANNED There is no password-change or session-list UI. Single admin only: no roles and no audit log.

D. Optional improvements (not defects)

Each is scheduled in product-roadmap.md:

Backwards-compatibility impact

Change Who notices Mitigation
Sessions moved server-side everyone signs in once more passwords keep working
First-admin setup needs a token new installs link printed in the log; MCPSONAR_SETUP_TOKEN
API no longer returns credentials scripts reading tokens back from the API the masked value round-trips; keep secrets in your own store
Export is masked by default backup scripts using /api/export ?include_secrets=true, or back up the SQLite file
--no-auth: loopback Host only, no stdio over API LAN dashboards without a login --allowed-host, --allow-stdio-api
Cross-origin POSTs refused reverse proxies that rewrite Host forward Host or set --trusted-origin
Metadata and link-local targets blocked someone monitoring a link-local MCP server MCPSONAR_ALLOW_LINK_LOCAL=1 / MCPSONAR_OUTBOUND_ALLOW
Probes skip destructive-annotated or unlisted tools configs probing such tools allow_destructive: true
Container user is uid 10001 custom images and bind mounts the entrypoint fixes the volume; set --user if you need another uid
required order ignored in fingerprints lockfile sha256 values may change once lockfile comparison uses the definitions, so no drift is reported