{"id":"CVE-2024-41810","aliases":["CVE-2024-41810","GHSA-cf56-g6w6-pqq2","PYSEC-2024-75"],"related":[],"kind":"vulnerability","state":"published","title":"HTML injection in HTTP redirect body","summary":"Twisted is an event-based framework for internet applications, supporting Python 3.6+. The `twisted.web.util.redirectTo` function contains an HTML injection vulnerability. If application code allows an attacker to control the redirect URL this vulnerability may result in Reflected Cross-Site Scripting (XSS) in the redirect response HTML body. This vulnerability is fixed in 24.7.0rc1.","summarySource":"cvelist","descriptions":[{"lang":"en","text":"Twisted is an event-based framework for internet applications, supporting Python 3.6+. The `twisted.web.util.redirectTo` function contains an HTML injection vulnerability. If application code allows an attacker to control the redirect URL this vulnerability may result in Reflected Cross-Site Scripting (XSS) in the redirect response HTML body. This vulnerability is fixed in 24.7.0rc1.","source":"cvelist"},{"lang":"en","text":"### Summary\n\nThe `twisted.web.util.redirectTo` function contains an HTML injection vulnerability. If application code allows an attacker to control the redirect URL this vulnerability may result in Reflected Cross-Site Scripting (XSS) in the redirect response HTML body.\n\n### Details\nTwisted’s `redirectTo` function generates an `HTTP 302 Redirect` response. The response contains an HTML body, built for exceptional cases where the browser doesn’t properly handle the redirect, allowing the user to click a link, navigating them to the specified destination.\n\nThe function reflects the destination URL in the HTML body without any output encoding. \n```python\n# https://github.com/twisted/twisted/blob/trunk/src/twisted/web/_template_util.py#L88\ndef redirectTo(URL: bytes, request: IRequest) -> bytes:\n    # ---snip---\n    content = b\"\"\"\n<html>\n    <head>\n        <meta http-equiv=\\\"refresh\\\" content=\\\"0;URL=%(url)s\\\">\n    </head>\n    <body bgcolor=\\\"#FFFFFF\\\" text=\\\"#000000\\\">\n    <a href=\\\"%(url)s\\\">click here</a>\n    </body>\n</html>\n\"\"\" % {\n        b\"url\": URL\n    }\n    return content\n```\n\nIf an attacker has full or partial control over redirect location due to an application bug, also known as an “Open Redirect”, they may inject arbitrary HTML into the response’s body, ultimately leading to an XSS attack.\n\nIt’s worth noting that the issue is known to maintainers and tracked with GitHub [Issue#9839](https://github.com/twisted/twisted/issues/9839). The issue description, however, does not make any mention of exploitability and simply states: “…Browsers don't seem to actually render that page…”\n\n### PoC\nThe issue can be reproduced by running the following Twisted-based HTTP server locally:\n```python\nfrom twisted.web import server, resource\nfrom twisted.internet import reactor\nfrom twisted.web.util import redirectTo\n\nclass Simple(resource.Resource):\n    isLeaf = True\n    def render_GET(self, request):\n        url = request.args[b'url'][0]  # <-- open redirect\n        return redirectTo(url, request)\n\nsite = server.Site(Simple())\nreactor.listenTCP(9009, site)\nreactor.run()\n```\nOnce running, navigate to the following URL: `http://127.0.0.1:9009?url=ws://example.com/\"><script>alert(document.location)</script>`, and verify that the “alert” dialog was displayed.\n\n**Note**: Due to the different ways browsers validate the redirect Location header, this attack is possible only in **Firefox**. All other tested browsers will display an error message to the user and will not render the HTML body.\n\n### Impact\nIf successfully exploited, the issue will allow malicious JavaScript to run in the context of the victim's session. This will in turn lead to unauthorized access/modification to victim's account and information associated with it, or allow for unauthorized operations to be performed within the context of the victim's session.","format":"markdown","source":"ghsa"},{"lang":"es","text":"Twisted es un framework basado en eventos para aplicaciones de Internet, compatible con Python 3.6+. La función `twisted.web.util.redirectTo` contiene una vulnerabilidad de inyección de HTML. Si el código de la aplicación permite a un atacante controlar la URL de redireccionamiento, esta vulnerabilidad puede provocar Cross Site Scripting reflejado (XSS) en el cuerpo HTML de la respuesta de redireccionamiento. Esta vulnerabilidad se soluciona en 24.7.0rc1.","source":"nvd"}],"published":"2024-07-29T15:41:40.289Z","modified":"2026-06-17T07:48:16.593Z","severity":{"scorer":"GitHub_M","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:L/I:L/A:N","score":6.1,"rating":"MEDIUM"},"severities":[{"scorer":"GitHub_M","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:L/I:L/A:N","score":6.1,"rating":"MEDIUM"},{"scorer":"GitHub","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:L/I:L/A:N","score":6.1,"rating":"MEDIUM"},{"scorer":"GitHub","scheme":"CVSS:4.0","vector":"CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:P/VC:N/VI:N/VA:N/SC:L/SI:L/SA:N","rating":"MEDIUM"},{"scorer":"NVD","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:L/I:L/A:N","score":6.1,"rating":"MEDIUM"},{"scorer":"PyPA Advisory Database","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:L/I:L/A:N","score":6.1,"rating":"MEDIUM"}],"cwes":["CWE-79","CWE-80"],"affected":[{"ranges":[{"version":"<= 24.3.0","status":"affected"}],"vendor":"twisted","product":"twisted","source":"cvelist"},{"ranges":[{"type":"custom","introduced":"0","lastAffected":"24.3.0","status":"affected"}],"vendor":"twistedmatrix","product":"twisted","cpe":"cpe:2.3:a:twistedmatrix:twisted:*:*:*:*:*:*:*:*","source":"cvelist"},{"ranges":[{"type":"ecosystem","introduced":"0","status":"affected","fixed":"24.7.0rc1"}],"ecosystem":"PyPI","package":"twisted","purl":"pkg:pypi/twisted","source":"ghsa"},{"ranges":[{"status":"affected","lastAffected":"24.3.0"}],"vendor":"twisted","product":"twisted","cpe":"cpe:2.3:a:twisted:twisted:*:*:*:*:*:*:*:*","source":"nvd"},{"ranges":[{"type":"git","introduced":"0","status":"affected","fixed":"046a164f89a0f08d3239ecebd750360f8914df33"},{"type":"ecosystem","introduced":"0","status":"affected","fixed":"24.7.0rc1"}],"ecosystem":"PyPI","package":"twisted","purl":"pkg:pypi/twisted","repo":"https://github.com/twisted/twisted","source":"pysec"}],"references":[{"url":"https://github.com/twisted/twisted/security/advisories/GHSA-cf56-g6w6-pqq2","tags":["advisory","vendor-advisory","web","x-refsource-confirm","x-transferred"],"sources":["cvelist","ghsa","nvd","pysec"]},{"url":"https://github.com/twisted/twisted/commit/046a164f89a0f08d3239ecebd750360f8914df33","tags":["fix","patch","web","x-refsource-misc","x-transferred"],"sources":["cvelist","ghsa","nvd","pysec"]},{"url":"https://lists.debian.org/debian-lts-announce/2024/11/msg00028.html","tags":["web"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://nvd.nist.gov/vuln/detail/CVE-2024-41810","tags":["advisory"],"sources":["ghsa"]},{"url":"https://github.com/pypa/advisory-database/tree/main/vulns/twisted/PYSEC-2024-75.yaml","tags":["web"],"sources":["ghsa"]},{"url":"https://github.com/twisted/twisted","tags":["package"],"sources":["ghsa"]}],"credits":[],"assigner":"GitHub_M","ssvc":{"scorer":"CISA-ADP","exploitation":"poc","automatable":"no","technicalImpact":"partial","date":"2024-07-29T16:39:25.608Z"},"sources":[{"source":"cvelist","name":"CVE List","id":"CVE-2024-41810","url":"https://www.cve.org/CVERecord?id=CVE-2024-41810","licence":"CVE Terms of Use","modified":"2025-11-03T22:01:01.094Z"},{"source":"ghsa","name":"GitHub Advisory Database","id":"GHSA-cf56-g6w6-pqq2","url":"https://github.com/advisories/GHSA-cf56-g6w6-pqq2","licence":"CC-BY-4.0","modified":"2025-11-04T17:06:06.972Z"},{"source":"nvd","name":"NVD","id":"CVE-2024-41810","url":"https://nvd.nist.gov/vuln/detail/CVE-2024-41810","licence":"Public domain","modified":"2026-06-17T07:48:16.593Z"},{"source":"pysec","name":"PyPA Advisory Database","id":"PYSEC-2024-75","url":"https://osv.dev/vulnerability/PYSEC-2024-75","licence":"CC-BY-4.0","modified":"2024-09-11T19:42:11.394Z"}],"updatedAt":"2026-11-25T22:58:43.331Z","epss":{"score":0.01497,"percentile":0.7453,"date":"2026-11-30T12:00:22.000Z"}}