Difference between revisions of "Category:OWASP AntiSamy Project"

From OWASP
Jump to: navigation, search
(7 intermediate revisions by 6 users not shown)
Line 1: Line 1:
== Modelo de Auditoría de sistemas:  ==
+
=Main=
  
Éste es un modelo universal para securizar en un alto grado de seguridad al sistema operativo.  
+
<div style="width:100%;height:160px;border:0,margin:0;overflow: hidden;">[[File:OWASP_Project_Header.jpg|link=]]</div>
  
#Sistema de cifrado congelado: Mantiene en secreto la ubicación del archivo del sistema, previniendo ataques de tipo monitoreo de redes.
+
{| style="padding: 0;margin:0;margin-top:10px;text-align:left;" |-
#OpenVAS: Línea de comandos para cifrar- descifrar el protocolo TCP/Ip
+
| valign="top"  style="border-right: 1px dotted gray;padding-right:25px;" |
#Filtro Web: Previene intrusiones a través de puertos inseguros
+
#Clam Antivirus: Previene, detecta y corrige virus informático
+
  
<br>
+
==OWASP AntiSamy Project==
  
{| border="1" cellspacing="1" cellpadding="1" width="200" align="center"
+
OWASP AntiSamy is...
|-
+
| Clam Antivirus
+
{| border="1" cellspacing="1" cellpadding="1" width="200" align="center"
+
|-
+
| Filtro Web
+
{| border="1" cellspacing="1" cellpadding="1" width="200" align="center"
+
|-
+
| OpenVAS
+
{| border="1" cellspacing="1" cellpadding="1" width="200" align="center"
+
|-
+
| Sistema de Cifrado Congelado
+
|}
+
  
|}
+
==Introduction==
  
|}
+
AntiSamy was originally authored by Arshan Dabirsiaghi (arshan.dabirsiaghi [at the] gmail.com) with help from Jason Li (li.jason.c [at the] gmail.com), both 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.
 +
 
 +
Philosophically, AntiSamy is a departure from contemporary security mechanisms. Generally, the security mechanism and user have a communication that is virtually one way, for good reason. Letting the potential attacker know details about the validation is considered unwise as it allows the attacker to "learn" and "recon" the mechanism for weaknesses. These types of information leaks can also hurt in ways you don't expect. A login mechanism that tells the user, "Username invalid" leaks the fact that a user by that name does not exist. A user could use a dictionary or phone book or both to remotely come up with a list of valid usernames. Using this information, an attacker could launch a brute force attack or massive account lock denial-of-service. We get that.
 +
 
 +
Unfortunately, that's just not very usable in this situation. Typical Internet users are largely pretty bad when it comes to writing HTML/CSS, so where do they get their HTML from? Usually they copy it from somewhere out on the web. Simply rejecting their input without any clue as to why is jolting and annoying. Annoyed users go somewhere else to do their social networking.
 +
 
 +
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].
 +
 
 +
 
 +
==Licensing==
 +
OWASP AntiSamy is free to use. It is licensed under the http://creativecommons.org/licenses/by-sa/3.0/ Creative Commons Attribution-ShareAlike 3.0 license], so you can copy, distribute and transmit the work, and you can adapt it, and use it commercially, but all provided that you attribute the work and if you alter, transform, or build upon this work, you may distribute the resulting work only under the same or similar license to this one.
 +
 
 +
 
 +
| 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! 
 +
 
 +
 
 +
== 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;" |
 +
 
 +
== Quick Download ==
 +
 
 +
https://code.google.com/p/owaspantisamy/downloads/list
 +
 
 +
 
 +
 
 +
== News and Events ==
 +
* [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=]]
 +
  |}
  
 
|}
 
|}
  
== Descripción softwares de auditoría  ==
+
= 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:
 +
# Download AntiSamy from [http://code.google.com/p/owaspantisamy/downloads/list its home on Google Code]
 +
# Choose one of the standard policy files that matches as close to the functionality you need:
 +
#* antisamy-tinymce-X.X.X.xml
 +
#* antisamy-slashdot-X.X.X.xml
 +
#* antisamy-ebay-X.X.X.xml
 +
#* antisamy-myspace-X.X.X.xml
 +
#* antisamy-anythinggoes-X.X.X.xml
 +
# Tailor the policy file according to your site's rules
 +
# Call the API from the code
 +
 
 +
=== Stage 1 - Downloading AntiSamy ===
 +
 
 +
The following instructions are for AntiSamy Java, the main version. For instructions on the .NET version, see [[the .NET page]].
 +
 
 +
Which package you download depends on what you want to do with AntiSamy. If you'd like to extend it or review the code, download the source package '''antisamy-X.X.X-src.jar'''. If you're looking to integrate AntiSamy, you can either download the library or use Maven to include it in your build. If you want to use Maven, here's [[an example POM for including AntiSamy]]. If you want a jar file, then download the '''antisamy-X.X.X.jar''' (which, before version 1.2 was confusingly called "antisamy-standalone-X.X.X.jar"), which only contains AntiSamy library. This will be the preferred choice for mature enterprise environments who don't want to be caught in classpath issues which may be introduced by the current version.
 +
 
 +
The second option, ''only available for versions before 1.2,'' is to download '''antisamy-standalone-X.X.X.jar''', which contains not only the AntiSamy code, but all necessary supporting libraries. This should only be used by applications that don't use the libraries AntiSamy ships with as they might introduce classpath and versioning issues. ''This option is no longer available after version 1.2.''
 +
 
 +
You must also download required dependencies, which are documented in the '''Developer Guide.pdf''' file.
 +
 
 +
You can Download AntiSamy from [http://code.google.com/p/owaspantisamy/downloads/list its home on Google Code]
  
*El sistema de cifrado http://truecrypt.org cifra el núcleo del sistema operativo y los discos lógicos impidiendo ataques espía.
+
=== Stage 2 - Choosing a base policy file ===
  
*Los comandos shell http://openvas.org sirven para analizar protocolos de red, detección de virus y cifrado del protocolo IpV4-6
+
Chances are that your site's use case for AntiSamy is at least roughly comparable to one of the predefined policy files. They each represent a "typical" scenario for allowing users to provide HTML (and possibly CSS) formatting information. Let's look into the different policy files:
  
*El filtro web http://freenetproject.org es una técnica que reemplaza al Firewall, discriminando puertos inseguros, ahorrando tiempo de procesamiento en el núcleo del sistema.
+
1) antisamy-slashdot.xml
  
*Clamwin.com es un software de código abierto, no usa computación en la nube y tiene una GUI que detecta virus en línea http://sourceforge.net/projects/clamsentinel
+
Slashdot (http://www.slashdot.org/) is a techie news site that allows users to respond anonymously to news posts with very limited HTML markup. Now Slashdot is not only one of the coolest sites around, it's also one that's been subject to many different successful attacks. Even more unfortunate is the fact that most of the attacks led users to the infamous goatse.cx picture (please don't go look it up). The rules for Slashdot are fairly strict: users can only submit the following HTML tags and no CSS: &lt;b&gt;, &lt;u&gt;, &lt;i&gt;, &lt;a&gt;, &lt;blockquote&gt;.
  
== Macroinformática  ==
+
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.
  
La macroinformática comprende eficiencia, seguridad y naturaleza. La eficacia de un sistema operativo se mide por la interacción hombre-máquina, sintetizando aplicaciones minimalistas y ejecutándolas nuestro sistema operativo procesará los datos eficientemente, ejemplos:
 
  
*Transmisión cifrada: Cliente e-mail con GnuPG
 
  
http://fellowship.fsfe.org
+
2) antisamy-ebay.xml
  
*Sistema de cifrado: Cifra y descifra texto plano, imágenes, etc..
+
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>,...
  
#ftp://ftp.gnupg.org/gcrypt/binary/gnupg-w32cli-1.4.11.exe
 
#http://cryptophane.googlecode.com/files/cryptophane-0.7.0.exe
 
  
*Ruby: Lenguaje de programación experimental
 
  
http://ruby-lang.org
+
3) antisamy-myspace.xml
  
*J2re1.3.1_20: Ejecutable de objetos interactivos o applets
+
MySpace (http://www.myspace.com/) is arguably the most popular social networking site today. Users are allowed to submit pretty much all HTML and CSS they want - as long as it doesn't contain JavaScript. MySpace is currently 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.
  
http://java.sun.com/products/archive/j2se/1.3.1_20/index.html
 
  
*Escritorio: Gestor de ventanas X11
+
4) antisamy-anythinggoes.xml
  
http://windowmaker.info
+
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 is _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.
  
*Gnuzilla: Navegador seguro y de uso libre
 
  
http://code.google.com/p/iceweaselwindows/downloads/list
 
  
*Gnupdf: Visor de formato de texto universal pdf
+
=== Stage 3 - Tailoring the policy file ===
  
http://blog.kowalczyk.info/software/sumatrapdf
+
Smaller organizations may want to deploy AntiSamy in a default configuration, but it's equally likely that a site may want to have strict, business-driven rules for what users can allow. The discussion that decides the tailoring should also consider attack surface - which grows in relative proportion to the policy file.
  
*Gnuflash: Jugador alternativo a flash player
+
You may also want to enable/modify some "directives", which are basically advanced user options. [[AntiSamy Directives|This page]] tells you what the directives are and which versions support them.
  
http://gnu.org/software/gnash
+
=== Stage 4 - Calling the AntiSamy API ===
  
*Zinf: Reproductor de audio
+
Using AntiSamy is abnormally easy. Here is an example of invoking AntiSamy with a policy file:
  
http://zinf.org  
+
<code><pre>import org.owasp.validator.html.*;
  
*Informática forense: Análisis de datos ocultos en el disco duro
+
Policy policy = Policy.getInstance(POLICY_FILE_LOCATION);
  
http://sleuthkit.org
+
AntiSamy as = new AntiSamy();
 +
CleanResults cr = as.scan(dirtyInput, policy);
  
*Compresor: Comprime datos sobreescribiendo bytes repetidos
+
MyUserDAO.storeUserProfile(cr.getCleanHTML()); // some custom function
 +
</pre></code>
  
http://peazip.sourceforge.net
+
There are a few ways to create a Policy object. The <code>getInstance()</code> method can take any of the following:
 +
* a String filename
 +
* a File object
 +
* an InputStream
  
*Ftp: Gestor de descarga de archivos
+
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.:
  
http://dfast.sourceforge.net
+
<code><pre>AntiSamy as = new AntiSamy();
 +
CleanResults cr = as.scan(dirtyInput, policyFilePath);</pre></code>
  
*AntiKeylogger: Neutraliza el seguimiento de escritorios remotos (Monitoring)
+
Finally, policy files can also be referenced by File objects directly in the second parameter:
  
http://psmantikeyloger.sourceforge.net
+
<code><pre>AntiSamy as = new AntiSamy();
 +
CleanResults cr = as.scan(dirtyInput, new File(policyFilePath));</pre></code>
  
*Password manager: Gestión de contraseñas
+
=== Stage 5 - Analyzing CleanResults ===
  
http://passwordsafe.sourceforge.net
+
The CleanResults object provides a lot of useful stuff.  
  
*Limpiador de disco: Borra archivos innecesrios del sistema
+
<code>getErrorMessages()</code> - a list of <code>String</code> error messages
  
http://bleachbit.sourceforge.net
+
<code>getCleanHTML()</code> - the clean, safe HTML output
  
*Desfragmentador: Reordena los archivos del disco duro, generando espacio virtual
+
<code>getCleanXMLDocumentFragment()</code> - the clean, safe <code>XMLDocumentFragment</code> which is reflected in <code>getCleanHTML()</code>
  
http://kessels.com/jkdefrag
+
<code>getScanTime()</code> - returns the scan time in seconds
  
*X11: Gestor de ventanas, reemplazo de escritorio Xwindow's
+
= Acknowledgements =
 +
== Contacting us ==
 +
There are two ways of getting information on AntiSamy. The mailing list, and contacting the project lead directly.
  
http://bb4win.org  
+
=== 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.
  
*Open Hardware: Hardware construído por la comunidad Linux
+
=== Emailing the project lead ===
  
http://open-pc.com  
+
For content which is not appropriate for the public mailing list, you can alternatively contact the project lead, Arshan Dabirsiaghi, at [arshan.dabirsiaghi] at [aspectsecurity.com].
  
*Open WRT: Firmware libre para configurar transmisión de Internet
+
=== Issue tracking ===
  
http://openwrt.org
+
Visit the [http://code.google.com/p/owaspantisamy/issues/list Google Code issue tracker].
  
*Gnu- Linux: Sistema operativo universal
 
  
http://gnewsense.org
 
  
== Biocriptoseguridad ==: Es la unión de la biología, criptografía y hacking ético para formar una defensa stándar contra virus complejos.  
+
==Sponsors==
 +
The AntiSamy project is sponsored by {{MemberLinks|link=http://www.aspectsecurity.com|logo=Aspect_logo_owasp.jpg}}
  
Implementación de la biocriptoseguridad informática:
+
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]].
  
#Amplificar la banda ancha
+
= Road Map =
#Optimizar (limpiar- modificar) el sistema operativo
+
This section details the status of the various ports of AntiSamy.
#Desfragmentar los discos lógicos
+
#Ocultar el sistema operativo
+
#Configurar antivirus
+
#Limpiar y desfragmentar
+
#Congelar
+
  
*Sistema inmune._ Defensa biológica natural contra infecciones como virus http://immunet.com
+
=== Grails ===
 +
Daniel Bower created a [http://www.grails.org/plugin/sanitizer Grails plugin] for AntiSamy.
  
*Criptografía._ Método de escritura oculta por caractes, números y letras:—{H}/gJa¢K¡Ng÷752%\*)A>¡#(W|a— http://diskcryptor.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.  
  
*Hacking ético._ Auditoría de sistemas informáticos que preserva la integridad de los datos.
+
This port is no longer under active development, and is looking for a few good developers to help make it feature-synchronized with the .NET 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.
  
Congelador: Mantiene el equilibrio en la integridad de los datos, el sistema operativo, red , memoria ram, ciclos de CPU, espacio en disco duro e incidencias de malware
+
=== Python ===
 +
A beta Python version is currently being prototyped by a few different groups. As more information becomes available, we will post it here. If you are interested in helping, please contact the mailing list.
  
*http://code.google.com/p/hzr312001/downloads/detail?name=Deep%20systemze%20Standard%20Version%206.51.020.2725.rar&amp;can=2&amp;q= (para Window's)
+
=== PHP ===
*http://sourceforge.net/projects/lethe (para GNU/Linux)
+
Although a PHP version was initially planned, we now suggest [http://htmlpurifier.org HTMLPurifier] for safe rich input validation for PHP applications.
  
<br>Auditoría de virus cifrado._ Un criptovirus se oculta tras un algoritmo de criptografía, generalmente es híbrido simétrico-asimétrico con una extensión de 1700bit's, burla los escáneres antivirus con la aleatoriedad de cifrado, facilitando la expansión de las botnet's. La solución es crear un sistema operativo transparente, anonimizarlo y usar herramientas de cifrado stándar de uso libre:
 
  
*Gnupg: Sirve para cifrar mensajes de correo electrónico http://gpg4win.org/download.html
 
  
*Open Secure Shell: Ofuscador TcpIp, protege el túnel de comunicación digital cifrando la Ip. http://openvas.org
+
=Project About=
 +
== Project's Assessment ==
  
*Red protegida: DNS libre http://namespace.org/switch
+
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'''].
  
*Criptosistema simétrico: Encapsula el disco duro, incluyendo el sistema operativo,usando algoritmo Twofish http://truecrypt.org/downloads.php
+
__NOTOC__ <headertabs />
  
*Proxy cifrado: Autenticación de usuario anónimo http://torproject.org
+
[[Category:OWASP Project|AntiSamy Project]]
 +
[[Category:OWASP Tool]]
 +
[[Category:OWASP Download]]
 +
[[Category:OWASP Release Quality Tool]]
  
Energías renovables._ Son energías adquiridas por medios naturales: hidrógeno, aire, sol que disminuyen la toxicidad de las emisiones de Co2 en el medio ambiente, impulsando políticas ecologistas contribuímos a preservar el ecosistema. Ejm: Usando paneles solares fotovoltaicos.
+
{{OWASP Builders}}

Revision as of 13:23, 22 April 2014

[edit]

OWASP Project Header.jpg

OWASP AntiSamy Project

OWASP AntiSamy is...

Introduction

AntiSamy was originally authored by Arshan Dabirsiaghi (arshan.dabirsiaghi [at the] gmail.com) with help from Jason Li (li.jason.c [at the] gmail.com), both 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.

Philosophically, AntiSamy is a departure from contemporary security mechanisms. Generally, the security mechanism and user have a communication that is virtually one way, for good reason. Letting the potential attacker know details about the validation is considered unwise as it allows the attacker to "learn" and "recon" the mechanism for weaknesses. These types of information leaks can also hurt in ways you don't expect. A login mechanism that tells the user, "Username invalid" leaks the fact that a user by that name does not exist. A user could use a dictionary or phone book or both to remotely come up with a list of valid usernames. Using this information, an attacker could launch a brute force attack or massive account lock denial-of-service. We get that.

Unfortunately, that's just not very usable in this situation. Typical Internet users are largely pretty bad when it comes to writing HTML/CSS, so where do they get their HTML from? Usually they copy it from somewhere out on the web. Simply rejecting their input without any clue as to why is jolting and annoying. Annoyed users go somewhere else to do their social networking.

The OWASP licensing policy (further explained in the membership FAQ) allows OWASP projects to be released under any approved open source license. Under these guidelines, AntiSamy is distributed under a BSD license.


Licensing

OWASP AntiSamy is free to use. It is licensed under the http://creativecommons.org/licenses/by-sa/3.0/ Creative Commons Attribution-ShareAlike 3.0 license], so you can copy, distribute and transmit the work, and you can adapt it, and use it commercially, but all provided that you attribute the work and if you alter, transform, or build upon this work, you may distribute the resulting work only under the same or similar license to this one.


What is AntiSamy

OWASP AntiSamy provides:

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!


Presentations

From OWASP & WASC AppSec U.S. 2007 Conference (San Jose, CA): AntiSamy - Picking a Fight with XSS (ppt) - by Arshan Dabirsiaghi - AntiSamy project lead

From OWASP AppSec Europe 2008 (Ghent, Belgium): The OWASP AntiSamy project (ppt) - by Jason Li - AntiSamy project contributor

From OWASP AppSec India 2008 (Delhi, India): Validating Rich User Content (ppt) - by Jason Li - AntiSamy project contributor

From Shmoocon 2009 (Washington, DC): AntiSamy - Picking a Fight with XSS (pptx) - by Arshan Dabirsiaghi - AntiSamy project lead


Project Leader

Arshan Dabirsiaghi


Related Projects

Ohloh


Quick Download

https://code.google.com/p/owaspantisamy/downloads/list


News and Events

  • [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

Owasp-incubator-trans-85.png Owasp-builders-small.png
Owasp-defenders-small.png
Cc-button-y-sa-small.png
Project Type Files CODE.jpg

There's 4 steps in the process of integrating AntiSamy. Each step is detailed in the next section, but the high level overview follows:

  1. Download AntiSamy from its home on Google Code
  2. Choose one of the standard policy files that matches as close to the functionality you need:
    • antisamy-tinymce-X.X.X.xml
    • antisamy-slashdot-X.X.X.xml
    • antisamy-ebay-X.X.X.xml
    • antisamy-myspace-X.X.X.xml
    • antisamy-anythinggoes-X.X.X.xml
  3. Tailor the policy file according to your site's rules
  4. Call the API from the code

Stage 1 - Downloading AntiSamy

The following instructions are for AntiSamy Java, the main version. For instructions on the .NET version, see the .NET page.

Which package you download depends on what you want to do with AntiSamy. If you'd like to extend it or review the code, download the source package antisamy-X.X.X-src.jar. If you're looking to integrate AntiSamy, you can either download the library or use Maven to include it in your build. If you want to use Maven, here's an example POM for including AntiSamy. If you want a jar file, then download the antisamy-X.X.X.jar (which, before version 1.2 was confusingly called "antisamy-standalone-X.X.X.jar"), which only contains AntiSamy library. This will be the preferred choice for mature enterprise environments who don't want to be caught in classpath issues which may be introduced by the current version.

The second option, only available for versions before 1.2, is to download antisamy-standalone-X.X.X.jar, which contains not only the AntiSamy code, but all necessary supporting libraries. This should only be used by applications that don't use the libraries AntiSamy ships with as they might introduce classpath and versioning issues. This option is no longer available after version 1.2.

You must also download required dependencies, which are documented in the Developer Guide.pdf file.

You can Download AntiSamy from its home on Google Code

Stage 2 - Choosing a base policy file

Chances are that your site's use case for AntiSamy is at least roughly comparable to one of the predefined policy files. They each represent a "typical" scenario for allowing users to provide HTML (and possibly CSS) formatting information. Let's look into the different policy files:

1) antisamy-slashdot.xml

Slashdot (http://www.slashdot.org/) is a techie news site that allows users to respond anonymously to news posts with very limited HTML markup. Now Slashdot is not only one of the coolest sites around, it's also one that's been subject to many different successful attacks. Even more unfortunate is the fact that most of the attacks led users to the infamous goatse.cx picture (please don't go look it up). The rules for Slashdot are fairly strict: users can only submit the following HTML tags and no CSS: <b>, <u>, <i>, <a>, <blockquote>.

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

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

MySpace (http://www.myspace.com/) is arguably the most popular social networking site today. Users are allowed to submit pretty much all HTML and CSS they want - as long as it doesn't contain JavaScript. MySpace is currently 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

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 is _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

Smaller organizations may want to deploy AntiSamy in a default configuration, but it's equally likely that a site may want to have strict, business-driven rules for what users can allow. The discussion that decides the tailoring should also consider attack surface - which grows in relative proportion to the policy file.

You may also want to enable/modify some "directives", which are basically advanced user options. This page tells you what the directives are and which versions support them.

Stage 4 - Calling the AntiSamy API

Using AntiSamy is abnormally easy. Here is an example of invoking AntiSamy with a policy file:

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 getInstance() method can take any of the following:

  • a String filename
  • a File object
  • an InputStream

Policy files can also be referenced by filename by passing a second argument to the AntiSamy:scan() method as the following examples show.:

AntiSamy as = new AntiSamy();
CleanResults cr = as.scan(dirtyInput, policyFilePath);

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));

Stage 5 - Analyzing CleanResults

The CleanResults object provides a lot of useful stuff.

getErrorMessages() - a list of String error messages

getCleanHTML() - the clean, safe HTML output

getCleanXMLDocumentFragment() - the clean, safe XMLDocumentFragment which is reflected in getCleanHTML()

getScanTime() - returns the scan time in seconds

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 [aspectsecurity.com].

Issue tracking

Visit the Google Code issue tracker.


Sponsors

The AntiSamy project is sponsored by Aspect_logo_owasp.jpg       

The initial Java project was sponsored by the OWASP Spring Of Code 2007. The .NET project was sponsored by the OWASP Summer of Code 2008.

This section details the status of the various ports of AntiSamy.

Grails

Daniel Bower created a Grails plugin for AntiSamy.

.NET

A .NET port of AntiSamy is available now at the OWASP AntiSamy .NET page. The project was funded by a Summer of Code 2008 grant and was developed by Jerry Hoff.

This port is no longer under active development, and is looking for a few good developers to help make it feature-synchronized with the .NET version. If it doesn't suit your needs, consider Microsoft's AntiXSS library.

Python

A beta Python version is currently being prototyped by a few different groups. As more information becomes available, we will post it here. If you are interested in helping, please contact the mailing list.

PHP

Although a PHP version was initially planned, we now suggest HTMLPurifier for safe rich input validation for PHP applications.


Project's Assessment

This project was assessed by Jeff Williams and his evaluation can be seen here.

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 the following 2 subcategories, out of 2 total.