plone.app.textfield: Stored XSS by spoofing mime type
Impact
A stored XSS affecting RichText fields. RichTextValue.output returns the raw, unsanitized stored value whenever the stored mimeType equals the outputMimeType. Because the safe-HTML output type (text/x-html-safe) is the type that signifies "already sanitized", any value whose stored mimeType equals it bypasses the safe_html transform entirely on render. The transform itself is sound — it correctly strips on* event-handler attributes and javascript:/data: URIs; the defect is that it is never invoked for these values. The unsanitized value is then emitted via tal:content="structure ...", which performs no escaping, so the payload executes in the viewer's browser.
This can be a problem when a RichText field is wrongly defined in code with a mimeType and outputMimeType that are the same, or when the REST API is used to the same effect.
Patches
The problem has been patched:* For Plone 6.0, upgrade plone.app.textfield to 2.0.2.
* For Plone 6.1, upgrade plone.app.textfield to 3.0.2.
* For Plone 6.2, upgrade plone.app.textfield to 4.0.1.