Reputation: 3196
When a user hits login page of a Portal
(it could be Liferay
, Jboss Portal
..), JSESSIONID cookie
is created by the container
. After entering credentials in the login page, same JSESSIONID
gets carried over.
Here, end user will come to know the JSESSIONID
before he could get authenticated (by checking the JSESSIONID
in the login page). This will increase vulnerability of the site for hacking because one can know the JSESSIONID
before one gets authenticated.
This post advices to have a different JSESSIONID
after authentication.
So, creating a new JSESSIOND can be achieved by Portal
server being used (am using Liferay CE 6.0
) or it has to be handled by web application developer? If it has to be handled by web application developer what is the best way to do? request.getSession(true)
is the only option?? If I need to instruct Liferay
to create a new JSESSIONID
after authentication how it can be done?
Upvotes: 1
Views: 11220
Reputation: 1
Put this code inside the portal-ext.properties
.
It will fix the problem, each and every time logged in, new session id will be generated.
session.enable.phishing.protection=true
com.liferay.util.servlet.SessionParameters=true
Upvotes: 0
Reputation: 3196
@Thiago:
This session.enable.phishing.protection=true
is by default true in portal.properties
. Anyhow, I have added this entry in portal-ext.properties
. But, even then JSESSIONID
remains same before and after login.
I have implemented a filter
as per this link. After implementing this filter, when I hit login page of Liferay, one JSESSIONID
gets created. After I enter the credentials and login, the same JSESSIONID
is retained.
I have implemented this filter
in a Servlet
and not in any of my Portlets
or in Liferay's ROOT application. My Servlet
is deployed in LR + Jboss AS bundle. Am first hitting the Servlet
and from here I have a link which will redirect to Liferay's login page. I have implemented this filter
in my Servlet
because Container will append JSESSIONID
for first time request as it doesn't know if cookies are enabled or not. Since, JSESSIONID
is getting appended, am not able to retrieve my images in Servlet
(because url is myImage.jpg;jsessionid=). Hence, I have implemented this filter
.
Is this filter
conflicting with Liferay's configuration? Even after setting session.enable.phishing.protection=true
same JSESSIONID
is retained means what else could be the problem?
Upvotes: 0
Reputation: 830
You can fix this issue by setting the following property to true like Liferay has as default.
#
# Set this to true to invalidate the session when a user logs into the
# portal. This helps prevents phishing. Set this to false if you need the
# guest user and the authenticated user to have the same session.
#
# Set this to false if the property "company.security.auth.requires.https"
# is set to true and you want to maintain the same credentials across HTTP
# and HTTPS sessions.
#
session.enable.phishing.protection=true
Upvotes: 1
Reputation: 1046
The problem here is not that the user knows the session ID (the user always knows it, it is sent by his browser). The attack scenario is that the user, while logged out, clicks on the link that already has JSESSIONID embedded, then authenticates and this session becomes a logged-in session. Now someone who initially created the link can use the same session to act as the user. More details at https://en.wikipedia.org/wiki/Session_fixation
So yes, use the web or app server to re-set session ID after a user authenticates. You do not need to write it yourself. For Tomcat 7: http://www.tomcatexpert.com/blog/2011/04/25/session-fixation-protection
Upvotes: 1
Reputation: 408
This looks a lot like the session fixation problem I solved for Liferay 5.2.5 a long time ago. The solution consists of creating a custom Tomcat Valve that will force a new session ID. So the solution isn't really specific for Liferay and is dependent on if you use Tomcat or not.
I suspect it shouldn't be too difficult to adapt my old solution to a newer Liferay/Tomcat combination. You can find the necessary information about my solution in my old and currently unmaintained blog (if I only had more time...): Fixing session fixation in Liferay
Upvotes: 1