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
m (Reverted edits by Frank Alexander (talk) to last revision by Arshan) |
|||
(24 intermediate revisions by 7 users not shown) | |||
Line 1: | Line 1: | ||
− | == | + | {| |
+ | |- | ||
+ | ! width="700" align="center" | <br> | ||
+ | ! width="500" align="center" | <br> | ||
+ | |- | ||
+ | | align="right" | | ||
+ | | align="right" | | ||
+ | |} | ||
+ | =Main= | ||
+ | |||
+ | <div style="width:100%;height:160px;border:0,margin:0;overflow: hidden;">[[File:OWASP_Project_Header.jpg|link=]]</div> | ||
+ | |||
+ | {| style="padding: 0;margin:0;margin-top:10px;text-align:left;" |- | ||
+ | | valign="top" style="border-right: 1px dotted gray;padding-right:25px;" | | ||
+ | |||
+ | ==OWASP AntiSamy Project== | ||
+ | |||
+ | OWASP AntiSamy is a library for HTML and CSS encoding. | ||
+ | |||
+ | ==Introduction== | ||
+ | |||
+ | AntiSamy was originally authored by Arshan Dabirsiaghi (arshan.dabirsiaghi [at the] gmail.com) of Contrast Security with help from Jason Li (jason.li [at the] owasp.org) of Aspect Security (http://www.aspectsecurity.com/). | ||
+ | |||
+ | ==Description== | ||
The OWASP AntiSamy project is a few things. Technically, it is an API for ensuring user-supplied HTML/CSS is in compliance within an application's rules. Another way of saying that could be: It's an API that helps you make sure that clients don't supply malicious cargo code in the HTML they supply for their profile, comments, etc., that get persisted on the server. The term "malicious code" in regards to web applications usually mean "JavaScript." Cascading Stylesheets are only considered malicious when they invoke the JavaScript engine. However, there are many situations where "normal" HTML and CSS can be used in a malicious manner. So we take care of that too. | The OWASP AntiSamy project is a few things. Technically, it is an API for ensuring user-supplied HTML/CSS is in compliance within an application's rules. Another way of saying that could be: It's an API that helps you make sure that clients don't supply malicious cargo code in the HTML they supply for their profile, comments, etc., that get persisted on the server. The term "malicious code" in regards to web applications usually mean "JavaScript." Cascading Stylesheets are only considered malicious when they invoke the JavaScript engine. However, there are many situations where "normal" HTML and CSS can be used in a malicious manner. So we take care of that too. | ||
Line 9: | Line 32: | ||
The [[OWASP_Licenses|OWASP licensing policy]] (further explained in the [[Membership|membership FAQ]]) allows OWASP projects to be released under any [http://www.opensource.org/licenses/alphabetical approved open source license]. Under these guidelines, AntiSamy is distributed under a [http://www.opensource.org/licenses/bsd-license.php BSD license]. | The [[OWASP_Licenses|OWASP licensing policy]] (further explained in the [[Membership|membership FAQ]]) allows OWASP projects to be released under any [http://www.opensource.org/licenses/alphabetical approved open source license]. Under these guidelines, AntiSamy is distributed under a [http://www.opensource.org/licenses/bsd-license.php BSD license]. | ||
− | |||
− | + | | valign="top" style="padding-left:25px;width:200px;border-right: 1px dotted gray;padding-right:25px;" | | |
− | + | == What is AntiSamy == | |
− | + | OWASP AntiSamy provides: | |
[[AntiSamy Version Differences|This page]] shows a big-picture comparison between the versions. Since it's an unfunded open source project, the ports can't be expected to mirror functionality exactly. If there's something a port is missing -- let us know, and we'll try to accommodate, or write a patch! | [[AntiSamy Version Differences|This page]] shows a big-picture comparison between the versions. Since it's an unfunded open source project, the ports can't be expected to mirror functionality exactly. If there's something a port is missing -- let us know, and we'll try to accommodate, or write a patch! | ||
− | == How do I get started? | + | |
+ | == Presentations == | ||
+ | |||
+ | From OWASP & WASC AppSec U.S. 2007 Conference (San Jose, CA): [http://www.owasp.org/images/e/e9/OWASP-WASCAppSec2007SanJose_AntiSamy.ppt AntiSamy - Picking a Fight with XSS (ppt)] - by Arshan Dabirsiaghi - AntiSamy project lead | ||
+ | |||
+ | From OWASP AppSec Europe 2008 (Ghent, Belgium): [http://www.owasp.org/images/4/47/AppSecEU08-AntiSamy.ppt The OWASP AntiSamy project (ppt)] - by Jason Li - AntiSamy project contributor | ||
+ | |||
+ | From OWASP AppSec India 2008 (Delhi, India): [https://www.owasp.org/images/9/9d/AppSecIN08-ValidatingRichUserContent.ppt Validating Rich User Content (ppt)] - by Jason Li - AntiSamy project contributor | ||
+ | |||
+ | From Shmoocon 2009 (Washington, DC): [http://www.shmoocon.org/2009/slides/OWASP%20Winter%202009%20Shmoocon%20-%20Anti%20Samy.pptx AntiSamy - Picking a Fight with XSS (pptx)] - by Arshan Dabirsiaghi - AntiSamy project lead | ||
+ | |||
+ | |||
+ | == Project Leader == | ||
+ | |||
+ | [mailto:arshan.dabirsiaghi@gmail.com Arshan Dabirsiaghi] | ||
+ | |||
+ | |||
+ | == Related Projects == | ||
+ | |||
+ | == Ohloh == | ||
+ | |||
+ | * https://www.ohloh.net/p/owaspantisamy | ||
+ | |||
+ | |||
+ | | valign="top" style="padding-left:25px;width:200px;" | | ||
+ | |||
+ | == News and Events == | ||
+ | * [26 Sep 2017] Please update AntiSamy to 1.5.5 or later per [https://nvd.nist.gov/vuln/detail/CVE-2016-10006 CVE-2016-10006] | ||
+ | * [20 Nov 2013] News 2 | ||
+ | * [30 Sep 2013] News 1 | ||
+ | |||
+ | == In Print == | ||
+ | This project can be purchased as a print on demand book from Lulu.com | ||
+ | |||
+ | |||
+ | ==Classifications== | ||
+ | |||
+ | {| width="200" cellpadding="2" | ||
+ | |- | ||
+ | | align="center" valign="top" width="50%" rowspan="2"| [[File:Owasp-incubator-trans-85.png|link=https://www.owasp.org/index.php/OWASP_Project_Stages#tab=Incubator_Projects]] | ||
+ | | align="center" valign="top" width="50%"| [[File:Owasp-builders-small.png|link=]] | ||
+ | |- | ||
+ | | align="center" valign="top" width="50%"| [[File:Owasp-defenders-small.png|link=]] | ||
+ | |- | ||
+ | | colspan="2" align="center" | [[File:Cc-button-y-sa-small.png|link=http://creativecommons.org/licenses/by-sa/3.0/]] | ||
+ | |- | ||
+ | | colspan="2" align="center" | [[File:Project_Type_Files_CODE.jpg|link=]] | ||
+ | |} | ||
+ | |||
+ | |} | ||
+ | |||
+ | = How do I get started? = | ||
There's 4 steps in the process of integrating AntiSamy. Each step is detailed in the next section, but the high level overview follows: | There's 4 steps in the process of integrating AntiSamy. Each step is detailed in the next section, but the high level overview follows: | ||
− | # Download AntiSamy from | + | # Download AntiSamy from Maven |
# Choose one of the standard policy files that matches as close to the functionality you need: | # Choose one of the standard policy files that matches as close to the functionality you need: | ||
− | #* antisamy-slashdot.xml | + | #* antisamy-tinymce-X.X.X.xml |
− | #* antisamy-ebay.xml | + | #* antisamy-slashdot-X.X.X.xml |
− | #* antisamy-myspace.xml | + | #* antisamy-ebay-X.X.X.xml |
− | #* antisamy-anythinggoes.xml | + | #* antisamy-myspace-X.X.X.xml |
+ | #* antisamy-anythinggoes-X.X.X.xml | ||
# Tailor the policy file according to your site's rules | # Tailor the policy file according to your site's rules | ||
# Call the API from the code | # Call the API from the code | ||
Line 33: | Line 107: | ||
=== Stage 1 - Downloading AntiSamy === | === Stage 1 - Downloading AntiSamy === | ||
− | + | First, add the dependency from Maven: | |
− | + | <dependency> | |
− | + | <groupId>org.owasp.antisamy</groupId> | |
− | + | <projectId>antisamy</projectId> | |
− | + | </dependency> | |
− | |||
− | |||
− | |||
=== Stage 2 - Choosing a base policy file === | === Stage 2 - Choosing a base policy file === | ||
Line 52: | 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/) | + | 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 | + | 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 80: | 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: |
− | + | import org.owasp.validator.html.*; | |
− | + | ||
− | Policy policy = Policy.getInstance(POLICY_FILE_LOCATION); | + | Policy policy = Policy.getInstance(POLICY_FILE_LOCATION); |
− | + | ||
− | AntiSamy as = new AntiSamy(); | + | AntiSamy as = new AntiSamy(); |
− | CleanResults cr = as.scan(dirtyInput, policy); | + | CleanResults cr = as.scan(dirtyInput, policy); |
− | + | ||
− | MyUserDAO.storeUserProfile(cr.getCleanHTML()); // some custom function | + | 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 97: | 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 119: | Line 182: | ||
<code>getScanTime()</code> - returns the scan time in seconds | <code>getScanTime()</code> - returns the scan time in seconds | ||
− | == | + | = Acknowledgements = |
+ | == Contacting us == | ||
+ | There are two ways of getting information on AntiSamy. The mailing list, and contacting the project lead directly. | ||
+ | === OWASP AntiSamy mailing list === | ||
+ | The first is the mailing list which is located at https://lists.owasp.org/mailman/listinfo/owasp-antisamy. The list was previously private and the archives have been cleared with the release of version 1.0. We encourage all prospective and current users and bored attackers to join in the conversation. We're happy to brainstorm attack scenarios, discuss regular expressions and help with integration. | ||
+ | |||
+ | === 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 [contrastsecurity.com] or Dave Wichers at [dave.wichers] at [owasp.org]. | ||
+ | |||
+ | === Issue tracking === | ||
+ | |||
+ | Visit the [https://github.com/nahsra/antisamy/issues GitHub issue tracker]. | ||
+ | |||
+ | ==Sponsors== | ||
+ | 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]]. | ||
+ | |||
+ | = Road Map = | ||
This section details the status of the various ports of AntiSamy. | This section details the status of the various ports of AntiSamy. | ||
Line 127: | 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's Assessment == | == Project's Assessment == | ||
This project was assessed by [[:User:Jeff Williams|Jeff Williams]] and his evaluation can be seen [http://spreadsheets.google.com/ccc?key=pAX6n7m2zaTW-JtGBqixbTw '''here''']. | This project was assessed by [[:User:Jeff Williams|Jeff Williams]] and his evaluation can be seen [http://spreadsheets.google.com/ccc?key=pAX6n7m2zaTW-JtGBqixbTw '''here''']. | ||
+ | |||
+ | __NOTOC__ <headertabs /> | ||
[[Category:OWASP Project|AntiSamy Project]] | [[Category:OWASP Project|AntiSamy Project]] | ||
Line 173: | Line 230: | ||
[[Category:OWASP Download]] | [[Category:OWASP Download]] | ||
[[Category:OWASP Release Quality Tool]] | [[Category:OWASP Release Quality Tool]] | ||
+ | |||
+ | {{OWASP Builders}} |
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.