Skip to content

[Security/Http] Ignore invalid URLs found in failure/success paths #46317

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

Merged
merged 1 commit into from
May 13, 2022

Conversation

nicolas-grekas
Copy link
Member

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

Copy link
Member

@wouterj wouterj left a comment

Choose a reason for hiding this comment

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

sorry, too quick

if (\is_string($failureUrl) && str_starts_with($failureUrl, '/')) {
$options['failure_path'] = $failureUrl;
} elseif ($this->logger && $failureUrl) {
$this->logger->debug(sprintf('Ignoring query parameter "%s": not a valid URL.', $options['failure_path_parameter']));
Copy link
Member

Choose a reason for hiding this comment

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

Should we include the value in the log message/context?

Copy link
Member Author

Choose a reason for hiding this comment

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

I don't think so: this is user input, might be just garbage. The query parameter name is enough to me.

}

if ($this->options['failure_forward']) {
$options['failure_path'] ?? $options['failure_path'] = $options['login_path'];
Copy link
Member

Choose a reason for hiding this comment

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

I must confess that I'm not at all sure if I understand what is going on here. Is this a leftover?

Copy link
Member Author

Choose a reason for hiding this comment

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

This is $options['failure_path'] ??= $options['login_path']; written for PHP 7.1+

@fabpot
Copy link
Member

fabpot commented May 13, 2022

Thank you @nicolas-grekas.

@fabpot fabpot merged commit a6f405a into symfony:4.4 May 13, 2022
@fabpot fabpot deleted the login_path branch May 13, 2022 09:18
@fabpot fabpot mentioned this pull request May 14, 2022
This was referenced May 27, 2022
@crmpicco
Copy link

Is there a recommended way to pass through the target_path now? It appears this change has broken the login functionality in some of my code. I created a discussion relating to it last week.

fabpot added a commit that referenced this pull request 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
nanasess added a commit to nanasess/ec-cube that referenced this pull request Aug 8, 2022
- see symfony/symfony#46317
- _target_path 及び _failure_path はURLまたはパスを指定する必要がある
- アプリケーション範囲外の URL を指定された場合は homepage へリダイレクトする
nanasess added a commit to nanasess/ec-cube that referenced this pull request Aug 8, 2022
- see symfony/symfony#46317
- _target_path 及び _failure_path はURLまたはパスを指定する必要がある
- アプリケーション範囲外の URL を指定された場合は homepage へリダイレクトする
@nanasess nanasess mentioned this pull request Aug 8, 2022
15 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants