-
Notifications
You must be signed in to change notification settings - Fork 871
Double percent encoding of forward slashes (%2F) in paths #1419
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
Comments
There's a fundamental issue in aspnetcore with %2F and %252F that makes it impossible for YARP to correctly round trip both values (dotnet/aspnetcore#30655). #1219 defaulted to the safer of the two misunderstandings since double decoding %252F could be dangerous. I don't think we'll be able to sort this out properly until .NET 7. |
Triage: We depend on ASP.NET issue dotnet/aspnetcore#30655 to be fixed first. Then we may have to react. Moving to Backlog for now. |
Not sure if I may be doing something differently than @DanielFischer79 but I am observing the following:
In my case Yarp seems to be url-decoding the path. Yarp 1.0.0 on Kestrel EDIT: actually it seems like Daniel said it does encode it to |
Conclusion for my case. It is the combination of Steps:
Dapr seems to be doing some magic as well because when I make a request to ASP Core with path |
Triage: Depends solely on ASP.NET changes, no YARP work -- see #1419 (comment), will be (hopefully) part of 7.0. |
It tried to use YARP as a ReverseProxy for GitLab, but it didn't worked because of the %252F problem.
|
Can you elaborate where did you insert this code, and how did you use it? |
I changed my approach to not affect other routes. So what I did is I changed the method "MakeDestinationAddress" in the class "RequestUtilities" as follows:
So the destinationPrefix is hardcoded. It is not a nice solution, but it works for GitLab, no problems anymore occurred. But in my opinion it should be possible for every route to set a flag if we want to encode the path or not. |
I forgot to mention, when I started to use the source code of YARP instead the Nuget package I got the following error message sometimes, independent from GitLab: "The request cannot be forwarded, the response has already started" So what I did it commented out the following lines in the "HttpForwarder" class:
|
I just ran into this issue which renders YARP useless for me. Is there any workaround available that doesn't require to modify and maintain a custom version of YARP? Also, it does not seem like there will be a fix on aspnet side any time soon (the linked issue is rotting away in the backlog), so is there anything that can be done on YARP side? |
Yes, there is a workaround. We use this code since few years:
At least, add this line to program.cs: |
Thank you for that workaround, upon quick testing it looks like it does solve the issue for me. 👍 Right now I cannot pretend to fully understand what it does, there doesn't seem to be much going on there code-wise. |
As this problem hasn't been fixed for years, I believe it is something the MS team cannot really solve without introducing lot's of breaking changes. It is still a fundamental issue. The other day I was deploying an app to Azure App Services, which seems to be using Yarp behind the scene as it automatically decodes |
We have the code since 3 years in a productive environment. Behind our YARP farm we have many different kinds of applications (common web apps, apis, grafana, loki, prometheus, gitlab, nexus with nuget, npm and docker repository). Everything is running smoothly. |
Similar issue here with proxying requests to HashiCorp Vault: hashicorp/vault-client-dotnet#204 |
Describe the bug
we use yarp in front of an nexus server which hosting node packages.
Node packages urls can contains %2f instead of slash as part of the path.
yarp encode the percent again to %25 so the resulting path was wrongly modifed.
To Reproduce
GET https://nexus.domain.com/repository/npm-proxy/@types%2fcors
YARP convert the url to, but its wrong:
https://nexus.domain.com/repository/npm-proxy/@types%252fcors
YARP should not modify the path by default. If there is a special use case for duing that, it should be done by a feature flag
Further technical details
We tested it with new version 1.0.0 / .net 5.0
We analysed the issue in detail and found the reason for this issue: #
By fixing the issue #1219 a major change was done with path encoding.
The char '%' was not longer a valid path character for yarp. (Class RequestUtilities, Method: IsValidPathChar)
We temporary fix the issue by creating a custom request transformer and set the uri like RequestUtilities did it before.
The text was updated successfully, but these errors were encountered: