aspose file tools*
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
Author

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.

session.setAttribute("userId",userId);

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.
http://localhost:8080/myApp/login

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
Marshal

Joined: Mar 22, 2005
Posts: 39549
    
  27
You understood it perfectly :-) Doing it that way would be a problem, but since your code doesn't do that, all is fine.


Ping & DNS - updated with new look and Ping home screen widget
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Session Security
 
Similar Threads
What should we do about Login?
getting session from hibernate session factory
User who is logged in simultaneously from different browser ... how to forcely logout the first user
Session handling during logoff
Using other Authentication Providers