Skip to content

coredump: add checksum for uploads #542

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jun 26, 2025
Merged

coredump: add checksum for uploads #542

merged 4 commits into from
Jun 26, 2025

Conversation

florianl
Copy link
Contributor

It seems the OTel S3 endpoint did get more restrictive and now requires a checksum for uploaded items.

Without this checksum, the following error is returned:

failed to upload file: operation error S3: PutObject, https response error StatusCode: 400, RequestID: sjc-1:, HostID: , api error InvalidArgument: x-amz-content-sha256 must be UNSIGNED-PAYLOAD or a valid sha256 value.

It seems the OTel S3 endpoint did get more restrictive and now requires a checksum for uploaded items.

Without this checksum, the following error is returned:

failed to upload file: operation error S3: PutObject, https response error StatusCode: 400, RequestID: sjc-1:<some-random-ID>, HostID: , api error InvalidArgument: x-amz-content-sha256 must be UNSIGNED-PAYLOAD or a valid sha256 value.

Signed-off-by: Florian Lehner <florian.lehner@elastic.co>
@florianl florianl requested review from a team as code owners June 20, 2025 08:22
Signed-off-by: Florian Lehner <florian.lehner@elastic.co>
@@ -197,16 +200,26 @@ func (store *Store) UploadModule(id ID) error {
return fmt.Errorf("failed to open local file: %w", err)
}

fileData, err := io.ReadAll(file)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't know how large a coredump file in the future can be, how much RAM a user has available or if the coredump already is in a RAM disk.

I'd suggest to hash from disk and also let PutObject stream from disk.
The potential (but extremely unlikely) TOCTOU (data changes between reads) is caught on the server side with the checksum provided.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Oracle backed S3 storage did not accept streams. That's why I made this change alongside the newly required checksum.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, you should have mentioned this in the PR description.
It means that just adding the checksum does not allow to upload?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sorry 🙏 I just try to get it working and did forget about this. but I think its not worth a dedicated PR.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This sounds weird. How did you test this? The Body seems to be working on a reader interface so this really should not matter.

Wild guess: did you use same reader for first hashing and not seeking back to beginning so that the http send starts from right position?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While helping to get the coredump tests pass for #289 I did run into this issue. And as coredump tests pass in #289, I was able to upload the new coredumps with this change successfully.

Based on your feedback, I dropped the io.ReadAll and bytes.NewReader. Hope this works for you.

florianl added 2 commits June 25, 2025 10:03
Signed-off-by: Florian Lehner <florian.lehner@elastic.co>
Signed-off-by: Florian Lehner <florian.lehner@elastic.co>
Copy link
Contributor

@rockdaboot rockdaboot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, just two minor comments

Copy link
Contributor

@fabled fabled left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@fabled fabled merged commit 2d40c64 into main Jun 26, 2025
25 checks passed
@fabled fabled deleted the coredump-upload branch June 26, 2025 12:17
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