Skip to content

Stop unquoting %2F in paths#1057

Merged
bdraco merged 7 commits intomasterfrom
no-unquote-2f
Aug 30, 2024
Merged

Stop unquoting %2F in paths#1057
bdraco merged 7 commits intomasterfrom
no-unquote-2f

Conversation

@Dreamsorcerer
Copy link
Member

@Dreamsorcerer Dreamsorcerer commented Aug 26, 2024

I've added ignore so that /foo/bar%2fbaz doesn't become %2Ffoo%2Fbar%2Fbaz, but maybe the unsafe option is just wrong currently?

@codecov
Copy link

codecov bot commented Aug 26, 2024

Codecov Report

Attention: Patch coverage is 75.00000% with 3 lines in your changes missing coverage. Please review.

Project coverage is 62.37%. Comparing base (24073ce) to head (a7c1d64).
Report is 356 commits behind head on master.

Files with missing lines Patch % Lines
tests/test_url.py 0.00% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1057      +/-   ##
==========================================
+ Coverage   62.36%   62.37%   +0.01%     
==========================================
  Files          38       38              
  Lines        6616     6626      +10     
  Branches      356      356              
==========================================
+ Hits         4126     4133       +7     
- Misses       2463     2466       +3     
  Partials       27       27              
Flag Coverage Δ
CI-GHA 62.34% <75.00%> (+0.01%) ⬆️
MyPy 25.60% <70.00%> (+0.03%) ⬆️
OS-Linux 99.25% <100.00%> (+<0.01%) ⬆️
OS-Windows 99.58% <100.00%> (+<0.01%) ⬆️
OS-macOS 99.02% <100.00%> (+<0.01%) ⬆️
Py-3.10.11 98.90% <100.00%> (+<0.01%) ⬆️
Py-3.10.14 99.10% <100.00%> (+<0.01%) ⬆️
Py-3.11.9 99.10% <100.00%> (+<0.01%) ⬆️
Py-3.12.4 99.45% <100.00%> (+<0.01%) ⬆️
Py-3.12.5 99.10% <100.00%> (+<0.01%) ⬆️
Py-3.13.0-rc.1 99.10% <100.00%> (+<0.01%) ⬆️
Py-3.8.10 98.87% <100.00%> (+<0.01%) ⬆️
Py-3.8.18 99.07% <100.00%> (+<0.01%) ⬆️
Py-3.9.13 98.87% <100.00%> (+<0.01%) ⬆️
Py-3.9.19 99.07% <100.00%> (+<0.01%) ⬆️
Py-pypy7.3.11 99.39% <100.00%> (+<0.01%) ⬆️
Py-pypy7.3.16 99.42% <100.00%> (+<0.01%) ⬆️
VM-macos-latest 99.02% <100.00%> (+<0.01%) ⬆️
VM-ubuntu-latest 99.25% <100.00%> (+<0.01%) ⬆️
VM-windows-latest 99.58% <100.00%> (+<0.01%) ⬆️

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

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Member

@bdraco bdraco left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After looking at history and considering security perspective with this, I think this is the right fix

@bdraco bdraco added the bot:chronographer:skip This PR does not need to include a change note label Aug 30, 2024
@bdraco
Copy link
Member

bdraco commented Aug 30, 2024

skip label added as a workaround

@bdraco
Copy link
Member

bdraco commented Aug 30, 2024

I'm going to test this on some Home Assistant production instances with ingress just to be sure.

@bdraco
Copy link
Member

bdraco commented Aug 30, 2024

Just realized I had already updated my primary production with this since it was in my integration branch.

No obvious breakage

@bdraco bdraco merged commit 84e1c7d into master Aug 30, 2024
@bdraco bdraco deleted the no-unquote-2f branch August 30, 2024 21:40
@@ -0,0 +1,2 @@
Stopped decoding ``%2F`` (``/``) in ``URL.path``, as this could lead to code incorrectly being treated as a path separator
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Stopped decoding ``%2F`` (``/``) in ``URL.path``, as this could lead to code incorrectly being treated as a path separator
Stopped decoding ``%2F`` (``/``) in ``URL.path``, as this could lead to code incorrectly treating it as a path separator

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll fix it up when I do the release

@Dreamsorcerer
Copy link
Member Author

Damn, beat me by a couple of seconds.. :P

@ofekashery
Copy link

ofekashery commented Sep 3, 2024

Hi @Dreamsorcerer @bdraco @webknjaz, thanks for your hard work ❤️
Please pay attention that this PR introduces BREAKING changes and might not be considered as a patch.

The %2F is frequently used by AMQP connection strings. This change led into a parsing bug in the AMQP connection protocol of mosquito/aiormq and mosquito/aio-pika, and broke our critical production system.

I believe those changes are great but could be as an optional flag. It also could reflected better in the changelog.

url = yarl.URL("amqp://localhost/%2f")
print(url.path)
# Yarl v1.9.4 -> `//`
# Yarl v1.9.5 -> `/%2F`

@webknjaz
Copy link
Member

webknjaz commented Sep 5, 2024

@ofekashery would you mind opening a new issue and maybe also submitting a PR with xfailing tests per https://blog.ganssle.io/articles/2021/11/pytest-xfail.html? Comments on closed things may end up getting lost. I'm not sure if @Dreamsorcerer and @bdraco got your message in time, for example.

@Dreamsorcerer
Copy link
Member Author

Yeah, should probably have been a bigger version bump, but not too much we can do now. As it relates to security, I think it's still important to keep the change going forwards.

@webknjaz
Copy link
Member

webknjaz commented Sep 5, 2024

Yeah, security changes are always exempt from SemVer.

bdraco added a commit that referenced this pull request Sep 23, 2024
bdraco added a commit that referenced this pull request Sep 23, 2024
This undones only the ignore part of #1057 in as we will instead
add a new property called path_safe in #1150
@Dreamsorcerer
Copy link
Member Author

Sorry about that, we've decided to revert this anyway as it's caused a few more issues. If you need to know the path separators for safety, we're adding a path_safe attribute instead which skips decoding %2F and %25.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bot:chronographer:skip This PR does not need to include a change note

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants