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 "OWASP Java Encoder Project"

From OWASP
Jump to: navigation, search
m (Add link to JavaDoc)
(OWASP Java Encoder Project)
 
(10 intermediate revisions by the same user not shown)
Line 6: Line 6:
 
==OWASP Java Encoder Project ==
 
==OWASP Java Encoder Project ==
  
The OWASP Java Encoder is a Java 1.5+ simple-to-use drop-in high-performance encoder class with no dependencies and little baggage. This project will help Java web developers defend against Cross Site Scripting!
+
The OWASP Java Encoder is a Java 1.5+ simple-to-use drop-in high-performance encoder class with no dependencies and little baggage. This project will help Java web developers defend against Cross Site Scripting!  
  
Cross-Site Scripting (XSS) attacks are a type of injection, in which malicious scripts (primarily JavaScript) are injected into otherwise trusted web sites. You can read more about Cross Site Scripting here: [[Cross-site_Scripting_%28XSS%29]]. One of the primary defenses to stop Cross Site Scripting is a technique called <i>Contextual Output Encoding</i>. You can read more about Cross Site Scripting prevention here: [[XSS_(Cross_Site_Scripting)_Prevention_Cheat_Sheet]].
+
Cross-Site Scripting (XSS) attacks are a type of injection, in which malicious scripts (primarily JavaScript) are injected into otherwise trusted web sites. You can read more about Cross Site Scripting here: [[Cross-site_Scripting_%28XSS%29]]. One of the primary defenses to stop Cross Site Scripting is a technique called <i>Contextual Output Encoding</i>. <b>WARNING</b>: Please note that XSS prevention requires other defensive strategies besides encoding! For more information, please read about Cross Site Scripting prevention here: [[XSS_(Cross_Site_Scripting)_Prevention_Cheat_Sheet]].
  
