You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@struts.apache.org by Dale Newfield <Da...@Newfield.org> on 2008/03/06 18:37:04 UTC

Re: [struts-dev] Issue WW-2107 question - Is JSTL disable or not?

Andrea Vettori wrote:
> can someone explain why it's bad practice to do something like this in a 
> jsp page :
> 
> <sometaglib:sometag var="result"/>
> <s:hidden name="property" value="${result}”/>

Because the value of ${result} will then be evaluated as an OGNL expression.

So let's say this sometaglib:sometag tag finds the current user's 
username and sticks it in the var attribute.

If I can change my username to "%{@java.lang.System@exit()}", ${result} 
will evaluate to "%{@java.lang.System@exit(-1)}" which will then be 
evaluated as OGNL, taking down your application server.

-Dale


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
For additional commands, e-mail: dev-help@struts.apache.org


Re: [struts-dev] Issue WW-2107 question - Is JSTL disable or not?

Posted by Andrea Vettori <ma...@andreavettori.com>.
thanks I'll check it...


Il giorno 06/mar/08, alle ore 19:49, Antonio Petrelli ha scritto:

> Sorry if I come up now, but there is an effort to create a EL plugin
> for Struts 2.1.x:
> http://svn.apache.org/repos/asf/struts/sandbox/trunk/struts2-uel-plugin/
> http://svn.apache.org/repos/asf/struts/sandbox/trunk/struts2-uel-plugin-example/
>
> If you want EL support back, please contribute to this sandboxed  
> plugin.
>
> Antonio

--
Ing. Andrea Vettori
Consulente per l'Information Technology


Re: [struts-dev] Issue WW-2107 question - Is JSTL disable or not?

Posted by Felipe Rodrigues <fe...@gmail.com>.
That's what I wass looking for!!!

:-)

Felipe



Antonio Petrelli-3 wrote:
> 
> Sorry if I come up now, but there is an effort to create a EL plugin
> for Struts 2.1.x:
> http://svn.apache.org/repos/asf/struts/sandbox/trunk/struts2-uel-plugin/
> http://svn.apache.org/repos/asf/struts/sandbox/trunk/struts2-uel-plugin-example/
> 
> If you want EL support back, please contribute to this sandboxed plugin.
> 
> Antonio
> 
> 2008/3/6, Andrea Vettori <ma...@andreavettori.com>:
>>
>>  Il giorno 06/mar/08, alle ore 19:04, Dale Newfield ha scritto:
>>
>>
>>  > Andrea Vettori wrote:
>>  >> That's true but should't the app do some input checking ?
>>  >
>>  > What you're suggesting is that we make this framework vulnerable to
>>  > poorly written applications?  I'd say the framework should be
>>  > written so that even poorly written applications can't compromise it.
>>
>>
>> Ok but if protecting poorly written applications breaks good written
>>  applications at least I think the framework should be available in two
>>  version.
>>  Since I think it's about having two tlds for the struts tags, just
>>  write "EL kills" and let the users choose...
>>
>>
>>  >
>>  >
>>  >> It's the same as SQL injection...
>>  >
>>  > In fact, it's OGNL injection, and the way to avoid it is not to
>>  > evaluate user provided strings as OGNL expressions.  Turning off EL
>>  > is part of how that's been accomplished.
>>
>>
>>
>> If one has EL enabled, do you think that escaping or removing OGNL
>>  syntax in http request variables is enought (assuming that there are
>>  no other ways to inject OGNL code into the app) ?
>>
>>
>>
>>  --
>>  Ing. Andrea Vettori
>>  Consulente per l'Information Technology
>>
>>
>>  ---------------------------------------------------------------------
>>
>> To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
>>  For additional commands, e-mail: dev-help@struts.apache.org
>>
>>
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
> For additional commands, e-mail: dev-help@struts.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Issue-WW-2107-question---Is-JSTL-disable-or-not--tp15830208p15884171.html
Sent from the Struts - Dev mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
For additional commands, e-mail: dev-help@struts.apache.org


