Skip to content

Bound the checkpoint size accepted by the migration endpoint#264

Merged
seanwevans merged 1 commit into
mainfrom
claude/migration-blob-len-bound
Jul 20, 2026
Merged

Bound the checkpoint size accepted by the migration endpoint#264
seanwevans merged 1 commit into
mainfrom
claude/migration-blob-len-bound

Conversation

@seanwevans

Copy link
Copy Markdown
Owner

Issue

handle_migration_connection validates that the peer-declared blob_len is a non-negative integer, but puts no upper bound on it. The endpoint then calls _read_exact(conn, blob_len), which buffers the entire body in memory — and the HMAC authenticator can only be verified after that read completes. An unauthenticated peer can therefore declare an arbitrarily large checkpoint and make the migration endpoint buffer unbounded data, the same class of resource-exhaustion issue SecureChannel already guards against with its length-prefix bound.

Fix

  • Add a max_blob_len parameter (default DEFAULT_MAX_BLOB_LEN = 64 MiB) to handle_migration_connection and serve_migration_once.
  • Reject oversized declarations with MigrationProtocolError("checkpoint exceeds maximum size") before reading the body; the endpoint's existing error handling converts this into an ok=False response.

Testing

  • New test_endpoint_rejects_oversized_checkpoint_before_reading_it verifies the rejection response is sent without the body being read and that restore_fn never runs.
  • Full suite: 410 passed, 2 environment-gated skips; all pre-commit hooks (isort, black, pylint, flake8, mypy) pass.

🤖 Generated with Claude Code

https://claude.ai/code/session_01DDSofWX5HwawsrwbN2nSXR


Generated by Claude Code

handle_migration_connection read the peer-declared blob_len into memory
before the HMAC could be verified, with no upper bound, so an
unauthenticated peer could make the endpoint buffer arbitrarily large
payloads. Reject declarations above a configurable max_blob_len
(default 64 MiB) before reading the body.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DDSofWX5HwawsrwbN2nSXR
@seanwevans
seanwevans merged commit c1e058c into main Jul 20, 2026
19 checks passed
@seanwevans
seanwevans deleted the claude/migration-blob-len-bound branch July 20, 2026 20:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants