Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Nov 6, 2025

Addresses critical security vulnerability where unvalidated redirect URLs in login flow allowed attackers to redirect users to external malicious sites after authentication.

Changes

  • Added isValidRedirectUrl() validation method that:

    • Rejects URLs with schemes (http://, https://, javascript:, data:, etc.)
    • Rejects protocol-relative URLs (//example.com)
    • Only allows internal paths starting with /
  • Protected both redirect entry points:

    • showLoginForm(): validates $_GET['redirect'] parameter
    • login(): validates $_POST['redirect_url'] parameter
  • Introduced DEFAULT_REDIRECT_URL constant to eliminate hardcoded fallback duplication

Example

// Before: vulnerable to external redirects
$ViewData = [
    'RedirectUrl' => $_GET['redirect'] ?? '/admin/dashboard'
];

// After: validated against malicious URLs
$requestedRedirect = $_GET['redirect'] ?? self::DEFAULT_REDIRECT_URL;
$redirectUrl = $this->isValidRedirectUrl($requestedRedirect) 
    ? $requestedRedirect 
    : self::DEFAULT_REDIRECT_URL;
$ViewData = ['RedirectUrl' => $redirectUrl];

Invalid redirect attempts now safely fall back to /admin/dashboard.


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Nov 6, 2025

Important

Review skipped

Bot user detected.

To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.


Note

Free review on us!

CodeRabbit is offering free reviews until Fri Nov 07 2025 to showcase some of the refinements we've made.

Comment @coderabbitai help to get the list of available commands and usage tips.

Copilot AI and others added 2 commits November 6, 2025 21:41
Co-authored-by: ljonesfl <1099983+ljonesfl@users.noreply.github.com>
Co-authored-by: ljonesfl <1099983+ljonesfl@users.noreply.github.com>
Copilot AI changed the title [WIP] Update authentication system with user management changes Fix open redirect vulnerability in LoginController Nov 6, 2025
Copilot AI requested a review from ljonesfl November 6, 2025 21:45
Copilot finished work on behalf of ljonesfl November 6, 2025 21:45
@ljonesfl ljonesfl closed this Nov 6, 2025
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.

2 participants