{"id":"CVE-2021-29434","aliases":["CVE-2021-29434","GHSA-wq5h-f9p5-q7fx","PYSEC-2021-114"],"related":[],"kind":"vulnerability","state":"published","title":"Improper validation of URLs ('Cross-site Scripting') in Wagtail rich text fields","summary":"Wagtail is a Django content management system. In affected versions of Wagtail, when saving the contents of a rich text field in the admin interface, Wagtail does not apply server-side checks to ensure that link URLs use a valid protocol. A malicious user with access to the admin interface could thus craft a POST request to publish content with `javascript:` URLs containing arbitrary code. The vulnerability is not exploitable by an ordinary site visitor without access to the Wagtail admin. See referenced GitHub advisory for additional details, including a workaround. Patched versions have been released as Wagtail 2.11.7 (for the LTS 2.11 branch) and Wagtail 2.12.4 (for the current 2.12 branch).","summarySource":"cvelist","descriptions":[{"lang":"en","text":"Wagtail is a Django content management system. In affected versions of Wagtail, when saving the contents of a rich text field in the admin interface, Wagtail does not apply server-side checks to ensure that link URLs use a valid protocol. A malicious user with access to the admin interface could thus craft a POST request to publish content with `javascript:` URLs containing arbitrary code. The vulnerability is not exploitable by an ordinary site visitor without access to the Wagtail admin. See referenced GitHub advisory for additional details, including a workaround. Patched versions have been released as Wagtail 2.11.7 (for the LTS 2.11 branch) and Wagtail 2.12.4 (for the current 2.12 branch).","source":"cvelist"},{"lang":"en","text":"### Impact\nWhen saving the contents of a rich text field in the admin interface, Wagtail does not apply server-side checks to ensure that link URLs use a valid protocol. A malicious user with access to the admin interface could thus craft a POST request to publish content with `javascript:` URLs containing arbitrary code. The vulnerability is not exploitable by an ordinary site visitor without access to the Wagtail admin.\n\n### Patches\nPatched versions have been released as Wagtail 2.11.7 (for the LTS 2.11 branch) and Wagtail 2.12.4 (for the current 2.12 branch).\n\n### Workarounds\nFor sites that cannot easily upgrade to a current supported version, the vulnerability can be patched by adding the following code to a `wagtail_hooks.py` module in any installed app:\n\n```python\nfrom draftjs_exporter.dom import DOM\nfrom wagtail.admin.rich_text.converters.html_to_contentstate import ExternalLinkElementHandler, PageLinkElementHandler\nfrom wagtail.core import hooks\nfrom wagtail.core.whitelist import check_url\n\n\ndef link_entity(props):\n    id_ = props.get('id')\n    link_props = {}\n\n    if id_ is not None:\n        link_props['linktype'] = 'page'\n        link_props['id'] = id_\n    else:\n        link_props['href'] = check_url(props.get('url'))\n\n    return DOM.create_element('a', link_props, props['children'])\n\n\n@hooks.register('register_rich_text_features', order=1)\ndef register_link(features):\n    features.register_converter_rule('contentstate', 'link', {\n        'from_database_format': {\n            'a[href]': ExternalLinkElementHandler('LINK'),\n            'a[linktype=\"page\"]': PageLinkElementHandler('LINK'),\n        },\n        'to_database_format': {\n            'entity_decorators': {'LINK': link_entity}\n        }\n    })\n```\n\n### Acknowledgements\nMany thanks to Kevin Breen for reporting this issue.\n\n### For more information\nIf you have any questions or comments about this advisory:\n\n* Visit Wagtail's [support channels](https://docs.wagtail.io/en/stable/support.html)\n* Email us at security@wagtail.io (if you wish to send encrypted email, the public key ID is `0x6ba1e1a86e0f8ce8`)","format":"markdown","source":"ghsa"},{"lang":"es","text":"Wagtail es un sistema de gestión de contenido de Django.&#xa0;En las versiones afectadas de Wagtail, al guardar el contenido de un campo de texto enriquecido en la interfaz de administración, Wagtail no aplica comprobaciones del lado del servidor para garantizar a las URL de los enlaces usar un protocolo válido.&#xa0;Un usuario malicioso con acceso a la interfaz de administración podría entonces diseñar una petición POST para publicar contenido con URLs \"javascript:\" que contengan código arbitrario.&#xa0;La vulnerabilidad no es explotable por un visitante ordinario del sitio sin acceso al administrador de Wagtail.&#xa0;Véase el aviso de GitHub al que se hace referencia para obtener detalles adicionales, incluyendo una solución alternativa.&#xa0;Las versiones parcheadas ha sido lanzadas como Wagtail versión 2.11.7 (para la rama LTS 2.11) y Wagtail versión 2.12.4 (para la rama 2.12 actual)","source":"nvd"}],"published":"2021-04-19T18:45:14.000Z","modified":"2026-09-10T03:49:26.868Z","severity":{"scorer":"GitHub_M","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:H/UI:R/S:U/C:H/I:H/A:N","score":6.1,"rating":"MEDIUM"},"severities":[{"scorer":"GitHub_M","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:H/UI:R/S:U/C:H/I:H/A:N","score":6.1,"rating":"MEDIUM"},{"scorer":"GitHub","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:H/UI:R/S:U/C:H/I:H/A:N","score":6.1,"rating":"HIGH"},{"scorer":"GitHub","scheme":"CVSS:4.0","vector":"CVSS:4.0/AV:N/AC:L/AT:N/PR:H/UI:P/VC:H/VI:H/VA:N/SC:N/SI:N/SA:N","rating":"HIGH"},{"scorer":"NVD","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:H/UI:R/S:C/C:L/I:L/A:N","score":4.8,"rating":"MEDIUM"},{"scorer":"NVD","scheme":"CVSS:2.0","vector":"AV:N/AC:M/Au:S/C:N/I:P/A:N","score":3.5,"rating":"LOW"}],"cwes":["CWE-79"],"affected":[{"ranges":[{"version":"<= 2.11.6","status":"affected"},{"version":">= 2.12, <= 2.12.3","status":"affected"}],"vendor":"wagtail","product":"wagtail","source":"cvelist"},{"ranges":[{"type":"ecosystem","introduced":"0","status":"affected","fixed":"2.11.7"}],"ecosystem":"PyPI","package":"wagtail","purl":"pkg:pypi/wagtail","source":"ghsa"},{"ranges":[{"type":"ecosystem","introduced":"2.12","status":"affected","fixed":"2.12.4"}],"ecosystem":"PyPI","package":"wagtail","purl":"pkg:pypi/wagtail","source":"ghsa"},{"ranges":[{"status":"affected","fixed":"2.11.6"},{"status":"affected","introduced":"2.11.0","fixed":"2.11.7"},{"status":"affected","introduced":"2.12.0","fixed":"2.12.4"}],"vendor":"torchbox","product":"wagtail","cpe":"cpe:2.3:a:torchbox:wagtail:*:*:*:*:-:*:*:*","source":"nvd"},{"ranges":[{"type":"ecosystem","introduced":"2.11","status":"affected","fixed":"2.11.7"},{"type":"ecosystem","introduced":"0","status":"affected","fixed":"2.11.6"},{"type":"ecosystem","introduced":"2.12","status":"affected","fixed":"2.12.4"}],"ecosystem":"PyPI","package":"wagtail","purl":"pkg:pypi/wagtail","source":"pysec"}],"references":[{"url":"https://github.com/wagtail/wagtail/security/advisories/GHSA-wq5h-f9p5-q7fx","tags":["advisory","mitigation","third-party-advisory","web","x-refsource-confirm","x-transferred"],"sources":["cvelist","ghsa","nvd","pysec"]},{"url":"https://pypi.org/project/wagtail/","tags":["package","product","third-party-advisory","x-refsource-misc","x-transferred"],"sources":["cvelist","nvd","pysec"]},{"url":"https://nvd.nist.gov/vuln/detail/CVE-2021-29434","tags":["advisory"],"sources":["ghsa"]},{"url":"https://github.com/wagtail/wagtail/commit/5c7a60977cba478f6a35390ba98cffc2bd41c8a4","tags":["web"],"sources":["ghsa"]},{"url":"https://github.com/wagtail/wagtail/commit/915f6ed2bd7d53154103cc4424a0f18695cdad6c","tags":["web"],"sources":["ghsa"]},{"url":"https://github.com/pypa/advisory-database/tree/main/vulns/wagtail/PYSEC-2021-114.yaml","tags":["web"],"sources":["ghsa"]},{"url":"https://github.com/wagtail/wagtail","tags":["package"],"sources":["ghsa"]},{"url":"https://github.com/wagtail/wagtail/compare/v2.11.6...v2.11.7","tags":["web"],"sources":["ghsa"]},{"url":"https://pypi.org/project/wagtail","tags":["web"],"sources":["ghsa"]}],"credits":[],"assigner":"GitHub_M","sources":[{"source":"cvelist","name":"CVE List","id":"CVE-2021-29434","url":"https://www.cve.org/CVERecord?id=CVE-2021-29434","licence":"CVE Terms of Use","modified":"2024-08-03T22:02:51.911Z"},{"source":"ghsa","name":"GitHub Advisory Database","id":"GHSA-wq5h-f9p5-q7fx","url":"https://github.com/advisories/GHSA-wq5h-f9p5-q7fx","licence":"CC-BY-4.0","modified":"2026-09-10T03:49:26.868Z"},{"source":"nvd","name":"NVD","id":"CVE-2021-29434","url":"https://nvd.nist.gov/vuln/detail/CVE-2021-29434","licence":"Public domain","modified":"2026-06-17T03:47:38.060Z"},{"source":"pysec","name":"PyPA Advisory Database","id":"PYSEC-2021-114","url":"https://osv.dev/vulnerability/PYSEC-2021-114","licence":"CC-BY-4.0","modified":"2023-11-08T04:05:33.896Z"}],"updatedAt":"2026-11-25T22:58:00.856Z","epss":{"score":0.00626,"percentile":0.51348,"date":"2026-12-01T12:00:22.000Z"}}