Re: [struts-dev] Issue WW-2107 question - Is JSTL disable or not?

Posted by Antonio Petrelli <an...@gmail.com>.
Sorry if I come up now, but there is an effort to create a EL plugin
for Struts 2.1.x:
http://svn.apache.org/repos/asf/struts/sandbox/trunk/struts2-uel-plugin/
http://svn.apache.org/repos/asf/struts/sandbox/trunk/struts2-uel-plugin-example/

If you want EL support back, please contribute to this sandboxed plugin.

Antonio

2008/3/6, Andrea Vettori <ma...@andreavettori.com>:
>
>  Il giorno 06/mar/08, alle ore 19:04, Dale Newfield ha scritto:
>
>
>  > Andrea Vettori wrote:
>  >> That's true but should't the app do some input checking ?
>  >
>  > What you're suggesting is that we make this framework vulnerable to
>  > poorly written applications?  I'd say the framework should be
>  > written so that even poorly written applications can't compromise it.
>
>
> Ok but if protecting poorly written applications breaks good written
>  applications at least I think the framework should be available in two
>  version.
>  Since I think it's about having two tlds for the struts tags, just
>  write "EL kills" and let the users choose...
>
>
>  >
>  >
>  >> It's the same as SQL injection...
>  >
>  > In fact, it's OGNL injection, and the way to avoid it is not to
>  > evaluate user provided strings as OGNL expressions.  Turning off EL
>  > is part of how that's been accomplished.
>
>
>
> If one has EL enabled, do you think that escaping or removing OGNL
>  syntax in http request variables is enought (assuming that there are
>  no other ways to inject OGNL code into the app) ?
>
>
>
>  --
>  Ing. Andrea Vettori
>  Consulente per l'Information Technology
>
>
>  ---------------------------------------------------------------------
>
> To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
>  For additional commands, e-mail: dev-help@struts.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
For additional commands, e-mail: dev-help@struts.apache.org


Re: [struts-dev] Issue WW-2107 question - Is JSTL disable or not?

Posted by Andrea Vettori <ma...@andreavettori.com>.
Il giorno 06/mar/08, alle ore 19:04, Dale Newfield ha scritto:

> Andrea Vettori wrote:
>> That's true but should't the app do some input checking ?
>
> What you're suggesting is that we make this framework vulnerable to  
> poorly written applications?  I'd say the framework should be  
> written so that even poorly written applications can't compromise it.

Ok but if protecting poorly written applications breaks good written  
applications at least I think the framework should be available in two  
version.
Since I think it's about having two tlds for the struts tags, just  
write "EL kills" and let the users choose...

>
>
>> It's the same as SQL injection...
>
> In fact, it's OGNL injection, and the way to avoid it is not to  
> evaluate user provided strings as OGNL expressions.  Turning off EL  
> is part of how that's been accomplished.


If one has EL enabled, do you think that escaping or removing OGNL  
syntax in http request variables is enought (assuming that there are  
no other ways to inject OGNL code into the app) ?


--
Ing. Andrea Vettori
Consulente per l'Information Technology


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
For additional commands, e-mail: dev-help@struts.apache.org


Re: [struts-dev] Issue WW-2107 question - Is JSTL disable or not?

Posted by Dale Newfield <Da...@Newfield.org>.
Andrea Vettori wrote:
> That's true but should't the app do some input checking ?

What you're suggesting is that we make this framework vulnerable to 
poorly written applications?  I'd say the framework should be written so 
that even poorly written applications can't compromise it.

> It's the same as SQL injection...

In fact, it's OGNL injection, and the way to avoid it is not to evaluate 
user provided strings as OGNL expressions.  Turning off EL is part of 
how that's been accomplished.

-Dale

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
For additional commands, e-mail: dev-help@struts.apache.org


Re: [struts-dev] Issue WW-2107 question - Is JSTL disable or not?

Posted by Andrea Vettori <ma...@andreavettori.com>.
That's true but should't the app do some input checking ?

