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

[Issue] URLs should not contains reserved characters according to RFC 3986 #36042

Closed
5 tasks
m2-assistant bot opened this issue Aug 26, 2022 · 4 comments · Fixed by #35885
Closed
5 tasks

[Issue] URLs should not contains reserved characters according to RFC 3986 #36042

m2-assistant bot opened this issue Aug 26, 2022 · 4 comments · Fixed by #35885
Labels
Area: Security Component: Encryption Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed Priority: P2 A defect with this priority could have functionality issues which are not to expectations. Progress: done Reported on 2.4.x Indicates original Magento version for the Issue report. Reproduced on 2.4.x The issue has been reproduced on latest 2.4-develop branch

Comments

@m2-assistant
Copy link

m2-assistant bot commented Aug 26, 2022

This issue is automatically created based on existing pull request: #35885: URLs should not contains reserved characters according to RFC 3986


Description (*)

This PR fixes the RFC 3986 which forbids to use reserved characters in URLs such as a comma.

Related Pull Requests

Manual testing scenarios (*)

  1. Use the URL : http://magento2.adobe/encoding/with/longer/url/
  2. Encode this URL with the Magento\Framework\Url\Encoder::encode method
  3. Note that the base64 encoded URL contains a comma : aHR0cDovL21hZ2VudG8yLmFkb2JlL2VuY29kaW5nL3dpdGgvbG9uZ2VyL3VybC8,
  4. Use the native method rawurlencode from PHP on the result : aHR0cDovL21hZ2VudG8yLmFkb2JlL2VuY29kaW5nL3dpdGgvbG9uZ2VyL3VybC8%2C (please notice the %2C character which is the hexadecimal value for a comma, which is not allowed.
  5. Decode this URL back : http://magento2.adobe/encoding/with/longer/url/6 (a 6 was added at the end of the URL because of the encoded value)

Questions or comments

In my understanding of the RFC, an URL can't contain a comma (or whatever reserved characters). However, Magento uses such character in the encode method to remove the = character from the base64 encoded value.

return strtr(base64_encode($url), '+/=', '-_,');

This PR replaces the comma value by a tilde as this is an unreserved character allowed for an URL and which will not be transformed in the rawurlencode method.

Contribution checklist (*)

  • Pull request has a meaningful description of its purpose
  • All commits are accompanied by meaningful commit messages
  • All new or changed code is covered with unit/integration tests (if applicable)
  • README.md files for modified modules are updated and included in the pull request if any README.md predefined sections require an update
  • All automated tests passed successfully (all builds are green)
@m2-assistant m2-assistant bot added the Priority: P2 A defect with this priority could have functionality issues which are not to expectations. label Aug 26, 2022
@m2-community-project m2-community-project bot added this to Pull Request In Progress in High Priority Backlog Aug 26, 2022
@engcom-Lima engcom-Lima added Component: Url Reproduced on 2.4.x The issue has been reproduced on latest 2.4-develop branch Reported on 2.4.x Indicates original Magento version for the Issue report. Area: Security Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed and removed Component: Url Reproduced on 2.4.x The issue has been reproduced on latest 2.4-develop branch Reported on 2.4.x Indicates original Magento version for the Issue report. Area: Security labels Sep 6, 2022
@github-jira-sync-bot github-jira-sync-bot removed the Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed label Sep 6, 2022
@github-jira-sync-bot
Copy link

Unfortunately, not enough information was provided to create a Jira ticket. Please make sure you added the following label(s): Reproduced on 2.4.x, ^Area:.*

Once all required labels are present, please add Issue: Confirmed label again.

@engcom-Lima engcom-Lima added Area: Security Component: Encryption Reproduced on 2.4.x The issue has been reproduced on latest 2.4-develop branch Reported on 2.4.x Indicates original Magento version for the Issue report. Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed labels Sep 6, 2022
@github-jira-sync-bot
Copy link

✅ Jira issue https://jira.corp.adobe.com/browse/AC-6635 is successfully created for this GitHub issue.

@m2-assistant
Copy link
Author

m2-assistant bot commented Sep 6, 2022

✅ Confirmed by @engcom-Lima. Thank you for verifying the issue.
Issue Available: @engcom-Lima, You will be automatically unassigned. Contributors/Maintainers can claim this issue to continue. To reclaim and continue work, reassign the ticket to yourself.

@MrBlueEyez
Copy link

MrBlueEyez commented May 23, 2023

The pull request only adjusted the encoder, the Magento\Framework\Url\Decoder is still looking for a comma instead of a tilde when decoding:
$url = $url !== null ? base64_decode(strtr($url, '~_,', '+/=')) : '';
(I see #37532 has been created for that)

I am also having some difficulties with urls that end with a tilde, getting a 403 from nginx. Not 100% sure if this is something I can fix on my side.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: Security Component: Encryption Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed Priority: P2 A defect with this priority could have functionality issues which are not to expectations. Progress: done Reported on 2.4.x Indicates original Magento version for the Issue report. Reproduced on 2.4.x The issue has been reproduced on latest 2.4-develop branch
Projects
Development

Successfully merging a pull request may close this issue.

3 participants