Itprotectssitesfrom[XSS](http://en.wikipedia.org/wiki/Cross-site_scripting) attacks. There are many [vectors for an XSS attack](https://www.owasp.org/index.php/XSS_Filter_Evasion_Cheat_Sheet) and the best way to mitigate the risk is to sanitize user input against a known safe list of HTML elements and attributes.
Ifyouuse[blackfriday](https://github.com/russross/blackfriday) or [Pandoc](http://johnmacfarlane.net/pandoc/) then bluemonday should be run after these steps. This ensures that no insecure HTML is introduced later in your process.
bluemondayisheavilyinspiredbyboththe[OWASPJavaHTMLSanitizer](https://code.google.com/p/owasp-java-html-sanitizer/) and the [HTML Purifier](http://htmlpurifier.org/).
Thepolicycontainingthewhitelistisappliedusingafastnon-validating,forwardonly,token-basedparserimplementedinthe[Gonet/htmllibrary](https://godoc.org/golang.org/x/net/html) by the core Go team.
Weexpecttobesuppliedwithwell-formattedHTML(closingelementsforeveryapplicableopenelement,nestedcorrectly)andsowedonotfocusonrepairingbadlynestedorincompleteHTML.Wefocusonsimplyensuringthatwhateverelementsdoexistaredescribedinthepolicywhitelistandthatattributesandlinksaresafeforuseonyourwebpage.[GIGO](http://en.wikipedia.org/wiki/Garbage_in,_garbage_out) does apply and if you feed it bad HTML bluemonday is not tasked with figuring out how to make it good again.
Wearepassingourextensivetestsuite(includingAntiSamytestsaswellastestsforanyissuesraised).Checkforany[unresolvedissues](https://github.com/microcosm-cc/bluemonday/issues?page=1&state=open) to see whether anything may be a blocker for you.
TheessenceofbuildingapolicyistodeterminewhichHTMLelementsandattributesareconsideredsafeforyourscenario.OWASPprovidean[XSSpreventioncheatsheet](https://www.owasp.org/index.php/XSS_(Cross_Site_Scripting)_Prevention_Cheat_Sheet) to help explain the risks, but essentially:
AnadditionalcomplexityregardinglinksisthedataURIasdefinedin[RFC2397](http://tools.ietf.org/html/rfc2397). The data URI allows for images to be served inline using this format:
Itshouldbenotedthatthereisapotential[security](http://palizine.plynt.com/issues/2010Oct/bypass-xss-filters/) [risk](https://capec.mitre.org/data/definitions/244.html) with the use of data URI links. You should only enable data URI links if you already trust the content.
*AddsupportforCSSsanitisationtoallowsomeCSSpropertiesbasedonawhitelist,possiblyusingthe[GorillaCSS3scanner](http://www.gorillatoolkit.org/pkg/css/scanner) - PRs welcome so long as testing covers XSS and demonstrates safety first