CVE-2021-29434: Improper validation of URLs in Wagtail rich text fields

wagtail Updated 02 Oct 2025

Summary

20/04/2021
Yes i
High
6.1

CVE-2021-29434: Improper validation of URLs ('Cross-site Scripting') in Wagtail rich text fields. Affects wagtail across 2 version ranges.

< 2.11.7 >= 2.12, < 2.12.4

Fixed in 2.11.7 or 2.12.4, depending on the release line you run. How to fix ↓

Free scan

Check if this vulnerability affects your application

Upload a manifest or SBOM and we'll show whether you're affected, plus every other risky package in the same scan.

Check my app free

No signup required · Results in about 60 seconds

Upload your dependency manifest or SBOM

Drag & drop your file here or

Java Javascript PHP Python Go Rust Ruby Dart C/C++ Elixir CycloneDX SPDX

Upload a supported dependency manifest or SBOM. No installation or source-code access required.

See supported files and SBOM formats
SBOM sbom.json · bom.json · bom.xml · *.spdx.json · *.cdx.json · *.cdx.xml
Java pom.xml · gradle.lockfile · buildscript-gradle.lockfile
Javascript package-lock.json · yarn.lock · pnpm-lock.yaml
PHP composer.lock
Python poetry.lock · requirements.txt · Pipfile.lock
Go go.mod
Rust Cargo.lock
Ruby Gemfile.lock
Dart pubspec.lock
C/C++ conan.lock
Elixir mix.lock
Enter your work email to receive your report link.

Verify your email to view the full report and start 30 days of continuous monitoring. No credit card required.

Sponsored Devnack Penetration testing for web, API and mobile Manual testing by engineers who build software, not an auditor's checklist. Trusted by teams at Swift and Google Talk to Devnack

Background

Wagtail is an open-source content management system (CMS) written in Python. It provides a flexible and user-friendly interface for managing website content. The rich text fields in Wagtail allow users to create and edit content with formatting options. However, a vulnerability has been discovered in the way Wagtail handles URLs in these rich text fields.

Vulnerability Detail

The vulnerability in Wagtail arises from the lack of server-side validation of link URLs in the admin interface. When saving the contents of a rich text field, Wagtail does not enforce checks to ensure that the URLs use a valid protocol. This allows a malicious user with access to the admin interface to craft a POST request containing javascript: URLs with arbitrary code. It is important to note that this vulnerability is not exploitable by ordinary site visitors without admin access.

How To Fix

Latest published version: 8.0.1 as of 23 Oct 2026

pip install --upgrade "wagtail==8.0.1"

Upgrading to it may include breaking changes; the versions below are the minimum fixed release for this vulnerability.

If you can't move to the latest

The minimum fixed version depends on the release line you run.

  • < 2.11.7 2.11.7
    pip install --upgrade "wagtail==2.11.7"
  • >= 2.12, < 2.12.4 2.12.4
    pip install --upgrade "wagtail==2.12.4"

Tip — Not sure which release line you're on? Vulert can find the fix for the version you are using. Scan free →

Workaround

For sites that cannot easily upgrade to the patched versions, a temporary workaround can be implemented by adding the following code to a wagtail_hooks.py module in any installed app:

from draftjs_exporter.dom import DOM
from wagtail.admin.rich_text.converters.html_to_contentstate import ExternalLinkElementHandler, PageLinkElementHandler
from wagtail.core import hooks
from wagtail.core.whitelist import check_url


def link_entity(props):
    id_ = props.get('id')
    link_props = {}

    if id_ is not None:
        link_props['linktype'] = 'page'
        link_props['id'] = id_
    else:
        link_props['href'] = check_url(props.get('url'))

    return DOM.create_element('a', link_props, props['children'])


@hooks.register('register_rich_text_features', order=1)
def register_link(features):
    features.register_converter_rule('contentstate', 'link', {
        'from_database_format': {
            'a[href]': ExternalLinkElementHandler('LINK'),
            'a[linktype="page"]': PageLinkElementHandler('LINK'),
        },
        'to_database_format': {
            'entity_decorators': {'LINK': link_entity}
        }
    })

This code adds a custom link converter rule that applies server-side checks for valid protocols. It ensures that only safe URLs are allowed in the rich text fields.

Conclusion

The vulnerability in Wagtail's rich text fields allows for the execution of arbitrary code through crafted javascript: URLs. To mitigate this risk, it is crucial to upgrade to the patched versions of Wagtail (2.11.7 or 2.12.4). Alternatively, a temporary workaround can be implemented by adding custom code to enforce server-side checks. For further support on vulnerability remediation, please contact DevNack.com.

See every vulnerability recorded for wagtail →

Share this vulnerability

FAQ

Wagtail is an open-source content management system (CMS) written in Python. It provides a flexible and user-friendly interface for managing website content.

The vulnerability allows a malicious user with access to the Wagtail admin interface to craft POST requests containing javascript: URLs with arbitrary code. This can lead to the execution of malicious code and potential security breaches.

No, this vulnerability is not exploitable by ordinary site visitors without access to the Wagtail admin interface.

To fix this vulnerability, it is recommended to upgrade to the patched versions of Wagtail (2.11.7 or 2.12.4). These versions include server-side checks for valid protocols in link URLs.

Yes, for sites that cannot easily upgrade to the patched versions, a temporary workaround is provided. It involves adding custom code to enforce server-side checks for valid protocols in link URLs.

Related vulnerabilities

Recent vulnerabilities recorded for wagtail.

How To Fix

Latest published version: 8.0.1 as of 23 Oct 2026

pip install --upgrade "wagtail==8.0.1"

Upgrading to it may include breaking changes; the versions below are the minimum fixed release for this vulnerability.

If you can't move to the latest

The minimum fixed version depends on the release line you run.

  • < 2.11.7 2.11.7
    pip install --upgrade "wagtail==2.11.7"
  • >= 2.12, < 2.12.4 2.12.4
    pip install --upgrade "wagtail==2.12.4"

Tip — Not sure which release line you're on? Vulert can find the fix for the version you are using. Scan free →

Subscribe to Vulert on Telegram
Daily digest of new CVEs, critical and high severity, affected packages and fixes — plus a weekly roundup.
Join the channel →
Help improve this record
Report an issue or send feedback