Repository navigation
11.0.16
Breaking changes
New IHtmlSanitizer.NamedPropertyTags member
Classes that implement IHtmlSanitizer directly, such as wrappers and decorators, must add the new NamedPropertyTags member. Mocks created with Moq, NSubstitute, and similar libraries are unaffected.
Security hardening
name is removed from certain elements
The name attribute is now removed from embed, form, iframe, img, and object elements by default.
Browsers expose the names of these elements as properties of document and window. For example, <img name="getElementById"> could replace document.getElementById on the page displaying the sanitized output and break its scripts. This is known as DOM clobbering.
The name attribute is still retained on other elements, including <a name> anchors, <map name> image maps, and form fields.
You can configure the affected elements through the new NamedPropertyTags set on HtmlSanitizer, HtmlSanitizerOptions, and HtmlSanitizerDefaults. To restore the previous behavior:
sanitizer.NamedPropertyTags.Clear();You can also cancel individual removals in the RemovingAttribute event. If you allow iframe elements and use their names as link targets, remove iframe from the set.
contenteditable is no longer allowed by default
An editable region gives an attacker a paste target on the host page. In Firefox, pasted <style> elements are retained, allowing CSS that the sanitizer would otherwise strip to affect the whole page.
To allow the attribute again:
sanitizer.AllowedAttributes.Add("contenteditable");Dependencies
- AngleSharp: 1.9.0 → 1.9.1
- AngleSharp.Css: 1.3.1 → 1.3.2
Credits for finding the name and contenteditable issues
Gareth Heyes (PortSwigger Research)
See also:
https://portswigger.net/research/css-the-bomb-inside-your-inbox
https://portswigger.net/research/smashing-the-token-limit