CVE-2021-21241

7.4 HIGH

📋 TL;DR

This vulnerability in Flask-Security-Too allows attackers to steal authentication tokens via CSRF attacks on unprotected GET requests to /login and /change endpoints. It affects Flask applications using Flask-Security-Too versions 3.3.0 through 3.4.4. Attackers can use stolen tokens to impersonate authenticated users.

💻 Affected Systems

Products:
  • Flask-Security-Too
Versions: 3.3.0 through 3.4.4
Operating Systems: All
Default Config Vulnerable: ⚠️ Yes
Notes: Only affects applications using authentication tokens. Applications not using tokens are not vulnerable.

📦 What is this software?

⚠️ Risk & Real-World Impact

🔴

Worst Case

Attackers steal authentication tokens and gain full access to user accounts, potentially leading to data breaches, account takeover, and privilege escalation.

🟠

Likely Case

Attackers steal authentication tokens via malicious websites and perform unauthorized actions as authenticated users.

🟢

If Mitigated

With proper CSRF protection and token validation, attackers cannot steal tokens or misuse them.

🌐 Internet-Facing: HIGH
🏢 Internal Only: MEDIUM

🎯 Exploit Status

Public PoC: ✅ No
Weaponized: LIKELY
Unauthenticated Exploit: ✅ No
Complexity: LOW

Exploitation requires user interaction (visiting malicious site) but is straightforward once token endpoints are identified.

🛠️ Fix & Mitigation

✅ Official Fix

Patch Version: 3.4.5 or 4.0.0

Vendor Advisory: https://github.com/Flask-Middleware/flask-security/security/advisories/GHSA-hh7m-rx4f-4vpv

Restart Required: Yes

Instructions:

1. Update Flask-Security-Too to version 3.4.5 or higher. 2. Run: pip install --upgrade Flask-Security-Too. 3. Restart your Flask application.

🔧 Temporary Workarounds

Disable authentication tokens

all

Set SECURITY_TOKEN_MAX_AGE to 0 to make authentication tokens unusable if your application doesn't require them.

SECURITY_TOKEN_MAX_AGE = 0

🧯 If You Can't Patch

  • Implement additional CSRF protection middleware for GET requests to /login and /change endpoints.
  • Monitor logs for unusual GET requests to token endpoints and implement rate limiting.

🔍 How to Verify

Check if Vulnerable:

Check Flask-Security-Too version in requirements.txt or via pip show Flask-Security-Too. If version is between 3.3.0 and 3.4.4, you are vulnerable.

Check Version:

pip show Flask-Security-Too | grep Version

Verify Fix Applied:

After updating, verify version is 3.4.5 or higher and test that GET requests to /login and /change no longer return authentication tokens.

📡 Detection & Monitoring

Log Indicators:

  • Multiple GET requests to /login or /change endpoints from suspicious sources
  • Authentication token exposure in server logs

Network Indicators:

  • CSRF attacks targeting token endpoints
  • Unexpected token usage from new IP addresses

SIEM Query:

source="web_logs" AND (url_path="/login" OR url_path="/change") AND http_method="GET" AND status_code=200

🔗 References

📤 Share & Export