Skip to content

Update getCanonicalizedHeaderString to follow SigV4 spec #2502

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

Closed
wants to merge 1 commit into from
Closed

Update getCanonicalizedHeaderString to follow SigV4 spec #2502

wants to merge 1 commit into from

Conversation

skrueger
Copy link

  • Update to handle leading and trailing whitespace in header value
  • Update to handle multiple header values

See Step 4 of https://docs.aws.amazon.com/general/latest/gr/sigv4-create-canonical-request.html

Without this change a request to S3 with multiple header values or
a header value with leading and trailing spaces
(e.g.,

Header1: Cat\n
Header1: Dog\n
Header2:     "a   b   c"  \n

)
that is signed by the AwsS3V4Signer will receive a 403 Forbidden
response with an Error Code of SignatureDoesNotMatch from S3.

Description

Currently my HTTP requests that contain multiple values for a specific header are receiving an 403 Forbidden response from S3 with an Error Code of SignatureDoesNotMatch. The S3's response would also return code would return the expected <CanonicalRequest>, which lead me to solving the issue.

Motivation and Context

My requests to S3 are failing because the library does not correctly follow the SigV4 spec.

Testing

Screenshots

N/A

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)

Checklist

  • I have read the CONTRIBUTING document
  • Local run of mvn install succeeds
  • My code follows the code style of this project
  • My change requires a change to the Javadoc documentation
  • I have updated the Javadoc documentation accordingly
  • I have read the README document
  • I have added tests to cover my changes
  • All new and existing tests passed
  • A short description of the change has been added to the CHANGELOG
  • My change is to implement 1.11 parity feature and I have updated LaunchChangelog

License

  • I confirm that this pull request can be released under the Apache 2 license

- Update to handle leading and trailing whitespace in header values
- Update to handle multiple header values

See Step 4 of https://docs.aws.amazon.com/general/latest/gr/sigv4-create-canonical-request.html

Without this change a request to S3 with multiple header values or
a header value with leading and trailing spaces
(e.g.,
```
Header1: Cat\n
Header1: Dog\n
Header2:     "a   b   c"  \n
```
)
that is signed by the AwsS3V4Signer will receive a 403 Forbidden
response with an Error Code of SignatureDoesNotMatch from S3.
@sonarqubecloud
Copy link

Kudos, SonarCloud Quality Gate passed!

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 1 Code Smell

96.2% 96.2% Coverage
0.0% 0.0% Duplication

@codecov-commenter
Copy link

Codecov Report

Merging #2502 (632fea8) into master (35eace7) will increase coverage by 0.01%.
The diff coverage is 88.88%.

Impacted file tree graph

@@             Coverage Diff              @@
##             master    #2502      +/-   ##
============================================
+ Coverage     77.74%   77.75%   +0.01%     
  Complexity      365      365              
============================================
  Files          1248     1248              
  Lines         39533    39540       +7     
  Branches       3094     3097       +3     
============================================
+ Hits          30733    30745      +12     
+ Misses         7314     7305       -9     
- Partials       1486     1490       +4     
Flag Coverage Δ
unittests 77.75% <88.88%> (+0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
...wssdk/auth/signer/internal/AbstractAws4Signer.java 90.58% <88.88%> (-0.21%) ⬇️
...nio/netty/internal/OldConnectionReaperHandler.java 81.81% <0.00%> (-9.10%) ⬇️
...o/netty/internal/utils/BetterFixedChannelPool.java 66.12% <0.00%> (+2.15%) ⬆️
...ttp/nio/netty/internal/nrs/HttpStreamsHandler.java 64.61% <0.00%> (+3.84%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 35eace7...632fea8. Read the comment docs.

@debora-ito
Copy link
Member

Hi @skrueger, since #2629 was merged is this still needed? I see you made some comments on the PR after it was merged.

@dagnir
Copy link
Contributor

dagnir commented Aug 25, 2021

With the merging of #2629 I think this feature can't merged as-is so I'm going to close it for now. I know @skrueger left some feedback on that PR for improvements. Please feel free to reopen this PR if you'd like to make those changes as part of it.

@dagnir dagnir closed this Aug 25, 2021
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.

4 participants