8000 Redirect URLs not starting with '/' get dropped · Issue #46533 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content
8000

Redirect URLs not starting with '/' get dropped #46533

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

Closed
martinmaehlmannchefkoch opened this issue May 31, 2022 · 2 comments
Closed

Redirect URLs not starting with '/' get dropped #46533

martinmaehlmannchefkoch opened this issue May 31, 2022 · 2 comments

Comments

@martinmaehlmannchefkoch

Symfony version(s) affected

4.4.42

Description

By fixing bug #46317 a new bug was introduced. If a _target_path starts with 'http' or 'https' it gets dropped and the default location is returned. Using the Referer should still work.

How to reproduce

In a login form allowing _target_path, modify the value to send a value which starts with http or https.

Possible Solution

Simply modify the check to see, if it is a valid URL. Something like this could work:

if (\is_string($targetUrl) && (str_starts_with($targetUrl, '/') || filter_var($url, FILTER_VALIDATE_URL) )) {
    return $targetUrl;
}

Additional Context

No response

@xabbuh
Copy link
Member
xabbuh commented Jun 1, 2022

Would you like to give this a try and send a PR fixing this?

@nicolas-grekas
Copy link
Member
nicolas-grekas commented Jun 1, 2022

Given the check in HttpUtils::generateUri(), I would go with a simple str_starts_with($targetUrl, '/') || str_starts_with($targetUrl, 'http'), in both DefaultAuthenticationFailureHandler and DefaultAuthenticationSuccessHandler.

PR welcome indeed.

UFTimmy pushed a commit to UFTimmy/symfony that referenced this issue Jul 26, 2022
@fabpot fabpot closed this as completed Jul 29, 2022
fabpot added a commit that referenced this issue Jul 29, 2022
…m Ward)

This PR was merged into the 4.4 branch.

Discussion
----------

[Security] Allow redirect after login to absolute URLs

| Q             | A
| ------------- | ---
| Branch?       | 4.4
| Bug fix?      | yes
| New feature?  | no
| Deprecations? | no
| Tickets       | Fix #46533
| License       | MIT
| Doc PR        |

Fixes the regression introduced by #46317, and once again allows absolute URLs to be the target of authentication redirection, as specified in the documentation (https://symfony.com/doc/current/security/form_login.html#changing-the-default-page)

Commits
-------

b9901aa [Security] Allow redirect after login to absolute URLs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants
0