Skip to content

Releases: microcosm-cc/bluemonday

Prevent a HTML sanitization vulnerability

18 Oct 13:39
Compare
Choose a tag to compare

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:

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.

Fix XSS vulnerability in HTML attribute parsing

07 Jul 19:35
Compare
Choose a tag to compare

A well crafted HTML attribute had the potential to evade sanitization due to incorrect escaping of the attribute whilst serializing it.

This version resolves that issue. In doing so it will also correctly use &amp; to separate query string values in URLs within HTML attributes (href, src, ...).

Add SanitizeReaderToWriter(r io.Reader, w io.Writer)

17 Jun 10:20
Compare
Choose a tag to compare
Allow the last commit to work on old go versions

Also tidy up some comments

Policies that accept regexps for matching are now additive

16 Jun 20:15
7f2aa2d
Compare
Choose a tag to compare

Thanks to @KN4CK3R for the contribution of a PR that results in multiple Matching() policies on the same attr and element no longer clobber the previous regexps.

Improve data-uri base64 handling, and improve docs structure

16 Jun 11:01
75e91cc
Compare
Choose a tag to compare
Merge pull request #124 from microcosm-cc/buro9/reorg

Minor re-org to improve documentation readability

Improve support for links on all elements

16 Jun 20:22
Compare
Choose a tag to compare

Originally I had only concentrated the link validation on the elements that were safe to link. However people do want to allow some unsafe elements and yet still have the benefits of link validation and sanitization, i.e. allow iframe but still have the src safely validated... these changes allow that.

Additionally I have added tests showing how AllowSchemesWithCustomPolicy can be used to globally allow only links to certain domains, and a test that shows how to apply the AllowAttributes().Matching().OnElements to only allow a given domain on specific elements (i.e. only allow an iframe if is is a YouTube embed).

AllowComments

10 Jun 20:20
aea9941
Compare
Choose a tag to compare

Adds a new func to allow HTML comments to be allowed. But does not allow CDATA comments which will be treated as plain HTML comments.

Also updates the readme, and the versions of the dependencies that have also updated.

Update x/net to latest version

23 Apr 07:51
Compare
Choose a tag to compare

Restore support for go < 1.10

13 Apr 19:42
487bf2c
Compare
Choose a tag to compare
Update .travis.yml

Expand to include newer versions of Go

Support query args without values

09 Apr 20:30
9de6a94
Compare
Choose a tag to compare

URIs that are /page?query are now accepted and not removed.