-
Notifications
You must be signed in to change notification settings - Fork 179
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Prevent a HTML sanitization vulnerability
CVE-2021-42576 A vulnerability was discovered by https://github.com/TomAnthony https://www.tomanthony.co.uk/ which allowed the contents of a `style` tag to be leaked unsanitized by bluemonday into the HTML output. Further it was demonstrated that if the form elements `select` and `option` were allowed by the policy that this could result in a successful XSS. You would only be vulnerable to if if you allowed `style`, `select` and `option` in your HTML sanitization policy: ```go p := bluemonday.NewPolicy() p.AllowElements("style","select") html := p.Sanitize(`<select><option><style><script>alert(1)</script>`) fmt.Println(html) ``` bluemonday very strongly recommends not allowing the `style` element in a policy. It is fundamentally unsafe as we do not have a CSS sanitizer and the content is passed through unmodified. bluemonday has been updated to explicitly suppress `style` and `script` elements by default even if you do allow them by policy as these are considered unsafe. If you have a use-case for using bluemonday whilst trusting the input then you can assert this via `p.AllowUnsafe(true)` which will let `style` and `script` through if the policy also allows them. Note: the policies shipped with bluemonday are not vulnerable to this.
- Loading branch information
1 parent
13d1799
commit c788a2a
Showing
6 changed files
with
116 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters