GHSA-w2j7-f3c6-g8cw: Flask Security Flask-Security Has An Open Redirect Vulnerability

MODERATE
CVSS 4.7
CWE-601
Published
Advisory Summary

GHSA-w2j7-f3c6-g8cw is a MODERATE (CVSS 4.7) flask-security has an open redirect vulnerability (CWE-601: URL Redirection to Untrusted Site ('Open Redirect')) affecting Flask Security libraries in the PyPI ecosystem. The issue involves flask-security has an open redirect issue. Remediation is available by upgrading affected packages to version 5.8.1.

GHSA-w2j7-f3c6-g8cw at a Glance

CVE Identifier N/A
GHSA Identifier GHSA-w2j7-f3c6-g8cw
Severity MODERATE
CVSS v3.1 Base Score 4.7
CWE Classification CWE-601: URL Redirection to Untrusted Site ('Open Redirect')
Affected Product Flask Security
Package Ecosystem PyPI
Published Date
Last Updated

Security Impact

CVSS: 4.7

The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:L/I:N/A:N).

Attack Vector Network (AV:N)
Attack Complexity Low (AC:L)
Privileges Required None (PR:N)
User Interaction Required (UI:R)
Scope Changed (S:C)
Confidentiality Low (C:L)
Integrity None (I:N)
Availability None (A:N)

How to Fix GHSA-w2j7-f3c6-g8cw

To remediate this vulnerability, upgrade all affected Flask Security dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.

Flask-Security fixed: 5.8.1
pip install Flask-Security>=5.8.1
Verify Direct and Transitive Dependencies

Run the following command in your project directory to verify that all resolved dependencies use the patched release:

pip show Flask-Security

How to Check if You Are Affected

To determine whether your Python environment is affected by GHSA-w2j7-f3c6-g8cw, inspect your installed packages using pip:

pip show Flask-Security

Analyze the terminal output to locate any version of Flask Security in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 5.8.1), your application is affected.

Note: The pip show Flask-Security command checks currently installed packages in your active Python environment.

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-601: URL Redirection to Untrusted Site ('Open Redirect'), where the web application accepts a user-controlled input that specifies a link to an external site, and uses that link in a redirect. In Flask Security, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.

Source Advisory Statement

# Open Redirect in Flask-Security ## Summary `flask_security.utils.validate_redirect_url()` can allow an attacker-controlled redirect URL when subdomain redirects are enabled. The bypass uses a backslash inside the URL authority/host: ```text http://evil.com\.whitelist.com http://evil.com%5C.whitelist.com ``` Python's `urlsplit()` parses the full authority as `evil.com\.whitelist.com` or `evil.com%5C.whitelist.com`. Because the value ends with `.whitelist.com`, `validate_redirect_url()` accepts it as an allowed subdomain of `whitelist.com`. This is similar in class to the previous Flask-Security-Too open redirect advisory CVE-2023-49438 / GHSA-672h-6x89-76m5, where crafted redirect URLs bypassed validation through browser URL normalization behavior. ## Affected Configuration The issue requires subdomain redirects to be enabled: ```python SERVER_NAME = "whitelist.com" SECURITY_REDIRECT_ALLOW_SUBDOMAINS = True ``` Tested environment: ```text Flask-Security: 5.8.0 Flask: 3.1.3 Werkzeug: 3.1.8 ``` ## Impact An attacker can craft a URL that passes Flask-Security's redirect validation and produces a `302` response to an attacker-controlled URL-like authority. This can be used for phishing or other attacks that rely on a trusted application redirecting users to an attacker-controlled destination. ## Proof of Concept ### PoC Flask App ```python from __future__ import annotations from importlib.metadata import version from urllib.parse import urlsplit from flask import Flask, jsonify, redirect, request from flask_security.utils import validate_redirect_url app = Flask(__name__) app.config.update( SECRET_KEY="poc-only", SERVER_NAME="whitelist.com", SECURITY_REDIRECT_ALLOW_SUBDOMAINS=True, SECURITY_REDIRECT_BASE_DOMAIN=None, SECURITY_REDIRECT_ALLOWED_SUBDOMAINS=[], ) @app.get("/") def index(): return jsonify( flask_version=version("Flask"), configured_server_name=app.config["SERVER_NAME"], examples=[ r"http://evil.com\.whitelist.com", "http://evil.com%5C.whitelist.com", "http://sub.whitelist.com", "http://sub.not-whitelist.com", ], ) @app.get("/check") def check(): next_url = request.args.get("next", "") parsed = urlsplit(next_url) return jsonify( next=next_url, valid=validate_redirect_url(next_url), parsed={ "scheme": parsed.scheme, "netloc": parsed.netloc, "hostname": parsed.hostname, "path": parsed.path, }, ) @app.get("/redir") def redir(): next_url = request.args.get("next", "") if not validate_redirect_url(next_url): return jsonify(error="blocked", next=next_url), 400 return redirect(next_url) if __name__ == "__main__": app.run(host="127.0.0.1", port=5000, debug=False) ``` ### Steps to Reproduce Run the PoC with the target project's Flask version: ```bash .venv/bin/python poc_redirect_app.py ``` The invalid comparison case is correctly blocked: ```bash http://127.0.0.1:5000/redir?next=http://evil.com ``` Observed result: <img width="1019" height="294" alt="image" src="https://github.com/user-attachments/assets/de25ac4d-b37f-4369-928e-f44dfd5b7557" /> Check the validation result: ```bash http://127.0.0.1:5000/check?next=http://evil.com%5C.whitelist.com ``` Observed result: <img width="1029" height="634" alt="image" src="https://github.com/user-attachments/assets/8e5ec8a6-42a4-438a-8d12-a27724519091" /> ## References - CVE-2023-49438: https://advisories.gitlab.com/pypi/flask-security-too/CVE-2023-49438/ - GHSA-672h-6x89-76m5: https://osv.dev/vulnerability/CVE-2023-49438 - NVD entry for CVE-2023-49438: https://nvd.nist.gov/vuln/detail/CVE-2023-49438

GHSA-w2j7-f3c6-g8cw Affected Flask Security Versions

1 component(s)
Fixed Versions:
5.8.1
Product / Package Ecosystem Affected Versions Fixed Version
Flask-Security
PyPI
< 5.8.1
5.8.1

References

Frequently Asked Questions

What is GHSA-w2j7-f3c6-g8cw?
GHSA-w2j7-f3c6-g8cw is a security vulnerability in Flask Security involving Flask-Security has an Open Redirect issue under CWE-601: URL Redirection to Untrusted Site ('Open Redirect').
Which Flask Security versions are affected?
Affected versions include releases prior to 5.8.1 across affected packages: Flask-Security.
What version fixes GHSA-w2j7-f3c6-g8cw?
Upgrading to 5.8.1 (or the latest patched release for your respective branch) resolves the vulnerability.
Is Flask-Security affected?
Yes, Flask-Security is affected in releases prior to 5.8.1. Upgrade your dependency to 5.8.1 or later.
What is the CVSS score of GHSA-w2j7-f3c6-g8cw?
GHSA-w2j7-f3c6-g8cw has a CVSS v3.1 base score of 4.7 (MODERATE) with vector string CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:L/I:N/A:N.
What CWE is associated with GHSA-w2j7-f3c6-g8cw?
GHSA-w2j7-f3c6-g8cw is classified under CWE-601: URL Redirection to Untrusted Site ('Open Redirect') (The web application accepts a user-controlled input that specifies a link to an external site, and uses that link in a redirect.).
How can I check PyPI dependencies for GHSA-w2j7-f3c6-g8cw?
Run the dependency tree command: 'pip show Flask-Security'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "schema_version" : "1.4.0",
  "id" : "GHSA-w2j7-f3c6-g8cw",
  "modified" : "2026-06-23T22:46:31Z",
  "published" : "2026-06-23T22:46:31Z",
  "aliases" : [ ],
  "summary" : "Flask-Security has an Open Redirect issue",
  "details" : "# Open Redirect in Flask-Security\n\n## Summary\n\n`flask_security.utils.validate_redirect_url()` can allow an attacker-controlled redirect URL when subdomain redirects are enabled.\n\nThe bypass uses a backslash inside the URL authority/host:\n\n```text\nhttp://evil.com\\.whitelist.com\nhttp://evil.com%5C.whitelist.com\n```\n\nPython's `urlsplit()` parses the full authority as `evil.com\\.whitelist.com` or `evil.com%5C.whitelist.com`. Because the value ends with `.whitelist.com`, `validate_redirect_url()` accepts it as an allowed subdomain of `whitelist.com`.\n\nThis is similar in class to the previous Flask-Security-Too open redirect advisory CVE-2023-49438 / GHSA-672h-6x89-76m5, where crafted redirect URLs bypassed validation through browser URL normalization behavior.\n\n## Affected Configuration\n\nThe issue requires subdomain redirects to be enabled:\n\n```python\nSERVER_NAME = \"whitelist.com\"\nSECURITY_REDIRECT_ALLOW_SUBDOMAINS = True\n```\n\nTested environment:\n\n```text\nFlask-Security: 5.8.0\nFlask: 3.1.3\nWerkzeug: 3.1.8\n```\n\n## Impact\n\nAn attacker can craft a URL that passes Flask-Security's redirect validation and produces a `302` response to an attacker-controlled URL-like authority.\n\nThis can be used for phishing or other attacks that rely on a trusted application redirecting users to an attacker-controlled destination.\n\n## Proof of Concept\n\n### PoC Flask App\n\n```python\nfrom __future__ import annotations\n\nfrom importlib.metadata import version\nfrom urllib.parse import urlsplit\n\nfrom flask import Flask, jsonify, redirect, request\n\nfrom flask_security.utils import validate_redirect_url\n\n\napp = Flask(__name__)\napp.config.update(\n    SECRET_KEY=\"poc-only\",\n    SERVER_NAME=\"whitelist.com\",\n    SECURITY_REDIRECT_ALLOW_SUBDOMAINS=True,\n    SECURITY_REDIRECT_BASE_DOMAIN=None,\n    SECURITY_REDIRECT_ALLOWED_SUBDOMAINS=[],\n)\n\n\n@app.get(\"/\")\ndef index():\n    return jsonify(\n        flask_version=version(\"Flask\"),\n        configured_server_name=app.config[\"SERVER_NAME\"],\n        examples=[\n            r\"http://evil.com\\.whitelist.com\",\n            \"http://evil.com%5C.whitelist.com\",\n            \"http://sub.whitelist.com\",\n            \"http://sub.not-whitelist.com\",\n        ],\n    )\n\n\n@app.get(\"/check\")\ndef check():\n    next_url = request.args.get(\"next\", \"\")\n    parsed = urlsplit(next_url)\n\n    return jsonify(\n        next=next_url,\n        valid=validate_redirect_url(next_url),\n        parsed={\n            \"scheme\": parsed.scheme,\n            \"netloc\": parsed.netloc,\n            \"hostname\": parsed.hostname,\n            \"path\": parsed.path,\n        },\n    )\n\n\n@app.get(\"/redir\")\ndef redir():\n    next_url = request.args.get(\"next\", \"\")\n    if not validate_redirect_url(next_url):\n        return jsonify(error=\"blocked\", next=next_url), 400\n\n    return redirect(next_url)\n\n\nif __name__ == \"__main__\":\n    app.run(host=\"127.0.0.1\", port=5000, debug=False)\n```\n\n### Steps to Reproduce\n\nRun the PoC with the target project's Flask version:\n\n```bash\n.venv/bin/python poc_redirect_app.py\n```\n\nThe invalid comparison case is correctly blocked:\n\n```bash\nhttp://127.0.0.1:5000/redir?next=http://evil.com\n```\n\nObserved result:\n\n<img width=\"1019\" height=\"294\" alt=\"image\" src=\"https://github.com/user-attachments/assets/de25ac4d-b37f-4369-928e-f44dfd5b7557\" />\n\nCheck the validation result:\n\n```bash\nhttp://127.0.0.1:5000/check?next=http://evil.com%5C.whitelist.com\n```\n\nObserved result:\n\n<img width=\"1029\" height=\"634\" alt=\"image\" src=\"https://github.com/user-attachments/assets/8e5ec8a6-42a4-438a-8d12-a27724519091\" />\n\n## References\n\n- CVE-2023-49438: https://advisories.gitlab.com/pypi/flask-security-too/CVE-2023-49438/\n- GHSA-672h-6x89-76m5: https://osv.dev/vulnerability/CVE-2023-49438\n- NVD entry for CVE-2023-49438: https://nvd.nist.gov/vuln/detail/CVE-2023-49438",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:L/I:N/A:N"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "PyPI",
      "name" : "Flask-Security"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "5.8.1"
      } ]
    } ],
    "database_specific" : {
      "last_known_affected_version_range" : "<= 5.8.0"
    }
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/pallets-eco/flask-security/security/advisories/GHSA-w2j7-f3c6-g8cw"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2023-49438"
  }, {
    "type" : "WEB",
    "url" : "https://advisories.gitlab.com/pypi/flask-security-too/CVE-2023-49438"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/pallets-eco/flask-security"
  }, {
    "type" : "WEB",
    "url" : "https://osv.dev/vulnerability/CVE-2023-49438"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-601" ],
    "severity" : "MODERATE",
    "github_reviewed" : true,
    "github_reviewed_at" : "2026-06-23T22:46:31Z",
    "nvd_published_at" : null
  }
}