Thanks to visit codestin.com
Credit goes to github.com

Skip to content

fix pre-signed URL with JS SDK, enable test_presigned_url_v4_x_amz_in_qs #12164

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 2 commits into from
Jan 23, 2025

Conversation

bentsku
Copy link
Contributor

@bentsku bentsku commented Jan 22, 2025

Motivation

We had pipeline failures due to the test_presigned_url_v4_x_amz_in_qs test suddenly failing. This happened at the same time we've had a big update in S3 data integrity and checksums in our boto update.

I suspected a change in behavior in the Javascript SDK: what happens now is that the JS SDK is adding a checksum value for pre-signed URL, which in itself is quite a bad idea, as you cannot know in advance what the value of the object can be.

So it seems AWS is just flat out ignoring the query string parameter.

Pre-signed URLs are a funny concept: you pass some values that would normally be headers in a regular signed request as query string parameters, so that the URL can be shared. To not have to manually parse query string parameters in our S3 provider, our pre-signed URL handler is picking up the query string parameters and putting them back as headers and mutating the request before it being parsed, so that we can fully enjoy the ASF power. See #8918

But in that case, the query string parameter is important for the signature, if you try modifying it, S3 will raise an invalid signature exception. But you need to ignore it before passing it down to the provider.

edit: this actually has been reported now with #12169

Changes

  • ignore any x-amz-checksum-<> header that is not in the signed headers, and do not pass it down the provider
  • re-enable the test and add a few checks

\cc @k-a-il

@bentsku bentsku added aws:s3 Amazon Simple Storage Service semver: patch Non-breaking changes which can be included in patch releases labels Jan 22, 2025
@bentsku bentsku added this to the 4.1 milestone Jan 22, 2025
@bentsku bentsku self-assigned this Jan 22, 2025
Copy link

S3 Image Test Results (AMD64 / ARM64)

  2 files    2 suites   4m 41s ⏱️
442 tests 389 ✅  53 💤 0 ❌
884 runs  778 ✅ 106 💤 0 ❌

Results for commit 0e5a983.

Copy link

LocalStack Community integration with Pro

    2 files  ±    0      2 suites  ±0   59m 28s ⏱️ - 52m 51s
1 671 tests  - 2 333  1 507 ✅  - 2 180  164 💤  - 153  0 ❌ ±0 
1 673 runs   - 2 333  1 507 ✅  - 2 180  166 💤  - 153  0 ❌ ±0 

Results for commit 0e5a983. ± Comparison against base commit e5e74db.

This pull request removes 2333 tests.
tests.aws.scenario.bookstore.test_bookstore.TestBookstoreApplication ‑ test_lambda_dynamodb
tests.aws.scenario.bookstore.test_bookstore.TestBookstoreApplication ‑ test_opensearch_crud
tests.aws.scenario.bookstore.test_bookstore.TestBookstoreApplication ‑ test_search_books
tests.aws.scenario.bookstore.test_bookstore.TestBookstoreApplication ‑ test_setup
tests.aws.scenario.kinesis_firehose.test_kinesis_firehose.TestKinesisFirehoseScenario ‑ test_kinesis_firehose_s3
tests.aws.scenario.lambda_destination.test_lambda_destination_scenario.TestLambdaDestinationScenario ‑ test_destination_sns
tests.aws.scenario.lambda_destination.test_lambda_destination_scenario.TestLambdaDestinationScenario ‑ test_infra
tests.aws.scenario.loan_broker.test_loan_broker.TestLoanBrokerScenario ‑ test_prefill_dynamodb_table
tests.aws.scenario.loan_broker.test_loan_broker.TestLoanBrokerScenario ‑ test_stepfunctions_input_recipient_list[step_function_input0-SUCCEEDED]
tests.aws.scenario.loan_broker.test_loan_broker.TestLoanBrokerScenario ‑ test_stepfunctions_input_recipient_list[step_function_input1-SUCCEEDED]
…

Copy link
Member

@silv-io silv-io left a comment

Choose a reason for hiding this comment

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

LGTM! Very weird in total

@@ -7544,6 +7543,8 @@ def test_presigned_url_v4_x_amz_in_qs(
# assert that the Javascript SDK hoists it in the URL, unlike Boto
assert StorageClass.STANDARD in presigned_url
assert "bar-complicated-no-random" in presigned_url
# the JS SDK also adds a default checksum now even for pre-signed URLs
Copy link
Member

Choose a reason for hiding this comment

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

Default checksum wow

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah I still don't understand how this made it into prod 😄

@bentsku bentsku merged commit e0c636f into master Jan 23, 2025
49 checks passed
@bentsku bentsku deleted the fix-pre-signed-js-sdk branch January 23, 2025 10:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
aws:s3 Amazon Simple Storage Service semver: patch Non-breaking changes which can be included in patch releases
Projects
None yet
Development

Successfully merging this pull request may close these issues.

bug: Value for x-amz-checksum-crc32 header is invalid when uploading to S3 via signed URL using AWS SDK v3 for JS
2 participants