Repository navigation
v7.0.2 #254
rgrove
announced in
Announcements
v7.0.2
#254
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Security
MathML and SVG elements whose
<math>or<svg>ancestor has been removed are now also removed (keeping their contents, subject to:remove_contents), even if they're allowed by the config or have been allowlisted by a transformer. Previously, if Sanitize removed a<math>or<svg>element but kept its contents, its descendants were kept even though they'd been parsed as foreign elements, and browsers would reparse them as HTML elements. Since some elements are parsed very differently in foreign content than in HTML, this could allow arbitrary HTML to be injected. For example, the contents of a<textarea>,<title>,<xmp>,<noembed>, or<noframes>element inside a MathML or SVG element are parsed as markup rather than text, so an attribute value, comment, or raw text element inside it like<svg><textarea><!--</textarea><img src=x onerror=alert(1)>-->could close the element early once it was reparsed as HTML. Similarly, browsers that use legacy<select>parsing rules would parse the contents of a raw text element inside a<select>element like<math><select><mi><xmp><input><img src=x onerror=alert(1)></xmp>as markup. This only affected custom configs that don't remove the contents of<math>or<svg>elements and allow one of the affected elements. Sanitize's default and built-in configs aren't affected. Thanks to Mike Dalessio (@flavorjones) for reporting this issue. (GHSA-599p-54q3-ff89)Elements and comments inside text content elements such as
<textarea>,<title>,<xmp>,<noembed>, and<noframes>are now always removed, even if they're allowed by the config or have been allowlisted by a transformer. Only their text is kept, subject to:remove_contents. This provides defense in depth against the issue above. (GHSA-599p-54q3-ff89)Sanitize now requires Nokogiri 1.19.7 or higher. Nokogiri versions since 1.19.5 escape
<and>in serialized attribute values to match browser behavior, which provides defense in depth against the issue above. (GHSA-599p-54q3-ff89)Elements inside
<select>,<option>, and<optgroup>elements that browsers using legacy<select>parsing rules wouldn't allow there are now always removed (keeping their contents, subject to:remove_contents), even if they're allowed by the config or have been allowlisted by a transformer. Previously, if Sanitize removed a<template>element inside a<select>element but kept its contents, any raw text element inside the<template>element would end up inside the<select>element. Browsers that use legacy<select>parsing rules ignore the start tags of raw text elements inside a<select>element and parse their contents as markup, so input like<select><template><xmp><input><img src=x onerror=alert(1)></xmp>could be used to inject arbitrary HTML. This only affected custom configs that allow<select>and at least one raw text element such as<style>,<xmp>,<noembed>,<noframes>, or<plaintext>. Sanitize's default and built-in configs aren't affected. (GHSA-mg79-gw37-jxx7)Changed
Full Changelog: v7.0.1...v7.0.2
This discussion was created from the release v7.0.2.
All reactions