It's the same as SQL injection...


Il giorno 06/mar/08, alle ore 18:37, Dale Newfield ha scritto:

> Andrea Vettori wrote:
>> can someone explain why it's bad practice to do something like this  
>> in a jsp page :
>> <sometaglib:sometag var="result"/>
>> <s:hidden name="property" value="${result}”/>
>
> Because the value of ${result} will then be evaluated as an OGNL  
> expression.
>
> So let's say this sometaglib:sometag tag finds the current user's  
> username and sticks it in the var attribute.
>
> If I can change my username to "%{@java.lang.System@exit()}", $ 
> {result} will evaluate to "%{@java.lang.System@exit(-1)}" which will  
> then be evaluated as OGNL, taking down your application server.
>
> -Dale
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
> For additional commands, e-mail: dev-help@struts.apache.org
>

--
Ing. Andrea Vettori
Consulente per l'Information Technology


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
For additional commands, e-mail: dev-help@struts.apache.org


Re: [struts-dev] Issue WW-2107 question - Is JSTL disable or not?

Posted by Brian Pontarelli <br...@pontarelli.com>.
Dale Newfield wrote:
> Chris Pratt wrote:
>> The proposed flow (with <rtexprvalue>false</rtexprvalue):
>
> The bit you're missing is that if you have a tag attribute with 
> rtexprvalue set to false that contains what the container thinks is an 
> EL expression (i.e., "${foo}"), the jsp compilation will fail, so it 
> will never execute and pass the string "${foo}" on to your tag.  As 
> previous posters suggested, I believe the only way to prevent this is 
> to tell the container to never evaluate these el expressions, which 
> has the previously mentioned down-sides.
Or to use the JSP delayed evaluation syntax of #{} which is part of UEL 
and JSP 2.1 (or 2.2 or whichever spec we are currently on).

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
For additional commands, e-mail: dev-help@struts.apache.org


Re: [struts-dev] Issue WW-2107 question - Is JSTL disable or not?

Posted by Dale Newfield <Da...@Newfield.org>.
Chris Pratt wrote:
> I don't know about other containers, but this works great on Resin.  I
> do it today.

Glad to learn I'm wrong!  So the plugable EL version of the struts tags 
should all be able to work with the same .tld, with rtexprvalue set to 
false everywhere, and the tag attributes that should be evaluated can be 
handed to the currently-plugged-in evaluation engine inside the tag. 
Hell, if they were all distinguishable textually (like ${} vs %{}) it 
could auto-select the appropriate el on an attribute by attribute basis, 
then *everyone* would be happy, without even needing to globally select 
one EL plugin...  (And as you've been saying, since the string would be 
evaluated by exactly one of these, we don't re-expose the previous 
security risk.)

-Dale

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
For additional commands, e-mail: dev-help@struts.apache.org


Re: [struts-dev] Issue WW-2107 question - Is JSTL disable or not?

Posted by Chris Pratt <th...@gmail.com>.
On Thu, Mar 6, 2008 at 4:59 PM, Dale Newfield <Da...@newfield.org> wrote:
> Chris Pratt wrote:
>  > The proposed flow (with <rtexprvalue>false</rtexprvalue):
>
>  The bit you're missing is that if you have a tag attribute with
>  rtexprvalue set to false that contains what the container thinks is an
>  EL expression (i.e., "${foo}"), the jsp compilation will fail, so it
>  will never execute and pass the string "${foo}" on to your tag.  As
>  previous posters suggested, I believe the only way to prevent this is to
>  tell the container to never evaluate these el expressions, which has the
>  previously mentioned down-sides.
>

I don't know about other containers, but this works great on Resin.  I
do it today.
  (*Chris*)

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
For additional commands, e-mail: dev-help@struts.apache.org


Re: [struts-dev] Issue WW-2107 question - Is JSTL disable or not?

Posted by Dale Newfield <Da...@Newfield.org>.
Chris Pratt wrote:
> The proposed flow (with <rtexprvalue>false</rtexprvalue):

