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

Fix CloudFront signer RFC5987 support #3826

Closed

Conversation

realies
Copy link

@realies realies commented Jul 9, 2021

url.parse(someUrl, true) in combination with nulling its search property has a side-effect when re-encoding using url.format.

var parsedUrl = url.parse(options.url, true),

parsedUrl.search = null;

It causes URL queries existing before the signing process to get re-encoded improperly during the url.format stage here:

? getRtmpUrl(url.format(parsedUrl))
: url.format(parsedUrl);

This breaks the usage of some special characters in URL queries, even when they have been properly URL encoded. One example is setting the filename in a specific charset using the response-content-disposition query field. For example, the response-content-disposition query value (RFC5987 examples) may contain:

attachment%3Bfilename%2A%3DUTF-8%27%27abc%2520def.mp4

Although the current functionality returns a signed URL that has the query value formatted as:

attachment%3Bfilename*%3DUTF-8''abc%2520def.mp4

This invalidates the generated signature and CloudFront replies with:

<Error>
<Code>AccessDenied</Code>
<Message>Access denied</Message>
</Error>

To replicate the issue in isolation:

> var u = url.parse('https://asdf.cloudfront.net/932e9e5d-cbdf-4c73-a3dc-e07758bd3adb?response-content-disposition=attachment%3Bfilename%2A%3DUTF-8%27%27abc%2520def.mp4', true)
> url.format(u)
'https://asdf.cloudfront.net/932e9e5d-cbdf-4c73-a3dc-e07758bd3adb?response-content-disposition=attachment%3Bfilename%2A%3DUTF-8%27%27abc%2520def.mp4'
> u.search=null
> url.format(u)
"https://asdf.cloudfront.net/932e9e5d-cbdf-4c73-a3dc-e07758bd3adb?response-content-disposition=attachment%3Bfilename*%3DUTF-8''abc%2520def.mp4"

The example input URL query works fine in aws-sdk-php and boto3.

Fixes #2952.

@aws-sdk-js-automation
Copy link

AWS CodeBuild CI Report

  • CodeBuild project: sdk-v2-github
  • Commit ID: c4cec7c
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@realies
Copy link
Author

realies commented Feb 23, 2022

@ajredniwja @AllanZhengYP could you please review this and potentially release it?

@realies
Copy link
Author

realies commented Jul 21, 2022

@ajredniwja @AllanZhengYP this is more than a year old now

@github-actions
Copy link

Greetings! We’re closing this issue because it has been open a long time and hasn’t been updated in a while and may not be getting the attention it deserves. We encourage you to check if this is still an issue in the latest release and if you find that this is still a problem, please feel free to comment or open a new issue.

@github-actions github-actions bot added the closing-soon This issue will automatically close in 4 days unless further comments are made. label Jul 22, 2023
@realies
Copy link
Author

realies commented Jul 22, 2023

review it

@github-actions github-actions bot removed the closing-soon This issue will automatically close in 4 days unless further comments are made. label Jul 23, 2023
@kuhe kuhe assigned kuhe and unassigned AllanZhengYP May 15, 2024
@kellertk
Copy link
Contributor

kellertk commented Sep 4, 2024

Thank you for your efforts, but this project is no longer accepting contributions as part of our plan to end support for AWS SDK for JavaScript v2. This method is overridable in your own code at runtime, if you prefer.

@kellertk kellertk closed this Sep 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Cloudfront Signer not works with UTF-8 filenames in content-disposition
6 participants