You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by Kevin Galligan <kg...@gmail.com> on 2006/12/13 19:22:33 UTC
Spoofing commandLink
I've been wondering something for a little while now. Some of the crud
style links in my app use 'h:commandLink', with 't:updateActionListener' to
set the particular element id value for that page. In days past I'd put the
id on the query string, so like ...
/app/DetailPage.do?itemId=1234
Now, obviously, you had to be careful because somebody could change the id
value manually. With JSF, using t:updateActionListener, can somebody change
the id value sent? If I'm 100% sure they couldn't, I could relax the access
checking a little.
Most of these links are in t:dataTable's, with preserveDataModel="true". If
state is kept on the server, or encrypted on client (I think you can do
that, right?), do I have to worry about the user getting access to something
they shouldn't?
Thanks in advance,
-Kevin
Re: Spoofing commandLink
Posted by delbd <de...@oma.be>.
Basic rules
1) client has always access to what is on his side
2) never trust what client is sending you. If it's an id, check it's valid.
For the component id, JSF des this check for you. For the component
values send by client (components accepting input) , you must have
validators to do this.
For the action, in jsf, it's always the client telling server what
button (using id) has been pressed. So if you fear user change the
action of a button, he can only change the id of button. If it does not
correspond to an existing id inside the jsf component tree for the form,
nothing happens.
example: client is telling 'i clicked on button
form0:carList:row25:removeButton' The fact it corresponds to
#{currentRow.removeMe} method binding is all server side. JSF just
forward the event to form0 which forward to carList (datatable) which
does iteration to row25 and forward to child component removeButton.
As someone suggested, check with a proxy what is sent by client.
Kevin Galligan a écrit :
> I've been wondering something for a little while now. Some of the
> crud style links in my app use 'h:commandLink', with
> 't:updateActionListener' to set the particular element id value for
> that page. In days past I'd put the id on the query string, so like ...
>
> /app/DetailPage.do?itemId=1234
>
> Now, obviously, you had to be careful because somebody could change
> the id value manually. With JSF, using t:updateActionListener, can
> somebody change the id value sent? If I'm 100% sure they couldn't, I
> could relax the access checking a little.
>
> Most of these links are in t:dataTable's, with
> preserveDataModel="true". If state is kept on the server, or
> encrypted on client (I think you can do that, right?), do I have to
> worry about the user getting access to something they shouldn't?
>
> Thanks in advance,
> -Kevin
Re: Spoofing commandLink
Posted by David Chandler <da...@learnjsf.com>.
Kevin,
I can't speak to Tomahawk's dataTable or updateActionListener, but
MyFaces' <h:dataTable> uses simple index values (0,1,2...) for each
row. By changing the index in the request, a hacker can access a
different row, but only from the set of rows that were in the data set
bound to the dataTable. I suspect that the Tomahawk tags behave the
same way. The safest way for you to check any such JSF behavior is to
grab a proxy tool like Paros that will let you inspect (and modify!)
the content of each request/response.
Also see http://learnjsf.com/wp/security/ for a link to a recent
ApacheCon presentation on securing JSF apps against parameter
tampering and other kinds of attacks.
As an aside, if you find that you need to put IDs in the URL (to
detect stale result sets or allow detail page bookmarks, for example),
you could use a JSF converter to hash the ID in the browser in order
to protect against parameter tampering as you've described.
/dmc
On 12/13/06, Kevin Galligan <kg...@gmail.com> wrote:
> I've been wondering something for a little while now. Some of the crud
> style links in my app use 'h:commandLink', with 't:updateActionListener' to
> set the particular element id value for that page. In days past I'd put the
> id on the query string, so like ...
>
> /app/DetailPage.do?itemId=1234
>
> Now, obviously, you had to be careful because somebody could change the id
> value manually. With JSF, using t:updateActionListener, can somebody change
> the id value sent? If I'm 100% sure they couldn't, I could relax the access
> checking a little.
>
> Most of these links are in t:dataTable's, with preserveDataModel="true". If
> state is kept on the server, or encrypted on client (I think you can do
> that, right?), do I have to worry about the user getting access to something
> they shouldn't?
>
> Thanks in advance,
> -Kevin
>
--
David Chandler
Development Coach
learnjsf.com