This site is the archived OWASP Foundation Wiki and is no longer accepting Account Requests.
To view the new OWASP Foundation website, please visit https://owasp.org
Difference between revisions of "Category:OWASP AntiSamy Project"
From OWASP
Line 123: | Line 123: | ||
Accordingly, we've built a policy file that allows fairly similar functionality. All text-formatting tags that operate directly on the font, color or emphasis have been allowed. | Accordingly, we've built a policy file that allows fairly similar functionality. All text-formatting tags that operate directly on the font, color or emphasis have been allowed. | ||
− | |||
− | |||
2) antisamy-ebay.xml | 2) antisamy-ebay.xml | ||
eBay (http://www.ebay.com/) is the most popular online auction site in the universe, as far as I can tell. It is a public site so anyone is allowed to post listings with rich HTML content. It's not surprising that given the attractiveness of eBay as a target that it has been subject to a few complex XSS attacks. Listings are allowed to contain much more rich content than, say, Slashdot- so it's attack surface is considerably larger. The following tags appear to be accepted by eBay (they don't publish rules): <a>,... | eBay (http://www.ebay.com/) is the most popular online auction site in the universe, as far as I can tell. It is a public site so anyone is allowed to post listings with rich HTML content. It's not surprising that given the attractiveness of eBay as a target that it has been subject to a few complex XSS attacks. Listings are allowed to contain much more rich content than, say, Slashdot- so it's attack surface is considerably larger. The following tags appear to be accepted by eBay (they don't publish rules): <a>,... | ||
− | |||
− | |||
3) antisamy-myspace.xml | 3) antisamy-myspace.xml | ||
MySpace (http://www.myspace.com/) was, at the time this project was born, arguably the most popular social networking site today. Users were allowed to submit pretty much all HTML and CSS they want - as long as it doesn't contain JavaScript. MySpace was using a word blacklist to validate users' HTML, which is why they were subject to the infamous Samy worm (http://namb.la/). The Samy worm, which used fragmentation attacks combined with a word that should have been blacklisted (eval) - was the inspiration for the project. | MySpace (http://www.myspace.com/) was, at the time this project was born, arguably the most popular social networking site today. Users were allowed to submit pretty much all HTML and CSS they want - as long as it doesn't contain JavaScript. MySpace was using a word blacklist to validate users' HTML, which is why they were subject to the infamous Samy worm (http://namb.la/). The Samy worm, which used fragmentation attacks combined with a word that should have been blacklisted (eval) - was the inspiration for the project. | ||
− | |||
4) antisamy-anythinggoes.xml | 4) antisamy-anythinggoes.xml | ||
I don't know of a possible use case for this policy file. If you wanted to allow every single valid HTML and CSS element (but without JavaScript or blatant CSS-related phishing attacks), you can use this policy file. Not even MySpace was _this_ crazy. However, it does serve as a good reference because it contains base rules for every element, so you can use it as a knowledge base when using tailoring the other policy files. | I don't know of a possible use case for this policy file. If you wanted to allow every single valid HTML and CSS element (but without JavaScript or blatant CSS-related phishing attacks), you can use this policy file. Not even MySpace was _this_ crazy. However, it does serve as a good reference because it contains base rules for every element, so you can use it as a knowledge base when using tailoring the other policy files. | ||
− | |||
− | |||
=== Stage 3 - Tailoring the policy file === | === Stage 3 - Tailoring the policy file === | ||
Line 151: | Line 144: | ||
=== Stage 4 - Calling the AntiSamy API === | === Stage 4 - Calling the AntiSamy API === | ||
− | Using AntiSamy is | + | Using AntiSamy is easy. Here is an example of invoking AntiSamy with a policy file: |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | MyUserDAO.storeUserProfile(cr.getCleanHTML()); // some custom function | + | import org.owasp.validator.html.*; |
− | + | ||
+ | Policy policy = Policy.getInstance(POLICY_FILE_LOCATION); | ||
+ | |||
+ | AntiSamy as = new AntiSamy(); | ||
+ | CleanResults cr = as.scan(dirtyInput, policy); | ||
+ | |||
+ | MyUserDAO.storeUserProfile(cr.getCleanHTML()); // some custom function | ||
There are a few ways to create a Policy object. The <code>getInstance()</code> method can take any of the following: | There are a few ways to create a Policy object. The <code>getInstance()</code> method can take any of the following: | ||
Line 168: | Line 160: | ||
* an InputStream | * an InputStream | ||
− | Policy files can also be referenced by filename by passing a second argument to the <code>AntiSamy:scan()</code> method as the following examples show | + | Policy files can also be referenced by filename by passing a second argument to the <code>AntiSamy:scan()</code> method as the following examples show: |
− | + | AntiSamy as = new AntiSamy(); | |
− | CleanResults cr = as.scan(dirtyInput, policyFilePath);</pre></code> | + | CleanResults cr = as.scan(dirtyInput, policyFilePath);</pre></code> |
Finally, policy files can also be referenced by File objects directly in the second parameter: | Finally, policy files can also be referenced by File objects directly in the second parameter: | ||
− | + | AntiSamy as = new AntiSamy(); | |
− | CleanResults cr = as.scan(dirtyInput, new File(policyFilePath)); | + | CleanResults cr = as.scan(dirtyInput, new File(policyFilePath)); |
=== Stage 5 - Analyzing CleanResults === | === Stage 5 - Analyzing CleanResults === | ||
Line 199: | Line 191: | ||
=== Emailing the project lead === | === Emailing the project lead === | ||
− | For content which is not appropriate for the public mailing list, you can alternatively contact the project lead, Arshan Dabirsiaghi, at [arshan.dabirsiaghi] at [ | + | For content which is not appropriate for the public mailing list, you can alternatively contact the project lead, Arshan Dabirsiaghi, at [arshan.dabirsiaghi] at [contrastsecurity.com] or Dave Wichers at [dave.wichers] at [owasp.org]. |
=== Issue tracking === | === Issue tracking === | ||
Line 206: | Line 198: | ||
==Sponsors== | ==Sponsors== | ||
− | The AntiSamy project is sponsored by [ | + | The AntiSamy project is sponsored by [https://www.contrastsecurity.com/ Contrast Security]. |
The initial Java project was sponsored by the [[OWASP Spring Of Code 2007|OWASP Spring Of Code 2007]]. The .NET project was sponsored by the [[OWASP Summer of Code 2008]]. | The initial Java project was sponsored by the [[OWASP Spring Of Code 2007|OWASP Spring Of Code 2007]]. The .NET project was sponsored by the [[OWASP Summer of Code 2008]]. | ||
Line 217: | Line 209: | ||
=== .NET === | === .NET === | ||
− | A .NET port of AntiSamy is available now at the [[:Category:OWASP AntiSamy Project .NET|OWASP AntiSamy .NET]] page. The project was funded by a Summer of Code 2008 grant and was developed by Jerry Hoff. | + | A .NET port of AntiSamy is available now at the [[:Category:OWASP AntiSamy Project .NET|OWASP AntiSamy .NET]] page. The project was funded by a Summer of Code 2008 grant and was developed by Jerry Hoff. However, this version of AntiSamy has not been updated in a while. |
− | This port is no longer under active development, and is looking for a few good developers to help make it feature-synchronized with the | + | This port is no longer under active development, and is looking for a few good developers to help make it feature-synchronized with the Java version. If it doesn't suit your needs, consider Microsoft's [http://blogs.msdn.com/b/securitytools/archive/2009/09/01/html-sanitization-in-anti-xss-library.aspx AntiXSS] library. |
=== Python === | === Python === | ||
− | A | + | A port of AntiSamy to Python was attempted, but has been abandoned since 2010. Michael Coates suggests you check out project Bleach instead: https://pypi.org/project/bleach/ |
=== PHP === | === PHP === | ||
Although a PHP version was initially planned, we now suggest [http://htmlpurifier.org HTMLPurifier] for safe rich input validation for PHP applications. | Although a PHP version was initially planned, we now suggest [http://htmlpurifier.org HTMLPurifier] for safe rich input validation for PHP applications. | ||
− | |||
− | |||
=Project About= | =Project About= |
Latest revision as of 22:06, 13 May 2019
|
|
---|---|
This project is part of the OWASP Builders community. Feel free to browse other projects within the Defenders, Builders, and Breakers communities. |
Subcategories
This category has only the following subcategory.