The bit you're missing is that if you have a tag attribute with 
rtexprvalue set to false that contains what the container thinks is an 
EL expression (i.e., "${foo}"), the jsp compilation will fail, so it 
will never execute and pass the string "${foo}" on to your tag.  As 
previous posters suggested, I believe the only way to prevent this is to 
tell the container to never evaluate these el expressions, which has the 
previously mentioned down-sides.

-Dale

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
For additional commands, e-mail: dev-help@struts.apache.org


Re: [struts-dev] Issue WW-2107 question - Is JSTL disable or not?

Posted by Dave Newton <ne...@yahoo.com>.
--- Chris Pratt <th...@gmail.com> wrote:
> * The struts tag first parses the attribute looking for "${", if it is
> found it uses the JSP EL API to evaluate the value for the attribute.
> If it is not found, it is assumed to be OGNL and processed just like
> today.

Oh, gotcha. Re-meh.

Dave


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
For additional commands, e-mail: dev-help@struts.apache.org


Re: [struts-dev] Issue WW-2107 question - Is JSTL disable or not?

Posted by Chris Pratt <th...@gmail.com>.
On Thu, Mar 6, 2008 at 4:27 PM, Dave Newton <ne...@yahoo.com> wrote:
> --- Chris Pratt <th...@gmail.com> wrote:
>
> > today).  My proposed change would be at the point where the attribute
>  > is evaluated (I have no idea where that happens within the struts
>  > component framework).  Before processing the attribute it should first
>  > be checked to see if it contains JSTL EL tags and, if so, processed as
>  > a JSTL EL expression.  If it doesn't contain any JSTL EL expressions,
>  > it would be processed as straight OGNL (like it is today).
>
>  I thought the issue was that EL was evaluated by the container before it got
>  to the tag?
>
>  Meh; I'm lost now.
>

OK let me see if I can clarify.

The current flow (with JSTL EL enabled by adding
<rtexprvalue>true</rtexprvalue> to struts.tld):

* The container evaluates the page processing all JSTL EL references,
if one of these references results in an OGNL string that OGNL string
is what will be passed on to the tag (which is bad =8^)
* The container then executes each tag referenced on the page passing
in the values from the result of the JSTL EL evaluation (i.e. the OGNL
expression)
* The struts tag has no way of knowing whether the programmer or the
hacker entered the OGNL attribute value, so it processes the string
and potentially allows an avenue for attack

The proposed flow (with <rtexprvalue>false</rtexprvalue):

* The container executes each tag referenced on the page passing in
the attribute values entered by the programmer only, since no
evaluation has been done to this point, only the programmer has had
the opportunity to define these values. They could be ${jstlel},
%{ognlel}, or ognlel formatted values
* The struts tag first parses the attribute looking for "${", if it is
found it uses the JSP EL API to evaluate the value for the attribute.
If it is not found, it is assumed to be OGNL and processed just like
today.

The advantage is that we get back the ability to process either JSTL
EL or OGNL, but without the security concerns.  Is that clearer?
  (*Chris*)

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
For additional commands, e-mail: dev-help@struts.apache.org


Re: [struts-dev] Issue WW-2107 question - Is JSTL disable or not?

Posted by Dave Newton <ne...@yahoo.com>.
--- Chris Pratt <th...@gmail.com> wrote:
> today).  My proposed change would be at the point where the attribute
> is evaluated (I have no idea where that happens within the struts
> component framework).  Before processing the attribute it should first
> be checked to see if it contains JSTL EL tags and, if so, processed as
> a JSTL EL expression.  If it doesn't contain any JSTL EL expressions,
> it would be processed as straight OGNL (like it is today).

I thought the issue was that EL was evaluated by the container before it got
to the tag?

Meh; I'm lost now.

Dave

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
For additional commands, e-mail: dev-help@struts.apache.org


Re: [struts-dev] Issue WW-2107 question - Is JSTL disable or not?

