-
-
Notifications
You must be signed in to change notification settings - Fork 161
Fix open redirect vulnerabilities in redirect parameter handling #2963
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
base: 4.1
Are you sure you want to change the base?
Conversation
Co-authored-by: dpfaffenbauer <5981845+dpfaffenbauer@users.noreply.github.com>
…haracters Co-authored-by: dpfaffenbauer <5981845+dpfaffenbauer@users.noreply.github.com>
| * | ||
| * @return string The validated URL or the default if invalid | ||
| */ | ||
| protected function validateRedirectUrl(Request $request, string $url, string $default): string |
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.
@copilot feels a bit weird that symfony doesn't provide anything like this?
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.
@copilot and you also duplicated it
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.
Symfony's HttpUtils class handles authentication-related redirects internally but doesn't expose a public method for general open redirect validation. The Security component's TargetPathTrait stores/retrieves redirect paths but doesn't validate them.
For arbitrary redirect parameters like _redirect, there's no built-in Symfony utility - custom validation is the standard approach. OWASP and Symfony security best practices recommend validating that redirects are either relative paths or same-origin URLs, which is what this implementation does.
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.
Extracted the method into RedirectUrlValidationTrait in ResourceBundle/Controller. Both FrontendController and StorageListController now use this trait. (30441bd)
|
Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details. Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
@copilot try again |
…duplication Co-authored-by: dpfaffenbauer <5981845+dpfaffenbauer@users.noreply.github.com>
|



Summary
This PR fixes open redirect vulnerabilities in several controllers by validating the
_redirectparameter before using it for redirects.Changes Made
RedirectUrlValidationTraitinResourceBundle/Controllerto provide reusable redirect URL validationFrontendControllerto use the traitStorageListControllerto use the trait_redirectparameter usage in:RegisterController::registerActionCustomerController::addressActionCartController::addItemActionStorageListController::addItemActionSecurity Measures
The
validateRedirectUrlmethod ensures that redirect URLs are safe by:/(but not//) are allowed//evil.comstyle URLshttporhttpsschemesjavascript:,data:,vbscript:,file:, etc.@charactersOriginal prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.