wood burning stoves
The moose likes JSP and the fly likes Session Security Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "Session Security" Watch "Session Security" New topic

Session Security

dimpsonu arora
Ranch Hand

Joined: Aug 13, 2003
Posts: 51
Hi All,
Following is my question:

A user logs into your application. Your application checks for the authentication from database.

User is a valid user. Now, Application sets the userId into session for session tracking.


When the user does some database transaction, the application fetches the userId from session and inserts user values in database against that userId. For example:

String userId =(String) session.getAttribute(userId) ;

Dummy Database Table:
UserIdItemsPurchasedItemCode ItemDescription

If the authenticated user is a hacker, is it possible for him to change the userId in session while doing the transaction so that the transaction appears in somebody else name.

If this is possible, then how difficult it is and what are the security measures???

Thanks in Advance.
Satish Chilukuri
Ranch Hand

Joined: Jun 23, 2005
Posts: 266
The userid set in session resides only in the server. The client will not have access to it. The client will have access only to the jsessionid cookie. And servers generate random values for jsessionid. So your approach looks fine. But if you are accepting the userid from the http request, then it will be a problem.
dimpsonu arora
Ranch Hand

Joined: Aug 13, 2003
Posts: 51
Thanks Santosh,

But i did not get what you mean by posting userid thourgh http request?

I am simply asking the user to login using a simple jsp page which runs on http.

Once the user logs in, my application hits databasse. If he is an authenticated user, his userid is set into the session using following code.
session.setAttribute("userId", userId);

Please explain what do you mean by posting userid thourgh http request?

Do you mean that it is a problem if I am storing userid somewhere in hidden field and then making use of it. Or userid is a part of my url like http://localhost:8080/myApp/abc.jsp?userId=abc.

Please correct, if I have not understood it correctly.
Ulf Dittmer

Joined: Mar 22, 2005
Posts: 42965
You understood it perfectly :-) Doing it that way would be a problem, but since your code doesn't do that, all is fine.
I agree. Here's the link: http://aspose.com/file-tools
subject: Session Security
It's not a secret anymore!