CVE-2024-41810

6.1 MEDIUM

📋 TL;DR

This CVE describes an HTML injection vulnerability in Twisted's twisted.web.util.redirectTo function that can lead to reflected cross-site scripting (XSS). Attackers who can control redirect URLs can inject malicious scripts that execute in victims' browsers. This affects applications using vulnerable Twisted versions that allow user-controlled redirects.

💻 Affected Systems

Products:
  • Twisted
Versions: All versions before 24.7.0rc1
Operating Systems: All operating systems running Python
Default Config Vulnerable: ⚠️ Yes
Notes: Only vulnerable if application code uses redirectTo with user-controlled URLs. The vulnerability exists in the framework but requires specific application usage patterns.

📦 What is this software?

⚠️ Risk & Real-World Impact

🔴

Worst Case

Attackers steal session cookies, credentials, or perform actions on behalf of authenticated users, potentially leading to account takeover or data theft.

🟠

Likely Case

Attackers execute arbitrary JavaScript in victims' browsers, potentially stealing session tokens or performing limited malicious actions.

🟢

If Mitigated

With proper input validation and output encoding, the vulnerability is prevented even without patching.

🌐 Internet-Facing: HIGH
🏢 Internal Only: MEDIUM

🎯 Exploit Status

Public PoC: ✅ No
Weaponized: UNKNOWN
Unauthenticated Exploit: ⚠️ Yes
Complexity: LOW

Exploitation requires the attacker to control the redirect URL parameter and the victim to visit a malicious link. No authentication bypass is needed.

🛠️ Fix & Mitigation

✅ Official Fix

Patch Version: 24.7.0rc1 and later

Vendor Advisory: https://github.com/twisted/twisted/security/advisories/GHSA-cf56-g6w6-pqq2

Restart Required: Yes

Instructions:

1. Upgrade Twisted to version 24.7.0rc1 or later using pip: 'pip install --upgrade twisted>=24.7.0rc1'. 2. Restart all services using Twisted. 3. Test application functionality after upgrade.

🔧 Temporary Workarounds

Input Validation and Sanitization

all

Validate and sanitize all user-controlled redirect URLs before passing to redirectTo function

Output Encoding

all

Implement proper HTML encoding for redirect response content

🧯 If You Can't Patch

  • Implement strict input validation for all redirect URL parameters
  • Use Content Security Policy (CSP) headers to mitigate XSS impact

🔍 How to Verify

Check if Vulnerable:

Check Twisted version: 'python -c "import twisted; print(twisted.__version__)"' - if version < 24.7.0rc1, you are vulnerable if using redirectTo with user input.

Check Version:

python -c "import twisted; print(twisted.__version__)"

Verify Fix Applied:

After upgrade, verify version is >=24.7.0rc1 and test redirect functionality with various inputs.

📡 Detection & Monitoring

Log Indicators:

  • Unusual redirect patterns
  • URLs with script tags or JavaScript in parameters
  • Multiple failed redirect attempts

Network Indicators:

  • HTTP redirect responses containing script tags
  • Suspicious URL parameters in redirect requests

SIEM Query:

web.logs | where url contains "redirect" and (url contains "<script>" or url contains "javascript:")

🔗 References

📤 Share & Export