Posted by Chris Pratt <th...@gmail.com>.
On Thu, Mar 6, 2008 at 10:25 AM, Dave Newton <ne...@yahoo.com> wrote:
> --- Chris Pratt <th...@gmail.com> wrote:
>  > Only if we allow the container to process the JSTL EL.  If we turn the
>  > container off and process the JSTL EL inside of the Struts tag
>  > library, the security hole vanishes.
>
>  So does my ability to use ${narnar} inside a JSP page, no? That's not
>  something I'm willing to give up after waiting so long for JSP 2.0 to finally
>  allow one of the most common use-cases ever.
>

Sorry, I'm not saying to turn off EL all together, only to tell the
container not to parse it for Struts tags by setting
<rtexprvalue>false</rtexprvalue> on each tag in the TLD (like it is
today).  My proposed change would be at the point where the attribute
is evaluated (I have no idea where that happens within the struts
component framework).  Before processing the attribute it should first
be checked to see if it contains JSTL EL tags and, if so, processed as
a JSTL EL expression.  If it doesn't contain any JSTL EL expressions,
it would be processed as straight OGNL (like it is today).

If someone can point me at the right part of the code where the
attribute evaluation process begins, I will take a stab at producing a
patch (and a pointer at producing a patch might be useful since I've
never done that before either).

I agree being able to use ${foobar} in the wild is great and I
wouldn't want to disable that either, only where it poses a security
risk when combined with OGNL.
  (*Chris*)

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
For additional commands, e-mail: dev-help@struts.apache.org


Re: [struts-dev] Issue WW-2107 question - Is JSTL disable or not?

Posted by Dale Newfield <Da...@Newfield.org>.
Chris Pratt wrote:
> Only if we allow the container to process the JSTL EL.  If we turn the
> container off and process the JSTL EL inside of the Struts tag
> library, the security hole vanishes.

Right--if you replace OGNL with EL in struts, the security issues that 
come from executing both go away.  Saying that doesn't make the changes 
trivial.  So if you would you like to help develop that, please read 
through the following page and post patches to the following xwork issue:

http://cwiki.apache.org/confluence/display/S2WIKI/OGNL+replacement

http://jira.opensymphony.com/browse/XW-461

-Dale

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
For additional commands, e-mail: dev-help@struts.apache.org


Re: [struts-dev] Issue WW-2107 question - Is JSTL disable or not?

Posted by Dave Newton <ne...@yahoo.com>.
--- Chris Pratt <th...@gmail.com> wrote:
> Only if we allow the container to process the JSTL EL.  If we turn the
> container off and process the JSTL EL inside of the Struts tag
> library, the security hole vanishes.

So does my ability to use ${narnar} inside a JSP page, no? That's not
something I'm willing to give up after waiting so long for JSP 2.0 to finally
allow one of the most common use-cases ever.

Dave


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
For additional commands, e-mail: dev-help@struts.apache.org


Re: [struts-dev] Issue WW-2107 question - Is JSTL disable or not?

Posted by Chris Pratt <th...@gmail.com>.
On Thu, Mar 6, 2008 at 9:37 AM, Dale Newfield <Da...@newfield.org> wrote:
> Andrea Vettori wrote:
>  > can someone explain why it's bad practice to do something like this in a
>  > jsp page :
>  >
>  > <sometaglib:sometag var="result"/>
>  > <s:hidden name="property" value="${result}"/>
>
>  Because the value of ${result} will then be evaluated as an OGNL expression.
>
>  So let's say this sometaglib:sometag tag finds the current user's
>  username and sticks it in the var attribute.
>
>  If I can change my username to "%{@java.lang.System@exit()}", ${result}
>  will evaluate to "%{@java.lang.System@exit(-1)}" which will then be
>  evaluated as OGNL, taking down your application server.
>
Only if we allow the container to process the JSTL EL.  If we turn the
container off and process the JSTL EL inside of the Struts tag
library, the security hole vanishes.
  (*Chris*)

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
For additional commands, e-mail: dev-help@struts.apache.org