Skip to content

Handle %2f in routing more consistently - #19537

Merged
markstory merged 2 commits into
5.xfrom
middleware-slash
Jul 14, 2026
Merged

markstory merged 2 commits into
5.xfrom
middleware-slash

Conversation

@markstory

Copy link
Copy Markdown
Member

Currently path prefix matching does not treat %2f as /, and Route has an option for it. In the past we've made changes in this area (#18050, #16110) to make urldecoding optional, and to intentionally decode urlencoding in path segments to support non-ascii applications.

We got a report on the security list for a potential issue where if an application enforced authorization within path prefixed scopes, and had fallback routes enabled, then one could potentially bypass the scoped middleware and hit the fallback routes which inconsistently handle %2f.

These changes align the behavior of urldecoding between RouteCollection and Route with a new shared internal function. I thought a function was better than exposing a static method on a public class.

Thanks to Rotem Reiss for reporting this issue.

Currently path prefix matching does not treat %2f as /, and `Route` has
an option for it. In the past we've made changes in this area
(#18050, #16110) to make urldecoding optional, and to intentionally
decode urlencoding in path segments to support non-ascii applications.

We got a report on the security list for a potential issue where *if*
an application enforced authorization within path prefixed scopes, and
had fallback routes enabled, then one could potentially bypass the scoped
middleware and hit the fallback routes which inconsistently handle %2f.

These changes align the behavior of urldecoding between RouteCollection
and Route with a new shared internal function. I thought a function was
better than exposing a static method on a public class.

Thanks to Rotem Reiss for reporting this issue.
@markstory markstory added this to the 5.3.7 milestone Jul 12, 2026
Been writing too much python and rust lately.
@markstory
markstory merged commit f95aebd into 5.x Jul 14, 2026
15 checks passed
@markstory
markstory deleted the middleware-slash branch July 14, 2026 03:03
markstory added a commit that referenced this pull request Jul 14, 2026
Currently path prefix matching does not treat %2f as /, and `Route` has
an option for it. In the past we've made changes in this area
(#18050, #16110) to make urldecoding optional, and to intentionally
decode urlencoding in path segments to support non-ascii applications.

We got a report on the security list for a potential issue where *if*
an application enforced authorization within path prefixed scopes, and
had fallback routes enabled, then one could potentially bypass the scoped
middleware and hit the fallback routes which inconsistently handle %2f.

These changes align the behavior of urldecoding between RouteCollection
and Route with a new shared internal function. I thought a function was
better than exposing a static method on a public class.

Thanks to Rotem Reiss for reporting this issue.
markstory added a commit that referenced this pull request Jul 14, 2026
Currently path prefix matching does not treat %2f as /, and `Route` has
an option for it. In the past we've made changes in this area
(#18050, #16110) to make urldecoding optional, and to intentionally
decode urlencoding in path segments to support non-ascii applications.

We got a report on the security list for a potential issue where *if*
an application enforced authorization within path prefixed scopes, and
had fallback routes enabled, then one could potentially bypass the scoped
middleware and hit the fallback routes which inconsistently handle %2f.

These changes align the behavior of urldecoding between RouteCollection
and Route with a new shared internal function. I thought a function was
better than exposing a static method on a public class.

Thanks to Rotem Reiss for reporting this issue.
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.

1 participant