As of February 2017 there are no issues submitted against this project! [https://github.com/OWASP/owasp-java-encoder/issues https://github.com/OWASP/owasp-java-encoder/issues]. We actively track project issues and seek to remediate any issues that arise. The project owners feel this project is stable and ready for production use and are seeking project status promotion.
+
As of September 16, 2018 there are no security issues submitted against this project! [https://github.com/OWASP/owasp-java-encoder/issues https://github.com/OWASP/owasp-java-encoder/issues]. We actively track project issues and seek to remediate any issues that arise. The project owners feel this project is stable and ready for production use and are seeking project status promotion.
  
 
==Introduction==
 
==Introduction==
Line 18: Line 18:
 
==Quick Overview==
 
==Quick Overview==
  
The OWASP Java Encoder library is intended for quick contextual encoding with very little overhead, either in performance or usage. To get started, simply add the encoder-1.2.1.jar, import org.owasp.encoder.Encode and start encoding.
+
The OWASP Java Encoder library is intended for quick contextual encoding with very little overhead, either in performance or usage. To get started, simply add the encoder-1.2.2.jar, import org.owasp.encoder.Encode and start encoding.
  
Please look at the [http://search.maven.org/remotecontent?filepath=org/owasp/encoder/encoder/1.2.1/encoder-1.2.1-javadoc.jar javadoc for Encode] to see the variety of contexts for which you can encode. Tag libraries and JSP EL functions can be found in the encoder-jsp-1.2.1.jar.
+
Please look at the [http://search.maven.org/remotecontent?filepath=org/owasp/encoder/encoder/1.2.2/encoder-1.2.2-javadoc.jar javadoc for Encode] to see the variety of contexts for which you can encode. Tag libraries and JSP EL functions can be found in the encoder-jsp-1.2.2.jar.
  
 
Happy Encoding!
 
Happy Encoding!
Line 66: Line 66:
 
== Quick Download ==
 
== Quick Download ==
  
* [https://search.maven.org/remotecontent?filepath=org/owasp/encoder/encoder/1.2.1/encoder-1.2.1.jar encoder-1.2.1.jar]
+
* [https://search.maven.org/remotecontent?filepath=org/owasp/encoder/encoder/1.2.2/encoder-1.2.2.jar encoder-1.2.2.jar]
* [https://search.maven.org/remotecontent?filepath=org/owasp/encoder/encoder-jsp/1.2.1/encoder-jsp-1.2.1.jar encoder-jsp-1.2.1.jar]
+
* [https://search.maven.org/remotecontent?filepath=org/owasp/encoder/encoder-jsp/1.2.2/encoder-jsp-1.2.2.jar encoder-jsp-1.2.2.jar]
  
 
== News and Events ==
 
== News and Events ==
 +
* [14 September 2018] 1.2.2 Released!
 
* [19 February 2017] 1.2.1 Released!
 
* [19 February 2017] 1.2.1 Released!
 
* [11 June 2016] No reported issues and library use is strong!
 
* [11 June 2016] No reported issues and library use is strong!
Line 200: Line 201:
 
= Deploy the Java Encoder Project =
 
= Deploy the Java Encoder Project =
  
The OWASP Java Encoder version 1.2.1 is now available in central!
+
The OWASP Java Encoder version 1.2.2 is now available in central!
  
 
[http://search.maven.org/#search%7Cga%7C1%7Cg%3A%22org.owasp.encoder%22 OWASP Encoder at Maven Central].
 
[http://search.maven.org/#search%7Cga%7C1%7Cg%3A%22org.owasp.encoder%22 OWASP Encoder at Maven Central].
  
 
== Core ==
 
== Core ==
Direct Download: [http://search.maven.org/remotecontent?filepath=org/owasp/encoder/encoder/1.2.1/encoder-1.2.1.jar encoder-1.2.1.jar]
+
Direct Download: [http://search.maven.org/remotecontent?filepath=org/owasp/encoder/encoder/1.2.2/encoder-1.2.2.jar encoder-1.2.2.jar]
 
=== Maven ===
 
=== Maven ===
 
  <dependency>
 
  <dependency>
 
     <groupId>org.owasp.encoder</groupId>
 
     <groupId>org.owasp.encoder</groupId>
 
     <artifactId>encoder</artifactId>
 
     <artifactId>encoder</artifactId>
     <version>1.2.1</version>
+
     <version>1.2.2</version>
 
  </dependency>
 
  </dependency>
  
 
== JSP Tag Library ==
 
== JSP Tag Library ==
Direct Download: [https://search.maven.org/remotecontent?filepath=org/owasp/encoder/encoder-jsp/1.2.1/encoder-jsp-1.2.1.jar encoder-jsp-1.2.1.jar]
+
Direct Download: [https://search.maven.org/remotecontent?filepath=org/owasp/encoder/encoder-jsp/1.2.2/encoder-jsp-1.2.2.jar encoder-jsp-1.2.2.jar]
 
=== Maven ===
 
=== Maven ===
 
  <dependency>
 
  <dependency>
 
     <groupId>org.owasp.encoder</groupId>
 
     <groupId>org.owasp.encoder</groupId>
 
     <artifactId>encoder-jsp</artifactId>
 
     <artifactId>encoder-jsp</artifactId>
     <version>1.2.1</version>
+
     <version>1.2.2</version>
 
  </dependency>
 
  </dependency>
  
Line 289: Line 290:
  
 
The OWASP Java Encoder Library at its core is intended to be a XSS safe _encoding_ library.  The grave accent is a legitimate and frequently used character, that cannot be encoded to avoid this bug in unpatched versions of IE.  With enough user feedback, we may update the library to include one of the following options: (1) alternate, drop-in build that filters grave accents, with unchanged API, (2) new filtering methods.
 
The OWASP Java Encoder Library at its core is intended to be a XSS safe _encoding_ library.  The grave accent is a legitimate and frequently used character, that cannot be encoded to avoid this bug in unpatched versions of IE.  With enough user feedback, we may update the library to include one of the following options: (1) alternate, drop-in build that filters grave accents, with unchanged API, (2) new filtering methods.
 +
 +
= Encoding and Template Literals =
 +
 +
Several users of the Java Encoder have asked how to properly use the OWASP Java Encoder in combination with template literals.
 +
 +
The best way to encode template literal variables is to first escape the untrusted data in a JavaScript variable and then place that variable in the template literal.
 +
 +
var user = &quot;&lt;%= Encode.forJavaScript(user) %&gt;&quot;;
 +
`Hello ${user}, here is your total: ${total}`
 +
 +
Another method is to properly escape the variable in-line.
 +
 +
`Hello ${&quot;&lt;%= Encode.forJavaScript(user) $&gt;&quot;}, here is your total ${total}`
  
 
= Roadmap =
 
= Roadmap =

Latest revision as of 14:29, 16 September 2018

Incubator big.jpg

OWASP Java Encoder Project

The OWASP Java Encoder is a Java 1.5+ simple-to-use drop-in high-performance encoder class with no dependencies and little baggage. This project will help Java web developers defend against Cross Site Scripting!

Cross-Site Scripting (XSS) attacks are a type of injection, in which malicious scripts (primarily JavaScript) are injected into otherwise trusted web sites. You can read more about Cross Site Scripting here: Cross-site_Scripting_(XSS). One of the primary defenses to stop Cross Site Scripting is a technique called Contextual Output Encoding. WARNING: Please note that XSS prevention requires other defensive strategies besides encoding! For more information, please read about Cross Site Scripting prevention here: XSS_(Cross_Site_Scripting)_Prevention_Cheat_Sheet.

As of September 16, 2018 there are no security issues submitted against this project! https://github.com/OWASP/owasp-java-encoder/issues. We actively track project issues and seek to remediate any issues that arise. The project owners feel this project is stable and ready for production use and are seeking project status promotion.

Introduction

Contextual Output Encoding is a computer programming technique necessary to stop Cross Site Scripting. This project is a Java 1.5+ simple-to-use drop-in high-performance encoder class with no dependencies and little baggage. It provides numerous encoding functions to help defend against XSS in a variety of different HTML, JavaScript, XML and CSS contexts.

Quick Overview

The OWASP Java Encoder library is intended for quick contextual encoding with very little overhead, either in performance or usage. To get started, simply add the encoder-1.2.2.jar, import org.owasp.encoder.Encode and start encoding.

Please look at the javadoc for Encode to see the variety of contexts for which you can encode. Tag libraries and JSP EL functions can be found in the encoder-jsp-1.2.2.jar.

Happy Encoding!

Licensing

The OWASP Java Encoder is free to use under the New BSD License.


What is this?

The OWASP Java Encoder provides:

  • Output Encoding functions to help stop XSS
  • Java 1.5+ standalone library

Important Links

Java Encoder at GitHub
Issue Tracker

Mailing List

Java Encoder Mailing List

Project Leaders

Author: Jeff Ichnowski @
Jim Manico @
Jeremy Long @

Related Projects


Quick Download

News and Events

  • [14 September 2018] 1.2.2 Released!
  • [19 February 2017] 1.2.1 Released!
  • [11 June 2016] No reported issues and library use is strong!
  • [1 May 2015] Moved to GitHub
  • [12 Apr 2015] 1.2 Released!
  • [10 Apr 2015] GitHub move
  • [1 Feb 2015] Removed ThreadLocal
  • [20 Mar 2014] Doc additions
  • [5 Feb 2014] New Wiki
  • [4 Feb 2014] 1.1.1 Released

In Print

We will be releasing a user guide soon!

Classifications

Owasp-incubator-trans-85.png Owasp-builders-small.png
Owasp-defenders-small.png
New BSD License
Project Type Files CODE.jpg