-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -70,31 +70,34 @@ public function setOptions(array $options) | |
*/ | ||
public function onAuthenticationFailure(Request $request, AuthenticationException $exception) | ||
{ | ||
if ($failureUrl = ParameterBagUtils::getRequestParameterValue($request, $this->options['failure_path_parameter'])) { | ||
$this->options['failure_path'] = $failureUrl; | ||
} | ||
$options = $this->options; | ||
$failureUrl = ParameterBagUtils::getRequestParameterValue($request, $options['failure_path_parameter']); | ||
|
||
if (null === $this->options['failure_path']) { | ||
$this->options['failure_path'] = $this->options['login_path']; | ||
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'])); | ||
} | ||
|
||
if ($this->options['failure_forward']) { | ||
$options['failure_path'] ?? $options['failure_path'] = $options['login_path']; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is |
||
|
||
if ($options['failure_forward']) { | ||
if (null !== $this->logger) { | ||
$this->logger->debug('Authentication failure, forward triggered.', ['failure_path' => $this->options['failure_path']]); | ||
$this->logger->debug('Authentication failure, forward triggered.', ['failure_path' => $options['failure_path']]); | ||
} | ||
|
||
$subRequest = $this->httpUtils->createRequest($request, $this->options['failure_path']); | ||
$subRequest = $this->httpUtils->createRequest($request, $options['failure_path']); | ||
$subRequest->attributes->set(Security::AUTHENTICATION_ERROR, $exception); | ||
|
||
return $this->httpKernel->handle($subRequest, HttpKernelInterface::SUB_REQUEST); | ||
} | ||
|
||
if (null !== $this->logger) { | ||
$this->logger->debug('Authentication failure, redirect triggered.', ['failure_path' => $this->options['failure_path']]); | ||
$this->logger->debug('Authentication failure, redirect triggered.', ['failure_path' => $options['failure_path']]); | ||
} | ||
|
||
$request->getSession()->set(Security::AUTHENTICATION_ERROR, $exception); | ||
|
||
return $this->httpUtils->createRedirectResponse($request, $this->options['failure_path']); | ||
return $this->httpUtils->createRedirectResponse($request, $options['failure_path']); | ||
} | ||
} |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.