This issue has been created
There are 2 updates.
 
 
XWiki Commons / cid:jira-generated-image-avatar-8380d369-6ff8-4193-830b-f172fc23e507 XCOMMONS-3869 Open

The HTML sanitizer removes SVG elements with camel case names like linearGradient

 
View issue   ยท   Add comment
 

Issue created

 
cid:jira-generated-image-avatar-1a245fcc-4854-4ea7-aa92-ed5627a0de72 Michael Hamann created this issue on 02/Nov/26 10:40
 
Summary: The HTML sanitizer removes SVG elements with camel case names like linearGradient
Issue Type: cid:jira-generated-image-avatar-8380d369-6ff8-4193-830b-f172fc23e507 Bug
Affects Versions: 14.6-rc-1
Assignee: Unassigned
Components: XML
Created: 02/Nov/26 10:40
Priority: cid:jira-generated-image-static-major-87bef64b-7bbe-410f-ac36-ca17910f96f5 Major
Reporter: Michael Hamann
Description:

The secure HTML element sanitizer compares element names case-sensitively, while its lists of allowed SVG elements are lowercase (except for the filter elements, which are in camel case). Attribute names are already compared case-insensitively.

As a consequence, in restricted HTML cleaning (e.g., HTML macros written by users without script right):

  • SVG elements written with their standard camel case name, like linearGradient, radialGradient, clipPath or textPath, are removed, together with their content. Only the lowercase spelling lineargradient is kept. Browsers serialize SVG elements in camel case, so content copied from a browser loses its gradients and clip paths.
  • SVG filter elements are only kept in camel case, e.g., feGaussianBlur is kept but fegaussianblur is removed.
  • Uppercase names like <RECT> are removed.
  • The tag names configured in xml.htmlElementSanitizer.forbidTags and xml.htmlElementSanitizer.extraAllowedTags are also matched case-sensitively, so, e.g., forbidding feimage doesn't forbid feImage.

Browsers parse element names case-insensitively, and DOMPurify, which the sanitizer is based on, lowercases them before checking them.

Steps to reproduce

  1. As a user without script right, create a page with:
    {{html}}
    <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 10 10"><defs><linearGradient id="g"><stop offset="0" stop-color="red"></stop><stop offset="1" stop-color="blue"></stop></linearGradient></defs><rect fill="url(#g)" width="10" height="10"></rect></svg>
    {{/html}}
    

Expected: the rectangle is displayed with a gradient.
Actual: the linearGradient element is removed and the rectangle is black.

 
 

2 updates

 
cid:jira-generated-image-avatar-1a245fcc-4854-4ea7-aa92-ed5627a0de72 Changes by Michael Hamann on 02/Nov/26 10:40
 
Fix Version: 18.10.0-rc-1
Assignee: Michael Hamann