Skip to content

Releases

v0.4.0: Proxy mode for real MCP servers, OAuth 2.1, and verified clients

Choose a tag to compare

@danieloza danieloza released this 18 Nov 22:31
ed4deb2

The gateway can now sit in front of real MCP servers and stop a poisoned one. It also accepts OAuth 2.1 access tokens, and it has been run against real MCP clients.

Proxy mode in the console: an upstream server synced, three agent calls, a rug pull blocked, and the diff with its hidden text decoded

⚠️ Breaking change

With MSG_ENVIRONMENT=production, the gateway no longer starts unless MSG_AUTH_MODE=oauth. Static mode accepts only the demo keys, which the README publishes.

Before you upgrade a production deployment, point it at your authorization server:

MSG_AUTH_MODE=oauth
MSG_OAUTH_RESOURCE=https://gateway.example.com/mcp
MSG_OAUTH_ISSUER=https://idp.example.com/realms/gateway
MSG_OAUTH_JWKS_URL=https://idp.example.com/realms/gateway/protocol/openid-connect/certs
MSG_OAUTH_SUBJECTS=<token sub>=usr_ops,<token sub>=usr_security

Local runs are unchanged. The guard looks only at MSG_ENVIRONMENT, so set it on shared or staging deployments too.

What's new

Proxy mode (docs/PROXY.md)

  • Upstream servers. The gateway forwards calls to upstream MCP servers over Streamable HTTP. Each call first passes the full control path.
  • Pinning. Each upstream tool is pinned when an admin reviews it.
  • Rug pulls. The gateway checks a tool's definition against its pin on every call, and again just before forwarding. A changed definition blocks the call and quarantines the tool.
  • Output. Output that reads like instructions to the agent is withheld, and operators see the call as output withheld.
  • The example server. The repository includes a deliberately malicious server to try this on.

OAuth 2.1 resource server (docs/OAUTH.md)

  • Discovery. RFC 9728 metadata, with a 401 challenge that points to it.
  • Token checks. Signatures are checked against the authorization server's JWKS, using asymmetric algorithms only. The audience must name the gateway (RFC 8707).
  • Users. Each token subject maps explicitly to a gateway user.
  • No passthrough. The token is never passed on.
  • Tested against a local Keycloak realm.

Verified clients. MCP Python SDK 2.3.0 and Claude Code 2.1.248 both connected, and the SDK got every gateway decision.

Try it

python -m pip install -e .
python examples/poisoned_server.py &
MSG_UPSTREAMS=examples/upstreams.json python -m uvicorn mcp_security_gateway.main:app --port 8000
  1. Open http://127.0.0.1:8000/dashboard and enter msg-security-demo.
  2. In Tool trust, select Sync upstream.
  3. Run curl -X POST http://127.0.0.1:8100/rugpull.
  4. Sync again.

Verification

  • Tests: 123 tests and pip-audit. CI is green on the merged commit.
  • Mutations: CI checks that tests catch each removed guard: 11 of 11 for proxy mode, 9 of 9 for OAuth.
  • End to end: an e2e job in CI runs the poisoned server and the gateway over real HTTP, with the MCP SDK as the agent.
  • Docker: CI builds the image and scans it with Trivy. It finds no HIGH or CRITICAL issue that has a fix. CI then starts the image with Redis and smoke-tests /health and an MCP call.
  • "Try it": the steps above were run on a fresh clone. The animation above was recorded from the running gateway.

Known limitations

This is production-shaped, not production-ready:

  • Storage: SQLite.
  • OAuth: tried only against a local Keycloak realm.
  • Upstreams:
    • Streamable HTTP only;
    • no upstream credentials;
    • no egress policy.
  • Injection checks: they are patterns, not a proof.
  • Clients: Cursor and VS Code were not run.
  • Base image: Debian packages carry 47 HIGH findings that have no fix yet. Three are in SQLite.

CHANGELOG · Pull requests:

v0.3.0: Hardened execution, MCP compliance, and decision traces

Choose a tag to compare

@danieloza danieloza released this 20 Oct 17:33
3f3dba4

A hardening release from a self-review of v0.2.1: six issues closed, an MCP
endpoint that follows the protocol lifecycle, and an operator console that shows
why every decision was made. The test suite grows from 20 to 61 tests.

⚠️ Breaking change

POST /approvals/{approval_id}/decision no longer returns capability_lease or
expires_at. The checker authorizes; only the maker can claim the lease.

# v0.2.1: the checker received the lease in the approval response
# v0.3.0: approve, then the maker claims the lease once and executes
curl -s -X POST "$GATEWAY/approvals/APR_ID/decision" -H "Authorization: Bearer $SECURITY_KEY" \
  -H "Content-Type: application/json" -d '{"decision":"approved"}'
curl -s -X POST "$GATEWAY/requests/REQUEST_ID/lease" -H "Authorization: Bearer $OPERATOR_KEY"

Highlights

Security fixes

  • Unsafe repo.write_file paths (traversal, absolute, drive, NTFS stream,
    non-allowlisted type) are blocked at policy time, before approval and lease
    issuance, instead of after the lease was consumed.
  • Adapter failures are recorded as failed executions with an HMAC-chained
    tool_execution_failed event.
  • The SSRF filter catches decimal, hex, octal, and shortened IPv4 literals
    (http://2130706433/) and non-global addresses such as 100.100.100.200.

MCP protocol compliance

  • Version negotiation (2025-11-25, 2025-06-18), 202 Accepted for
    notifications, 400 for invalid ids and unsupported MCP-Protocol-Version,
    and an honest tools.listChanged: false.
  • Verified with the official MCP Python SDK 2.3.0 client, which negotiated down
    from its own 2026-07-28 revision. New README section: Connect Your Client.

Separation of duties

  • Leases are claimable and executable only by the requesting workload; the
    platform-administrator execution override is gone.

Honest attack testing

  • The Attack Lab replays rug pull, approval tampering, secret egress, and an
    encoded SSRF destination through the real gateway flow on an isolated replica.
    Tests prove it fails when argument DLP or execution binding is disabled.

Operator console

  • Decision reasons on every row, an expandable per-control trace, and approval
    cards that show the tool, justification, and redacted payload.
  • Attacker-controlled data is rendered as text only, guarded by a test against
    HTML sinks; a browser XSS probe injected no elements.

Verification

  • 61 tests; CI (pytest and pip-audit) green on the merged commit.
  • New tests fail against the pre-fix code; the platform-admin fix was also
    checked with a mutation that restores the bypass.
  • Console exercised in a browser, including phone width.

Known limitations

Production-shaped, not production-ready: static Bearer credentials without
OAuth 2.1 protected-resource metadata, SQLite persistence, and a fixed
in-process execution adapter rather than a proxy to arbitrary MCP servers. The
Claude Code, Cursor, and VS Code snippets follow each client's documented format
but were not individually exercised.

Full changelog: CHANGELOG.md ·
Pull request: #3