fix(deps): require mcp>=1.30.0 for CVE-2026-59951 (#4239)

## Description
Fix CVE-2026-59951 in the existing MCP SDK dependency used by Headroom's
stateful Streamable HTTP server. Require the fixed 1.x SDK while
retaining the existing SDK 2.x exclusion.

## Type of Change
- [x] Bug fix (non-breaking change which fixes an issue)

## Changes Made
- Raise the `proxy` and `mcp` extras to `mcp>=1.30.0,<2.0.0`.
- Update only the MCP package and corresponding requirement metadata in
`uv.lock`.
- Extend the dependency contract to exclude affected 1.29.1 and retain
the SDK 2.x guard.

## Testing
- [x] Unit tests pass (`pytest`)
- Hosted dependency audit passed on this head.
- Maintainer verification: Python 3.12.13 on Windows, installed MCP
1.30.0 in an isolated environment; dependency-contract, MCP HTTP, and
MCP server suites: **27 passed**, two warnings. Confirmed imports came
from the isolated MCP 1.30.0 installation.
- Additional author testing and limitations are preserved below.

## Real Behavior Proof
- Environment: author's macOS 26.7, Python 3.14, MCP 1.30.0.
- Exact command / steps: start `headroom mcp serve --transport http
--port 18788`; initialize, list tools, delete session, retry tools/list
using that session.
- Observed result: initialize 200, initialized 202, tools/list 200;
DELETE 200; reuse of deleted session returns 404. Full author output
below.
- Not tested: live Claude Code stdio session; idle-expiry and
max-session limits; maintainer did not independently repeat the
external-client live proof.

## Runtime Rollout Safety
- Rollout-managed feature(s): none; existing MCP SDK dependency security
update.
- Minimum rollout channel: n/a.
- Stable/default behavior changed: stateful Streamable HTTP sessions
gain the SDK's bounded lifecycle and deletion behavior; SDK 2.x remains
excluded.
- Kill switch / disable path: avoid the HTTP transport; stdio is
unaffected by this advisory.
- Unsafe override required: no.
- Qualification impact: MCP transport compatibility and security audit,
as documented here.
- Rollback path: revert this PR, which would restore the vulnerable SDK
floor and must not be treated as a security remediation.

## Review Readiness
Maintainer review and verification completed for the current head. The
following checklist records maintainer verification, rather than adding
an author attestation.
- [x] I performed self-review
- [x] This PR is ready for human review

## Original author evidence and dependency review

## What we discovered

The `Dependency audit (pip-audit)` check started failing on every open
PR (seen on #4232, #4233, #4236 and #4237):

```
mcp | 1.28.1 | CVE-2026-59951 | 1.30.0,2.2.0
Found 1 known vulnerability in 1 package
```

In `mcp` 1.8.0 through 1.29.1, a Streamable HTTP server in stateful mode
(the default) never reclaimed session state:

- sessions never expired;
- a `DELETE` ended the session but left it registered;
- the number of sessions was unlimited.

A client that can reach the endpoint can therefore grow server memory
without bound. Headroom serves this transport through `headroom mcp
serve --transport http` (`headroom/ccr/mcp_http.py`). The default
`stdio` transport is not affected.

## The fix

- `pyproject.toml`: raise the `mcp` floor in the `proxy` and `mcp`
extras from `>=1.28.1,<2.0.0` to `>=1.30.0,<2.0.0`. The `<2.0.0` cap
stays (SDK 2 removed the server API; that port is #2658).
- `uv.lock`: the only package that changes is `mcp`, 1.28.1 → 1.30.0.
Its dependency list is identical, so nothing else is pulled in or moves.
I locked with uv 0.11.0: newer uv (0.12.x) rewrites unrelated
environment markers across the file, and 0.9/0.8 add extra lines.
- `strands-agents` (locked at 1.24.0) requires `mcp<2.0.0,>=1.11.0`, so
it still resolves; `uv pip compile` of `strands-agents==1.24.0` with
`mcp==1.30.0` succeeds.
- `tests/test_mcp_dependency_contract.py` now also asserts that both
extras exclude 1.29.1 (the last affected version).

## Before / after

| | origin/main | this PR |
|---|---|---|
| `uv export --extra all` → `mcp` | `1.28.1` | `1.30.0` |
| `pip-audit -r requirements-prod.txt` (same command as `security.yml`)
| `Found 1 known vulnerability` (CVE-2026-59951) | `No known
vulnerabilities found` |
| `test_all_shipping_mcp_extras_exclude_incompatible_sdk_v2` | fails
with the new assertion | passes |

## Tests

These ran on mcp 1.30.0 with `uv run --extra proxy --extra mcp --extra
strands --extra dev`:

- `tests/test_mcp_dependency_contract.py`
- `tests/test_ccr_mcp_http.py`, `tests/test_ccr_mcp_server.py`
- `tests/test_mcp_stub.py`, `tests/test_mcp_registry`,
`tests/test_mcp_registry_opencode.py`
- `tests/test_cli/test_mcp.py`
- `tests/test_stateless_no_disk.py`,
`tests/test_content_router_mcp_small_result.py`
- `tests/integrations/test_strands`

Result: 398 passed. The 22 errors are all in
`test_strands/test_model.py::TestHeadroomStrandsModelReal`: those tests
call real Bedrock and fail locally on `botocore TokenRetrievalError`
(expired SSO token), which has nothing to do with mcp.

`uv lock --check`, ruff check, ruff format --check and mypy (`--extra
proxy`, mypy 1.20.2) pass.

## Dependency review (CONTRIBUTING "Dependencies & supply chain")

- **Why this package:** not a new dependency. `mcp` is already a direct
dependency of the `proxy` and `mcp` extras: it is the SDK behind
`headroom mcp serve` (`headroom/ccr/mcp_server.py`, `mcp_http.py`) and
the MCP integration.
- **Who maintains it:** the Model Context Protocol project. The repo is
`modelcontextprotocol/python-sdk` and the license is MIT. Releases are
frequent; recent ones are 1.30.0 and 2.2.0 (2026-09-07, both carrying
this CVE fix), 2.3.0 (2026-10-02), and 2.0.1/2.1.0/2.1.1 in late August.
CVE-2026-59951 was disclosed together with its fix.
- **Install surface:** unchanged. 1.30.0 declares exactly the same
dependencies as 1.28.1 (`anyio`, `httpx`, `httpx-sse`, `jsonschema`,
`pydantic`, `pydantic-settings`, `pyjwt[crypto]`, `python-multipart`,
`pywin32` on Windows, `sse-starlette`, `starlette`, `typing-extensions`,
`typing-inspection`, `uvicorn`), so no new transitive packages are
added. It is a pure-Python wheel with no native code and no install-time
network access. At runtime it opens network sockets only when Headroom
serves or connects over HTTP/SSE, the same as before.
- **Why this version:** a **security patch**. 1.30.0 is the lowest 1.x
release that fixes CVE-2026-59951. 2.x stays excluded until the server
port in #2658 lands.

## Real behavior proof

- **Setup:** macOS 26.7, Python 3.14 (the uv-managed venv), this branch
with `mcp==1.30.0`. Started the real server with `headroom mcp serve
--transport http --port 18788` and drove it with a small httpx
Streamable HTTP client.
- **Output:**
  ```
  initialize 200 {'name': 'headroom', 'version': '1.30.0'} session True
  initialized 202
tools/list 200 ['headroom_compress', 'headroom_retrieve',
'headroom_stats']
  DELETE 200
  tools/list after DELETE 404
  ```
The Headroom MCP server works on 1.30.0, and a deleted session is now
gone (404), per the 1.30.0 fix.
- **Not tested:** the stdio transport inside a real Claude Code session;
the idle-expiry (`session_idle_timeout`, default 1800 s) and
`max_sessions` limits; and Python 3.10–3.13 locally (CI covers them).

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Tejas Chopra
2026-10-15 21:47:54 -05:00
committed by GitHub
co-authored by Claude Opus 5.5
parent 1f71cb3d64
commit 2f7a83a91d

Diff Content Not Available