Bug 39576 - SAML logout causes traceback on DC Backup in UMC
SAML logout causes traceback on DC Backup in UMC
Status: CLOSED FIXED
Product: UCS
Classification: Unclassified
Component: SAML
UCS 4.1
Other Linux
: P5 normal (vote)
: UCS 4.1
Assigned To: Florian Best
Stefan Gohmann
https://github.com/rohe/pysaml2/issue...
: interim-2
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2015-10-16 21:17 CEST by Stefan Gohmann
Modified: 2015-11-17 12:12 CET (History)
1 user (show)

See Also:
What kind of report is it?: ---
What type of bug is this?: ---
Who will be affected by this bug?: ---
How will those affected feel about the bug?: ---
User Pain:
Enterprise Customer affected?:
School Customer affected?:
ISV affected?:
Waiting Support:
Flags outvoted (downgraded) after PO Review:
Ticket number:
Bug group (optional):
Max CVSS v3 score:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Stefan Gohmann univentionstaff 2015-10-16 21:17:44 CEST
I got the following traceback will trying to logoff a SAML session on my DC Backup:

{"status": 500, "message": "The server encountered an unexpected condition which prevented it from fulfilling the request.
Traceback (most recent call last):
  File \"/usr/lib/python2.7/dist-packages/cherrypy/_cprequest.py\", line 656, in respond
    response.body = self.handler()
  File \"/usr/lib/python2.7/dist-packages/cherrypy/lib/encoding.py\", line 188, in __call__
    self.body = self.oldhandler(*args, **kwargs)
  File \"/usr/lib/python2.7/dist-packages/cherrypy/_cpdispatch.py\", line 34, in __call__
    return self.callable(*self.args, **self.kwargs)
  File \"/usr/sbin/univention-management-console-web-server\", line 86, in _decorated
    return func(*args, **kwargs)
  File \"/usr/sbin/univention-management-console-web-server\", line 1024, in slo
    self.sp.parse_logout_request_response(message, binding)
  File \"/usr/lib/python2.7/dist-packages/saml2/entity.py\", line 962, in parse_logout_request_response
    \"single_logout_service\", binding)
  File \"/usr/lib/python2.7/dist-packages/saml2/entity.py\", line 949, in _parse_response
    response = response.verify(key_file)
  File \"/usr/lib/python2.7/dist-packages/saml2/response.py\", line 400, in verify
    return self._verify()
  File \"/usr/lib/python2.7/dist-packages/saml2/response.py\", line 376, in _verify
    assert self.response.version == \"2.0\"
AttributeError: 'NoneType' object has no attribute 'version'
Comment 2 Florian Best univentionstaff 2015-10-16 22:31:09 CEST
Strange! I saw this one before and opened a upstream issue: https://github.com/rohe/pysaml2/issues/259

But the problem probably relies in our code, there is a redirection done to the wrong server I am assuming!
Comment 3 Florian Best univentionstaff 2015-10-22 15:01:16 CEST
simplesamlphp's resumelogout.php does the broken redirection.
Comment 4 Florian Best univentionstaff 2015-10-28 14:04:30 CET
The redirection is correct. SAML SLO works this way that it informs every involved service provider that the session is now logged out.
Comment 5 Florian Best univentionstaff 2015-10-29 19:42:23 CET
The reason for this was that the SLO interface only accepted <samlp:LogoutResponse> messages. But simplesamlphp sends <samlp:LogoutRequest> messages because multiple SP sessions exists.

I commited a workaround which will prevent the exception.
The problem left is that a logout will switch the host (e.g. from slave to master). I will later find out how to do the redirection back.

univention-management-console-frontend (5.0.49-1):
r64989 | Bug #39576: fix handling of <samlp:LogoutRequest> in single logout service
Comment 6 Florian Best univentionstaff 2015-10-31 14:17:10 CET
Logouts are now correctly handled with a redirection back to the IDP.

QA: Two test scenarios:
1. (make sure all cookies are removed on SP and IDP side) login via SAML + logout directly
2. login via SAML, SSO to the slave/backup/memberserver and logout from that host. After the logout you should see the login page of the UMC where you logged out
Comment 7 Stefan Gohmann univentionstaff 2015-11-04 09:23:39 CET
I got the following traceback:

The server encountered an unexpected condition which prevented it from fulfilling the request.

Traceback (most recent call last):
  File "/usr/lib/python2.7/dist-packages/cherrypy/_cprequest.py", line 656, in respond
    response.body = self.handler()
  File "/usr/lib/python2.7/dist-packages/cherrypy/lib/encoding.py", line 188, in __call__
    self.body = self.oldhandler(*args, **kwargs)
  File "/usr/lib/python2.7/dist-packages/cherrypy/_cpdispatch.py", line 34, in __call__
    return self.callable(*self.args, **self.kwargs)
  File "/usr/sbin/univention-management-console-web-server", line 1214, in logout
    data = self.sp.global_logout(user.saml.response.name_id)
  File "/usr/lib/python2.7/dist-packages/saml2/client.py", line 106, in global_logout
    entity_ids = self.users.issuers_of_info(name_id)
  File "/usr/lib/python2.7/dist-packages/saml2/population.py", line 42, in issuers_of_info
    return self.cache.entities(name_id)
  File "/usr/lib/python2.7/dist-packages/saml2/cache.py", line 142, in entities
    return self._db[cni].keys()
KeyError: '1=https%3A//master441.deadlock44.intranet/univention-management-console/saml/metadata,2=urn%3Aoasis%3Anames%3Atc%3ASAML%3A2.0%3Anameid-format%3Atransient,4=_d20734fef743f5fcaeca395507e4d4926bf13f23bd'
Comment 8 Florian Best univentionstaff 2015-11-06 15:36:24 CET
I created Bug #39815 for this. I couldn't reproduce. Regularly this doesn't happen. Let's wait if we get this reported.
Comment 9 Stefan Gohmann univentionstaff 2015-11-08 20:35:49 CET
(In reply to Florian Best from comment #8)
> I created Bug #39815 for this. I couldn't reproduce. Regularly this doesn't
> happen. Let's wait if we get this reported.

Yes.
Comment 10 Stefan Gohmann univentionstaff 2015-11-17 12:12:33 CET
UCS 4.1 has been released:
 https://docs.software-univention.de/release-notes-4.1-0-en.html
 https://docs.software-univention.de/release-notes-4.1-0-de.html

If this error occurs again, please use "Clone This Bug".