GHSA-hvq6-2r72-p2x7: XSS
Summary
When plugin rendering fails in edit mode, django CMS renders a cms-rendering-exception block so editors can see that a placeholder could not be rendered. Older code built that block's heading by interpolating the exception message, placeholder/source strings, and the failing plugin's short description directly into an HTML string, then returned the placeholder output as safe markup.
If an editor could store HTML in data used by a plugin's getshortdescription() (or in other values interpolated into the exception message), and that plugin later raised during edit-mode rendering, the payload was parsed as HTML in the staff user's browser. This is a stored XSS condition in the CMS editing context.
Impact
The vulnerable path is only reached when placeholder rendering catches a plugin rendering exception:
python try: placeholdercontent = "".join(plugincontent) except Exception as e: context["excinfo"] = sys.excinfo() placeholdercontent = self.renderexception("rendering placeholder", context, placeholder, editable)
renderexception() constructs a message from values that can include stored content:
- value - the exception message. - placeholder - the placeholder string representation. - placeholder.source - the source object string representation, such as page content. - instance.getshortdescription() - plugin-provided summary text, often derived from plugin model fields.
In the vulnerable implementation, that message was embedded directly into an HTML heading. The final placeholder content was later returned through marksafe, so Django template autoescaping did not protect the heading.
settings.DEBUG does not mitigate the issue: it only controls whether Django's traceback HTML is appended. The custom heading is rendered in edit mode regardless of DEBUG.
Patch
Escape the custom exception heading before returning it as safe placeholder markup. The current fixed code uses formathtml, which escapes message before inserting it into the heading:
python heading = formathtml('<h2 class="cms-rendering-exception-title">{}</h2>', message)
The traceback HTML from ExceptionReporter.gettracebackhtml() should remain separate from django CMS's custom heading; Django's traceback escaping does not protect additional HTML assembled by django CMS.
Workarounds
Until patched, reduce exposure by ensuring only fully trusted staff can edit plugins whose stored fields are included in getshortdescription(), and fix or disable plugins that can be made to raise during edit-mode rendering. This is only a partial mitigation because the escaping bug is in the shared exception-rendering path.
References
- cms/pluginrendering.py - ContentRenderer.renderplaceholder - cms/pluginrendering.py - ContentRenderer.renderexception - Fixed code: heading = formathtml('<h2 class="cms-rendering-exception-title">{}</h2>', message) - Regression tests: cms.tests.testpluginrenderers.TestExceptionCatchers.testexceptioninpluginrenderescapesusercontentineditmode, cms.tests.testpluginrenderers.TestLegacyRendererExceptionCatcher.testexceptioninpluginrenderescapesusercontentineditmode
Affected Software
Remediation
Recommended actions to resolve this vulnerability, in priority order.
- Upgrade
Upgrade
pip/django-cmsto a version that resolves this vulnerability.Fixed in 5.0.9 - Upgrade
Upgrade
django CMS (plugin rendering exception heading)to a version that resolves this vulnerability.Fixed in format_html('<h2 class="cms-rendering-exception-title">{}</h2>', message) - Configuration
In the shared exception-rendering path used by plugin edit-mode rendering, escape the custom exception heading before returning it as safe placeholder markup by constructing the heading with format_html (which escapes message) rather than embedding message directly into an HTML string.
django CMS Escape exception heading with format_html = Use format_html('<h2 class="cms-rendering-exception-title">{}</h2>', message) instead of interpolating message directly into HTML - Compensating control
Until patched, reduce stored XSS exposure by ensuring only fully trusted staff can edit plugins whose stored fields are included in get_short_description(), and fix or disable plugins that can be made to raise during edit-mode rendering.
Event History
Frequently Asked Questions
Who is exposed to script execution through this issue?
The payload is parsed in the browser of a staff user using django CMS edit mode. Exposure requires content controlled by an editor to be included in a plugin short description or another value incorporated into the rendering exception.
What conditions are required for exploitation?
A plugin must raise an exception while a placeholder is being rendered in edit mode. An editor must also be able to store HTML in data that reaches the exception message, such as data used by get_short_description().
Does ordinary placeholder rendering trigger the vulnerable path?
No. The affected path is reached only when placeholder rendering catches a plugin rendering exception and renders the cms-rendering-exception block for the editor.