Bound the checkpoint size accepted by the migration endpoint#264
Merged
Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Issue
handle_migration_connectionvalidates that the peer-declaredblob_lenis 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 issueSecureChannelalready guards against with its length-prefix bound.Fix
max_blob_lenparameter (defaultDEFAULT_MAX_BLOB_LEN= 64 MiB) tohandle_migration_connectionandserve_migration_once.MigrationProtocolError("checkpoint exceeds maximum size")before reading the body; the endpoint's existing error handling converts this into anok=Falseresponse.Testing
test_endpoint_rejects_oversized_checkpoint_before_reading_itverifies the rejection response is sent without the body being read and thatrestore_fnnever runs.🤖 Generated with Claude Code
https://claude.ai/code/session_01DDSofWX5HwawsrwbN2nSXR
Generated by Claude Code