Repository navigation
Reinstate working sessions in browser - #308
rsafonseca wants to merge 3 commits into
Conversation
…ent instance issue
|
@bhaisaab please take a look :) |
There was a problem hiding this comment.
I'm no UI/Javascript expert, but should these include hostname as well? If so, same goes for L351+
There was a problem hiding this comment.
Indeed Erik, thanks for pointing that out. I've updated the PR.
On Tue, May 26, 2015 at 11:46 PM, Erik Weber notifications@github.com
wrote:
In ui/scripts/cloudStack.js
#308 (comment):@@ -329,7 +325,6 @@
g_regionsecondaryenabled = null;
g_loginCmdText = null;
$.cookie('JSESSIONID', null); $.cookie('sessionkey', null);I'm no UI/Javascript expert, but should these include hostname as well? If
so, same goes for L351+—
Reply to this email directly or view it on GitHub
https://github.com/apache/cloudstack/pull/308/files#r31083230.
|
Erik Weber on dev@cloudstack.apache.org replies: We know what this commit does, but we have to guess why it was done this It references what I believe to be an internal Citrix Jira/tracking#, so if |
|
I searched around for that reference and found nothing useful, perhaps @bhaisaab can shed some light, since it was signed off by him :) |
There was a problem hiding this comment.
The original issue was related to security where session key was stored in cookie; the crux of the fix by Jessica was to use the cookie to set the sessionkey on window (g_sessionKey variable) and destroy it so it may not be read later.
|
cloudstack-pull-requests #246 SUCCESS |
|
Rajani Karuturi on dev@cloudstack.apache.org replies: CLOUDSTACK-5242 is the ACS issue id for this (accessible only to security The commit was done by Jessica for CloudPlatform and the patch was provided This was discussed on the security list. This is the last comment I see " ~ Rajani |
|
Erik Weber on dev@cloudstack.apache.org replies: |
Remove sessionkey data stored in js variable
|
Have tested with 4.5.1 -- works good ! |
|
I see that in the parent commit Jessica tried to fix security on the cookie by setting httponly=true in tomcat's context .xml Basically, all this did was break the functionality and remove 1 of the 2 places where the sessionkey was accessible through javascript. My new proposal is to actually get httponly cookie working, which thwarts most kinds of XSS attacks. The only thing i didn't fix was the same security hole being created by the SAML login (cookie with sessionkey data is created in browser), since i didn't have it setup to test. These changes shouldn't break it though, it will just keep the same insecure behaviour. Have a look at my proposed changes :) |
|
As this changes behaviour which was aiming to fix a security problem, I've referred it to the security mailing list. |
|
cloudstack-pull-requests #257 SUCCESS |
|
Hi @rsafonseca thanks for the update and patch. It's a good idea to use HTTPOnly flag on cookie to ensure we have the authentication going on and at the same time not expose the cookie value to javascript. But the current patch will break SAML and any redirected authentication which relies on cookies being read by JS and then destroyed. As an alternative, let's discuss how we can improve this:
Please review the above ideas and comment/share on them. TLDR? To fix the login/UI issue, I think we need to not depend on passing a sessionkey as API argument but instead use HTTPOnly (and enable secure flag, so cookies are passed on HTTPs if enabled) "sessionkey" cookie along with the JSESSIONID cookie. Doing this would make sure we can run ACS UI across tabs and let the UI work when a external auth system such as those based on SAML, 2-factor or OAuth can work. |
|
Hi Rohit, thank you for your view on this :)
Regarding the non-bulleted stuff: Secure cookie: Not depend on sessionkey as API argument: About SAML and redirect based auth not working: Thanks for reviewing. |
|
Hi @rsafonseca, thanks for replying.
I guess we have some agreement here, please go ahead and make the changes. I'm working on making the SAML plugin production grade, so I can help test all aspects of logging/authentication around it as well. Cheers. |
|
Hi @bhaisaab |
|
Hi @bhaisaab Any news on testing it? If i misunderstood the problem you stated, can you explain further or help fix as you suggested? |
|
@rsafonseca yeah, can you fix the cookie usage? Sorry due to dayjob projects I'm not getting time to review PRs and test them actively. I'm planning to test and merge this next week along with some of the SAML improvements I'm doing, since merging that work may conflict (or maybe not) with the auth subsystem. Meanwhile, if possible please see other ways of improving it - for example, since you're not habituated like rest of us -- you can better see the auth subsystem, security and UI from your fresh eyes and perhaps think of how we can improve it. For example, why do we have JSESSIONID when we actually rely on sessionkey, those kinds of things. |
|
This merges cleanly, should we wait on extra fixes? or have them done in separate PRs? |
|
I have recently implemented SSL proxy in front of CS. This way seems to be more practical than deploying certificates directly into Tomcat. After such modification session persistence does not work anymore. So basically I see no point of this change anymore. May be we need to find better solution if possible? |
|
Session persistence is not working on any scenario atm. The aim of this is to fix that. The security measure is aimed to prevent browser vulnerability, which using SSL doesn't prevent. Why do you say this is not needed any more? |
|
I have applied you patch manually and it worked for HTTP. I have expected that if I put HTTPS proxy in front of it - it will continue to work. But at HTTPS session if I do "F5" to refresh page -- I am logged off. So from the end-user perspective there is no (visual) difference. I would like to understand what problem are we going to solve? It seems for me it is not clearly defined. Or may be I understood it in a wrong way. I have expected that F5 does not brake session. |
|
@vadimkim In the past, with the purpose of preventing a browser vulnerability, session persistence was completely broken, so currently, there is no session persistence with either HTTP or HTTPS from ACS 4.3.x to 4.6.x, that is, if you press F5, you will be logged out. This fix reenables persistence, and does so while improving on the security measure that was the objective that led to session persistence being broken. With this patch, both HTTP and HTTPS are working fine with session persistence, and the browser vulnerability (XSS attack) is eliminated. SSL would not protect against a XSS attack, it would only protect from the fact that you are sending your credentials and sessionkey unencrypted from your machine to the server. If you are doing so over a secure network that you trust, using SSL might even be irrelevant, depending on the situation. So, SSL will only protect your credentials/session on the transport layer, other nasty XSS scripts might still gain access to whatever is stored in your browser. Setting the cookie as HttpOnly prevents your own browser from reading it, and thus makes that information safe from XSS. If you're having issues with a reverse proxy in front of it, the issue is probably with the reverse proxy or browser config... here's where i see it might be going wrong on your setup:
Could you share some more info on your reverse proxy setup? I'll can try to reproduce your issue and give you a hand :) |
|
@rsafonseca
I am using very simple nginx conf. Pure proxy: x.x.x.x -- backend server where Cloudstack runs |
|
@vadimkim Try setting: Since your internal domain may not be the same as the external, you might also need some additional config like: I will try to reproduce your setup when i have some time to figure out a config that works for sure, but try these configs in the mean while :) Either way, this seems like an issue with the proxy config itself, and there should be no need to adjust code for that situation ;) |
|
About the redirect rule, i will soon bake a patch that will render that unnecessary, but for now, there should be no problem with just rewriting it in the proxy :) |
|
@rsafonseca |
|
@vadimkim |
|
@rsafonseca |
|
@vadimkim |
|
@rsafonseca |
|
@vadimkim are you building the latest version of this PR? I've removed the initial host_ prefix on the cookies, since that was not the issue that led to breaking the sessions. |
|
@rsafonseca |
- Login is based on sessionkey HttpOnly Cookie - ApiServlet does login verification using sessionKey from both the request cookies and the API parameters. In both cases, if either or both are passed they should match the sessionKey stored in the current session of the HttpRequest - UI: it no longer needs to read or set sessionkey cookie - UI: it no longer needs to return g_sessionKey value in the API requests, though to support a sso mechanism g_sessionKey is still passed in the API is not null - Secure jsessionid cookie is set to be HttpOnly and Secure - SAML login should also set HttpOnly cookie before redirecting to UI - SAML: listIdps & getSPMetadata APIs are readonly now, won't log out a logged in user Performed tests (login, saml login if applicable, page refreshes, opening multiple tabs, logout) with following combinations: - SAML disabled, normal auth as admin, domain-admin and user - SAML enabled, normal auth as admin, domain-admin and user; and saml sso as admin, domain-admin and user Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com> This closes #574 This closes #308
- Login is based on sessionkey HttpOnly Cookie - ApiServlet does login verification using sessionKey from both the request cookies and the API parameters. In both cases, if either or both are passed they should match the sessionKey stored in the current session of the HttpRequest - UI: it no longer needs to read or set sessionkey cookie - UI: it no longer needs to return g_sessionKey value in the API requests, though to support a sso mechanism g_sessionKey is still passed in the API is not null - Secure jsessionid cookie is set to be HttpOnly and Secure - SAML login should also set HttpOnly cookie before redirecting to UI - SAML: listIdps & getSPMetadata APIs are readonly now, won't log out a logged in user Performed tests (login, saml login if applicable, page refreshes, opening multiple tabs, logout) with following combinations: - SAML disabled, normal auth as admin, domain-admin and user - SAML enabled, normal auth as admin, domain-admin and user; and saml sso as admin, domain-admin and user Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com> This closes #574 This closes #308 (cherry picked from commit 12edad3) Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com> Conflicts: server/src/com/cloud/api/ApiServlet.java utils/src/com/cloud/utils/HttpUtils.java
- Login is based on sessionkey HttpOnly Cookie - ApiServlet does login verification using sessionKey from both the request cookies and the API parameters. In both cases, if either or both are passed they should match the sessionKey stored in the current session of the HttpRequest - UI: it no longer needs to read or set sessionkey cookie - UI: it no longer needs to return g_sessionKey value in the API requests, though to support a sso mechanism g_sessionKey is still passed in the API is not null - Secure jsessionid cookie is set to be HttpOnly and Secure - SAML login should also set HttpOnly cookie before redirecting to UI - SAML: listIdps & getSPMetadata APIs are readonly now, won't log out a logged in user Performed tests (login, saml login if applicable, page refreshes, opening multiple tabs, logout) with following combinations: - SAML disabled, normal auth as admin, domain-admin and user - SAML enabled, normal auth as admin, domain-admin and user; and saml sso as admin, domain-admin and user Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com> This closes apache#574 This closes apache#308 (cherry picked from commit 12edad3) Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com> Conflicts: server/src/com/cloud/api/ApiServlet.java utils/src/com/cloud/utils/HttpUtils.java
- Login is based on sessionkey HttpOnly Cookie - ApiServlet does login verification using sessionKey from both the request cookies and the API parameters. In both cases, if either or both are passed they should match the sessionKey stored in the current session of the HttpRequest - UI: it no longer needs to read or set sessionkey cookie - UI: it no longer needs to return g_sessionKey value in the API requests, though to support a sso mechanism g_sessionKey is still passed in the API is not null - Secure jsessionid cookie is set to be HttpOnly and Secure - SAML login should also set HttpOnly cookie before redirecting to UI - SAML: listIdps & getSPMetadata APIs are readonly now, won't log out a logged in user Performed tests (login, saml login if applicable, page refreshes, opening multiple tabs, logout) with following combinations: - SAML disabled, normal auth as admin, domain-admin and user - SAML enabled, normal auth as admin, domain-admin and user; and saml sso as admin, domain-admin and user Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com> This closes apache#574 This closes apache#308
Fixes #308 Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>
I've seen that session persistence stopped working due to 19e3c01
From what I could gather from the comments, this was done to fix issue where separate instances of management servers could exist within the same domain.
I've fixed the above mentioned issue by prepending the location's hostname, in order to allow both sessions to co-exist without clashing.
This also removes the need for this fix 6c71d3b