Skip to content
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

SignatureDoesNotMatch error when S3 key contains * #1896

Closed
TsvetanMilanov opened this issue Jan 11, 2021 · 8 comments
Closed

SignatureDoesNotMatch error when S3 key contains * #1896

TsvetanMilanov opened this issue Jan 11, 2021 · 8 comments
Assignees
Labels
bug This issue is a bug. p2 This is a standard priority issue

Comments

@TsvetanMilanov
Copy link

Describe the bug
When trying to get/put object with key which contains * (e.g. te*st) the S3 client throws SignatureDoesNotMatch error.

SDK version number
3.2.0

Is the issue in the browser/Node.js/ReactNative?
Node.js

Details of the browser/Node.js/ReactNative version
v12.16.1

To Reproduce (observed behavior)

const { S3 } = require("@aws-sdk/client-s3");

const s3 = new S3({ region: "us-east-1" });
await s3.putObject({ Bucket: "test-signature-sdk-v3", Key: "test*", Body: "test" });

Expected behavior
Expecting the method invocation to succeed, but it throws SignatureDoesNotMatch error.

Additional context
There is a similar issue #283 and a related fix #284. The S3 client works with : (e.g. te:st) but not with *. The aws-sdk v2 works correctly with key te*st

@TsvetanMilanov TsvetanMilanov added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Jan 11, 2021
@ajredniwja
Copy link
Contributor

Hey @TsvetanMilanov I was able to reproduce this issue, it is currently in our high priority list, the issue will be updated once it has been fixed.

@trivikr
Copy link
Member

trivikr commented Mar 18, 2021

This happens because encodeURIComponent doesn't escape *.

Currently the additional encoding is only done in signer, and some additional characters will be required to be escaped

if (this.uriEscapePath) {
const doubleEncoded = encodeURIComponent(path.replace(/^\//, ""));
return `/${doubleEncoded.replace(/%2F/g, "/")}`;
}

The solution would be to do additional encoding on top of encodeURIComponent output.
Code from v2: https://github.com/aws/aws-sdk-js/blob/dd83d672170e8cc0c52a20df29a43e7663e5336a/lib/util.js#L41-L46

@trivikr trivikr removed the needs-triage This issue or PR still needs to be triaged. label Mar 18, 2021
@trivikr trivikr assigned alexforsyth and unassigned ajredniwja Mar 18, 2021
@dobrynin
Copy link

Bump, can the suggest change be implemented?

@live680g
Copy link

live680g commented Aug 9, 2022

This error is being exist.
"@aws-sdk/client-s3": "^3.142.0",

@dobrynin
Copy link

dobrynin commented Aug 9, 2022

myString.replace("*", "%2A"); fixed for me.

@RanVaknin RanVaknin added the p2 This is a standard priority issue label Feb 7, 2023
@Dids
Copy link

Dids commented Apr 26, 2023

This also happens when metadata contains special/unicode characters, such as ContentDisposition, which I've been wrestling with lately.

Using the latest SDK and specifically the CopyObjectCommand, as I'm trying to update metadata for a lot of files, as part of a migration to S3, however this has been a rather unpleasant surprise.

@yenfryherrerafeliz
Copy link
Contributor

Hi @TsvetanMilanov, @Dids, @dobrynin, @live680g, this issue has been fixed. Please update to the latest version of the SDK you should have not issues.

If you folks have anything else that we can help with, please feel free of opening a new issue.

Thanks!

Copy link

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs and link to relevant comments in this thread.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 10, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug This issue is a bug. p2 This is a standard priority issue
Projects
None yet
Development

No branches or pull requests

9 participants