Skip to content

Open Redirect on Login via `next`

Moderate
northwestwitch published GHSA-3x45-2m34-x95v Sep 30, 2024 · 1 comment

Package

No package listed

Affected versions

<=4.88.1

Patched versions

4.89

Description

Summary

Open redirect vulnerability allows performing phishing attacks on users by redirecting them to malicious page.
/login API endpoint is vulnerable to open redirect attack via next parameter due to absence of sanitization logic.
Additionally, due to lack of scheme validation, HTTPS Downgrade Attack can be performed on the users.

Note: This vulnerability was found by the SAST tool I am current on the development.

Details

In /login API endpoint, next value from parameter is stored in session["next_url"].

@login_bp.route("/login", methods=["GET", "POST"])
@public_endpoint
def login():
"""Login a user if they have access."""
if "next" in request.args:
session["next_url"] = request.args["next"]
user_id = None
user_mail = None

Upon completing login process, perform_login function will be returned.

return perform_login(user_dict)

If the user is successfully logged in, the user will be redirect based on parameter from next, next_url from session or default url.
Since in the previous step, we have next value stored in next_url, this may be used in performing the redirect.

def perform_login(user_dict):
if login_user(user_dict, remember=True):
flash("you logged in as: {}".format(user_dict.name), "success")
next_url = session.pop("next_url", None)
return redirect(request.args.get("next") or next_url or url_for("cases.index"))
flash("sorry, you could not log in", "warning")
return redirect(url_for("public.index"))

This will result in the user being redirected to the malicious site.

PoC

  1. Visit the the PoC link like below where hostname replaced with the host the application is being served on.
http://[hostname]/login?next=https://example.com
  1. You will be redirect to http://[hostname]. Login with your account.
  2. Upon login, You will be redirect to the malicious page. In this PoC, it will be https://example.com.
scout_poc.mov

Impact

The attacker can redirect victims to the attacker controlled malicious website attempting to steal sensitive information from them.
Moreover, the attacker can attempt to perform HTTPS Downgrade Attack to perform Man-in-the-Middle (MitM) attack to steal sessions to perform account takeover etc.

@northwestwitch
Copy link
Member

Severity

Moderate

CVSS overall score

This score calculates overall vulnerability severity from 0 to 10 and is based on the Common Vulnerability Scoring System (CVSS).
/ 10

CVSS v3 base metrics

Attack vector
Network
Attack complexity
Low
Privileges required
None
User interaction
Required
Scope
Unchanged
Confidentiality
Low
Integrity
Low
Availability
None

CVSS v3 base metrics

Attack vector: More severe the more the remote (logically and physically) an attacker can be in order to exploit the vulnerability.
Attack complexity: More severe for the least complex attacks.
Privileges required: More severe if no privileges are required.
User interaction: More severe when no user interaction is required.
Scope: More severe when a scope change occurs, e.g. one vulnerable component impacts resources in components beyond its security scope.
Confidentiality: More severe when loss of data confidentiality is highest, measuring the level of data access available to an unauthorized user.
Integrity: More severe when loss of data integrity is the highest, measuring the consequence of data modification possible by an unauthorized user.
Availability: More severe when the loss of impacted component availability is highest.
CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:L/I:L/A:N

CVE ID

CVE-2024-47530

Weaknesses

Credits