Skip to content
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

[Vulnerability] Cross site scripting (XSS) and Open Redirect on the login page #396

Merged
merged 2 commits into from
Jun 23, 2023
Merged

Conversation

catmandx
Copy link
Contributor

Description

The login page is vulnerable to open redirect and XSS attacks. An attacker can craft a seemingly valid URL and then trick the admin into clicking, after the admin authenticates the payload will run, which will :

  1. Redirect the browser to any URL the attacker chooses. This can lead to phishing and credential theft.
  2. Run javascript code inside the admin's browser. This can lead to unauthorized actions being performed, including but not limited to:
    a. Create a new webui user with admin privileges, which can be used to takeover the entire application.
    b. Create new clients, exfiltrate existing client config and send to attacker. This can lead to exposure of private network/servers, enabling further exploitation.

Cause

The function redirectNext in login.html does not check the value of 'next' parameters before redirecting:

    function redirectNext() {
        const urlParams = new URLSearchParams(window.location.search);
        const nextURL = urlParams.get('next');
        if (nextURL) {
            window.location.href = nextURL;
        } else {
            window.location.href = '/{{.basePath}}';
        } 
    }

Steps to reproduce

  1. Open redirect
    Login URL: https://example.com:5000/login?next=/

Change the 'next' parameter to any url:
https://example.com:5000/login?next=https://malicious.domain

After logging in the user will be redirected to the malicious domain.

  1. Cross site scripting:
    Change the 'next' parameter to:
javascript:alert(1)

Screenshot

image

The fix

Check if the 'next' param is just a singular slash (/) or starts with a slash and a character. This will prevent payloads like these:

javascript:alert(1)
https://google.com
//google.com

@ngoduykhanh
Copy link
Owner

Thanks @catmandx for reporting and fixing the issue. Merging it.

@ngoduykhanh ngoduykhanh merged commit 6bbe230 into ngoduykhanh:master Jun 23, 2023
@catmandx catmandx deleted the master-new branch June 23, 2023 11:12
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