<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
		<id>https://wiki.owasp.org/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Kunklejr</id>
		<title>OWASP - User contributions [en]</title>
		<link rel="self" type="application/atom+xml" href="https://wiki.owasp.org/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Kunklejr"/>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php/Special:Contributions/Kunklejr"/>
		<updated>2026-05-02T16:30:29Z</updated>
		<subtitle>User contributions</subtitle>
		<generator>MediaWiki 1.27.2</generator>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=J2EE_Bad_Practices:_JSP_Expressions&amp;diff=16704</id>
		<title>J2EE Bad Practices: JSP Expressions</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=J2EE_Bad_Practices:_JSP_Expressions&amp;diff=16704"/>
				<updated>2007-02-24T19:54:22Z</updated>
		
		<summary type="html">&lt;p&gt;Kunklejr: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Overview==&lt;br /&gt;
JSP 2.0 introduced a new capability allowing one to use JSP Expressions directly within the template text (i.e. outside of tag libraries or tag files) of a web page. However, improper use of the expressions will leave an application open to [[XSS Attacks]].&lt;br /&gt;
&lt;br /&gt;
==Consequences ==&lt;br /&gt;
* Failing to use JSP Expressions properly will leave an application open to [[XSS Attacks]].&lt;br /&gt;
&lt;br /&gt;
==Exposure period ==&lt;br /&gt;
This vulnerability has existed since servlet containers and application servers began implementing the [[http://jcp.org/en/jsr/detail?id=152| JSP 2.0 standard]]&lt;br /&gt;
&lt;br /&gt;
==Platform ==&lt;br /&gt;
* Languages: Java/JSP&lt;br /&gt;
&lt;br /&gt;
==Required resources ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Severity ==&lt;br /&gt;
High&lt;br /&gt;
&lt;br /&gt;
==Likelihood of exploit ==&lt;br /&gt;
If a developer uses JSP Expressions to write unsanitized, user-entered data to a page, the likelihood of exploit is very high.&lt;br /&gt;
&lt;br /&gt;
==Discussion ==&lt;br /&gt;
JSP 2.0 expressions allow developers to expose data and objects stored in application, session, request, or page scope using an Ant-style syntax. It allows you to replace this&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;table&amp;gt;&lt;br /&gt;
    &amp;lt;c:forEach var=&amp;quot;book&amp;quot; items=&amp;quot;${books}&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;tr&amp;gt;&lt;br /&gt;
            &amp;lt;td&amp;gt;&amp;lt;c:out value=&amp;quot;${book.title}&amp;quot;/&amp;gt;&amp;lt;/td&amp;gt;&lt;br /&gt;
            &amp;lt;td&amp;gt;&amp;lt;c:out value=&amp;quot;${book.author}&amp;quot;/&amp;gt;&amp;lt;/td&amp;gt;&lt;br /&gt;
            &amp;lt;td&amp;gt;&amp;lt;c:out value=&amp;quot;${book.isbn}&amp;quot;/&amp;gt;&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;/tr&amp;gt; &lt;br /&gt;
    &amp;lt;/c:forEach&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
with this&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;table&amp;gt;&lt;br /&gt;
    &amp;lt;c:forEach var=&amp;quot;book&amp;quot; items=&amp;quot;${books}&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;tr&amp;gt;&lt;br /&gt;
            &amp;lt;td&amp;gt;${book.title}&amp;lt;/td&amp;gt;&lt;br /&gt;
            &amp;lt;td&amp;gt;${book.author}&amp;lt;/td&amp;gt;&lt;br /&gt;
            &amp;lt;td&amp;gt;${book.isbn}&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;/c:forEach&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As you can see, the syntax in the second example is more succinct. However, it may also expose a Cross Site Scripting [[XSS Attacks| XSS]] vulnerability. The problem that few tutorials (including [http://java.sun.com/javaee/5/docs/tutorial/doc| Sun's Java EE 5 Tutorial]) mention is that the expression syntax does not escape HTML characters. Therefore, any web application using JSP Expressions to output unsanitized, user-entered data will be vulnerable to Cross Site Scripting (XSS) attacks.&lt;br /&gt;
&lt;br /&gt;
==Avoidance and mitigation ==&lt;br /&gt;
The safest cure for this XSS vulnerability leads one right back to the first example. As section 2.2.2 of the JSP 2.0 Specification reads, “In cases where escaping is desired (for example, to help prevent cross-site scripting attacks), the JSTL core tag c:out can be used.”&lt;br /&gt;
&lt;br /&gt;
To be sure your code is not vulnerable to the potential XSS vulnerability described herein, use JSP Expressions only as tag library attribute values and stick to using JSTL‘s c:out tag for writing text to a page. Deciding which instances of template text expression usage are safe and which are not is error prone and the consequences of a mistake are grave.&lt;br /&gt;
&lt;br /&gt;
==Examples ==&lt;br /&gt;
See [[#Discussion]] above.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Related problems ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{{Template:Vulnerability}}&lt;br /&gt;
{{Template:Stub}}&lt;br /&gt;
[[Category:Vulnerability]]&lt;br /&gt;
[[Category:Implementation]]&lt;br /&gt;
[[Category:Java]]&lt;br /&gt;
[[Category:Use of Dangerous API]]&lt;/div&gt;</summary>
		<author><name>Kunklejr</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=J2EE_Bad_Practices:_JSP_Expressions&amp;diff=16703</id>
		<title>J2EE Bad Practices: JSP Expressions</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=J2EE_Bad_Practices:_JSP_Expressions&amp;diff=16703"/>
				<updated>2007-02-24T19:49:11Z</updated>
		
		<summary type="html">&lt;p&gt;Kunklejr: New page: ==Overview== JSP 2.0 introduced a new capability allowing one to use JSP Expressions directly within the template text (i.e. outside of tag libraries or tag files) of a web page. However, ...&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Overview==&lt;br /&gt;
JSP 2.0 introduced a new capability allowing one to use JSP Expressions directly within the template text (i.e. outside of tag libraries or tag files) of a web page. However, improper use of the expressions will leave an application open to [[XSS Attacks]].&lt;br /&gt;
&lt;br /&gt;
==Consequences ==&lt;br /&gt;
* Failing to use JSP Expressions properly will leave an application open to [[XSS Attacks]].&lt;br /&gt;
&lt;br /&gt;
==Exposure period ==&lt;br /&gt;
This vulnerability has existed since servlet containers and application servers began implementing the [[http://jcp.org/en/jsr/detail?id=152| JSP 2.0 standard]]&lt;br /&gt;
&lt;br /&gt;
==Platform ==&lt;br /&gt;
* Languages: Java/JSP&lt;br /&gt;
&lt;br /&gt;
==Required resources ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Severity ==&lt;br /&gt;
High&lt;br /&gt;
&lt;br /&gt;
==Likelihood of exploit ==&lt;br /&gt;
If a developer uses JSP Expressions to write unsanitized, user-entered data to a page, the likelihood of exploit is very high.&lt;br /&gt;
&lt;br /&gt;
==Discussion ==&lt;br /&gt;
JSP 2.0 expressions allow developers to expose data and objects stored in application, session, request, or page scope using an Ant-style syntax. It allows you to replace this&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;table&amp;gt;&lt;br /&gt;
    &amp;lt;c:forEach var=&amp;quot;book&amp;quot; items=&amp;quot;${books}&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;tr&amp;gt;&lt;br /&gt;
            &amp;lt;td&amp;gt;&amp;lt;c:out value=&amp;quot;${book.title}&amp;quot;/&amp;gt;&amp;lt;/td&amp;gt;&lt;br /&gt;
            &amp;lt;td&amp;gt;&amp;lt;c:out value=&amp;quot;${book.author}&amp;quot;/&amp;gt;&amp;lt;/td&amp;gt;&lt;br /&gt;
            &amp;lt;td&amp;gt;&amp;lt;c:out value=&amp;quot;${book.isbn}&amp;quot;/&amp;gt;&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;/tr&amp;gt; &lt;br /&gt;
    &amp;lt;/c:forEach&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
with this&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;table&amp;gt;&lt;br /&gt;
    &amp;lt;c:forEach var=&amp;quot;book&amp;quot; items=&amp;quot;${books}&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;tr&amp;gt;&lt;br /&gt;
            &amp;lt;td&amp;gt;${book.title}&amp;lt;/td&amp;gt;&lt;br /&gt;
            &amp;lt;td&amp;gt;${book.author}&amp;lt;/td&amp;gt;&lt;br /&gt;
            &amp;lt;td&amp;gt;${book.isbn}&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;/c:forEach&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As you can see, the syntax in the second example is more succinct. However, it may also expose a Cross Site Scripting [[XSS Attacks| XSS]] vulnerability. The problem that few tutorials (including [http://java.sun.com/javaee/5/docs/tutorial/doc| Sun's Java EE 5 Tutorial]) mention is that the expression syntax does not escape HTML characters. Therefore, any web application using JSP Expressions to output unsanitized, user-entered data will be vulnerable to Cross Site Scripting (XSS) attacks.&lt;br /&gt;
&lt;br /&gt;
==Avoidance and mitigation ==&lt;br /&gt;
The safest cure for this XSS vulnerability leads one right back to the first example. As section 2.2.2 of the JSP 2.0 Specification reads, “In cases where escaping is desired (for example, to help prevent cross-site scripting attacks), the JSTL core tag c:out can be used.”&lt;br /&gt;
&lt;br /&gt;
To be sure your code is not vulnerable to the potential XSS vulnerability described herein, use JSP Expressions only as tag library attribute values and stick to using JSTL‘s c:out tag for writing text to a page. Deciding which instances of template text expression usage are safe and which are not is error prone and the consequences of a mistake is dangerous.&lt;br /&gt;
&lt;br /&gt;
==Examples ==&lt;br /&gt;
See [[#Discussion]] above.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Related problems ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{{Template:Vulnerability}}&lt;br /&gt;
{{Template:Stub}}&lt;br /&gt;
[[Category:Vulnerability]]&lt;br /&gt;
[[Category:Implementation]]&lt;br /&gt;
[[Category:Java]]&lt;br /&gt;
[[Category:Use of Dangerous API]]&lt;/div&gt;</summary>
		<author><name>Kunklejr</name></author>	</entry>

	</feed>