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

AWS Signature Verification Fails when variables used in request body #684

Closed
los93sol opened this issue May 1, 2024 · 10 comments
Closed

Comments

@los93sol
Copy link

los93sol commented May 1, 2024

If I use any variables in an AWS request it fails signature verification. It looks like variables may not be getting replaced in the body before signing resulting in invalid signatures

@los93sol
Copy link
Author

los93sol commented May 1, 2024

The content-length header also is incorrect when using variables in these request bodies. Additionally, I do not see the x-amz-content-sha256 header present either so there appear to be multiple issues that will need addressed

@AnWeber
Copy link
Owner

AnWeber commented May 1, 2024

The incorrect Content-Length and the Invalid Authorization Header can be explained by the fact that I chose the wrong order for processing. The header was created first and then the body variables were replaced. I have now reversed the order.
The missing x-amz-content-sha256 header is a issue with the lib. I am using. There is already a bug ticket there. I'll have a read and see what the best way is to fix it.

@AnWeber
Copy link
Owner

AnWeber commented May 1, 2024

Ok. If I understand the documentation and the Java code for signing correctly, the header is only required for S3 and not otherwise. In this case, however, the lib inserts the header. So if it does cause problems, please let me know. I wouldn't change the functionality now, but I don't have an AWS account for testing.

@los93sol
Copy link
Author

los93sol commented May 1, 2024

Awesome! Thank you for turning that around so quickly. As a workaround for ordering I set the request.body in a pre request script and that made the signature valid but difficult to read and understand.

@los93sol
Copy link
Author

los93sol commented May 1, 2024

After performing the workaround with the prescript everything went through fine so for my case it turns out the sha header is not required

@AnWeber
Copy link
Owner

AnWeber commented May 2, 2024

Thx for your Feedback. I will close this issue as completed.

@AnWeber AnWeber closed this as completed May 2, 2024
@LaurenceGA
Copy link

@AnWeber

Not sure if it's related, but I have found that requests also fail if there is any query string at all (using latest version). Could it be a similar issue?

@AnWeber
Copy link
Owner

AnWeber commented May 5, 2024

@LaurenceGA should be not related, but I will test. Ist this behaviour a new issue?

@AnWeber
Copy link
Owner

AnWeber commented May 5, 2024

@LaurenceGA I accidentally did not insert the Query parameter in the signing request. This will be fixed with the next release.

@LaurenceGA
Copy link

@AnWeber Awesome, thank you 🙏

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

No branches or pull requests

3 participants