CVE-2021-32681 — wagtail
MEDIUMCVE-2021-32681 is a medium-severity (CVSS 5.4) Cross-site Scripting (XSS) vulnerability in wagtail. 3 public exploit references exist, so weaponization risk is real. A fix is available for wagtail — see the affected versions and patch details below.
Cross-site Scripting in wagtail
EPSS Exploitation Probability
Probability of exploitation in the next 30 days, from FIRST.org EPSS.
How urgent is this, really
CVE-2021-32681 by exploitation likelihood (EPSS) against impact (CVSS). Outside the shaded patch-first corner.
Where this sits among everything scored
Of 385,738 CVEs with a current EPSS score, this one falls in the < 10% band (highlighted). Counts from FIRST.org, log-scaled.
Real-World Exposure
wagtail🐍wagtail🐍wagtailReal-time download stats are indexed for npm and PyPI packages. This vulnerability affects PyPI packages — download data is not available via public APIs for these ecosystems.
Description
Impact
When the {% include_block %} template tag is used to output the value of a plain-text StreamField block (CharBlock, TextBlock or a similar user-defined block derived from FieldBlock), and that block does not specify a template for rendering, the tag output is not properly escaped as HTML. This could allow users to insert arbitrary HTML or scripting. This vulnerability is only exploitable by users with the ability to author StreamField content (i.e. users with 'editor' access to the Wagtail admin).
Patches
Patched versions have been released as Wagtail 2.11.8 (for the LTS 2.11 branch), Wagtail 2.12.5, and Wagtail 2.13.2 (for the current 2.13 branch).
Site implementors who wish to retain the existing behaviour of allowing editors to insert HTML content in these blocks (and are willing to accept the risk of untrusted editors inserting arbitrary code) may disable the escaping by surrounding the relevant {% include_block %} tag in {% autoescape off %}...{% endautoescape %}.
Workarounds
Site implementors who are unable to upgrade to a current supported version should audit their use of {% include_block %} to ensure it is not used to output CharBlock / TextBlock values with no associated template. Note that this only applies where {% include_block %} is used directly on that block (uses of include_block on a block containing a CharBlock / TextBlock, such as a StructBlock, are unaffected). In these cases, the tag can be replaced with Django's {{ ... }} syntax - e.g. {% include_block my_title_block %} becomes {{ my_title_block }}.
Acknowledgements
Many thanks to Karen Tracey for reporting this issue.
For more information
If you have any questions or comments about this advisory:
- Visit Wagtail's support channels
- Email us at [email protected] (if you wish to send encrypted email, the public key ID is
0x6ba1e1a86e0f8ce8)
Affected Packages
| Ecosystem | Package | Vulnerable range | Fix |
|---|---|---|---|
| 🐍PyPI | wagtail | all versions | 2.11.8pip install --upgrade 'wagtail==2.11.8' |
| 🐍PyPI | wagtail | ≥ 2.12&&< 2.12.5 | 2.12.5pip install --upgrade 'wagtail==2.12.5' |
| 🐍PyPI | wagtail | ≥ 2.13&&< 2.13.2 | 2.13.2pip install --upgrade 'wagtail==2.13.2' |
Affected Products
wagtailtorchboxResearch use only. For defensive security, authorized penetration testing, and academic research only. Never execute exploit code against systems without explicit written authorization.
Detection & mitigation playbook
Open-source dependencyDetect
Scan your dependency tree (package-lock.json, pnpm-lock.yaml, requirements.txt, go.sum, etc.) for wagtail, including transitive dependencies — a direct dependency you never call can still pull in a vulnerable version.
Fix
Update wagtail to 2.11.8 or later, then make sure no transitive (indirect) dependency still pins the vulnerable range — O3 confirms CVE-2021-32681 is resolved across your whole dependency graph.
Workarounds
Escape or sanitise the affected output on the server side rather than relying on client-side filtering, and add a Content-Security-Policy that blocks inline script execution so injected markup cannot run even if it reaches the page.
Frequently Asked Questions
Is CVE-2021-32681 in your dependencies?
Find it across PyPI, including transitive dependencies.