commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Andy Reek (JIRA)" <>
Subject [jira] [Commented] (LANG-871) [XSS] Possible attacks through StringEscapeUtils.escapeEcmaScript?
Date Mon, 02 Dec 2013 09:13:35 GMT


Andy Reek commented on LANG-871:

Hi Maurizio,

just take the example above: \"

In Apache Commons, the output is: \\\"
In the implementation by OWASP (ESAPI), the output is: \x5C\x22

Assume you are using the output within the javascript context of an attribute tag like onmouseover:
<select onmouseover="..." />
With the Apache implementation you will break the quoted string, but not with ESAPI.

And using the encodeForHTML method would not be correct here, because we are in a javascript
context. The result would be different.

> [XSS] Possible attacks through StringEscapeUtils.escapeEcmaScript?
> ------------------------------------------------------------------
>                 Key: LANG-871
>                 URL:
>             Project: Commons Lang
>          Issue Type: Bug
>          Components: lang.*
>    Affects Versions: 3.1
>            Reporter: Andy Reek
>              Labels: XSS
>             Fix For: Discussion
> org.apache.commons.lang3.StringEscapeUtils.escapeEcmaScript does the escape via a prefixed
'\' on all characters which must be escaped. I am not sure if this is really secure, if am
looking at the comments on
They say it is possible to do an attack by escape the escape. I tested this with the string
'\"' and the output was '\\\"'. Is this really ecma-/java-script secure? Or is it better to
use the the implementation used by OWASP?

This message was sent by Atlassian JIRA

View raw message