Skip to content

Validate large blob parameters before mutating write state - #797

Merged
kaczmarczyck merged 1 commit into
developfrom
preserve-large-blob-state-on-error
Oct 9, 2026
Merged

kaczmarczyck merged 1 commit into
developfrom
preserve-large-blob-state-on-error

Conversation

@kaczmarczyck

Copy link
Copy Markdown
Collaborator

In LargeBlobState::process_command, an offset == 0 write mutated self.expected_length before checking max_large_blob_array_size() and TRUNCATED_HASH_LEN, and updated self.expected_next_offset = 0 before verifying pin_uv_auth_param and checking that the chunk fits within expected_length.

If an offset == 0 request failed validation or authentication while a multi-fragment write was in progress, self.expected_length and/or self.expected_next_offset were overwritten while self.buffer retained the previous write's bytes. In particular, an offset == 0 request with length > max_large_blob_array_size() after an initial valid chunk left self.expected_length set to the oversized length and allowed subsequent chunks at offset > 0 to bypass max_large_blob_array_size().

Validate length, authentication, and chunk bounds before mutating LargeBlobState on offset == 0, and clear the state when the final chunk is processed regardless of whether the hash check succeeds.

@kaczmarczyck
kaczmarczyck requested a review from ia0 October 9, 2026 15:30
@kaczmarczyck kaczmarczyck self-assigned this Oct 9, 2026
@coveralls

coveralls commented Oct 9, 2026 •

Copy link
Copy Markdown

Coverage Status

coverage: 97.219% (+0.01%) from 97.205% — preserve-large-blob-state-on-error into develop

In LargeBlobState::process_command, an offset == 0 write mutated
self.expected_length before checking max_large_blob_array_size() and
TRUNCATED_HASH_LEN, and updated self.expected_next_offset = 0 before
verifying pin_uv_auth_param and checking that the chunk fits within
expected_length.

If an offset == 0 request failed validation or authentication while a
multi-fragment write was in progress, self.expected_length and/or
self.expected_next_offset were overwritten while self.buffer retained
the previous write's bytes. In particular, an offset == 0 request with
length > max_large_blob_array_size() after an initial valid chunk left
self.expected_length set to the oversized length and allowed subsequent
chunks at offset > 0 to bypass max_large_blob_array_size().

Validate length, authentication, and chunk bounds before mutating
LargeBlobState on offset == 0, and clear the state when the final chunk
is processed regardless of whether the hash check succeeds.
@kaczmarczyck
kaczmarczyck force-pushed the preserve-large-blob-state-on-error branch from fa86fd0 to e43cff8 Compare October 9, 2026 16:34
@kaczmarczyck
kaczmarczyck merged commit 6e10def into develop Oct 9, 2026
18 checks passed
@kaczmarczyck
kaczmarczyck deleted the preserve-large-blob-state-on-error branch October 9, 2026 16:47
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.

3 participants