Skip to content
This repository was archived by the owner on Jan 8, 2020. It is now read-only.
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions src/idpproxy/state.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,8 +161,17 @@ def parse_cookie(self, value):
parts = value.split("|")
if len(parts) != 3:
return None
# verify the cookie signature
if self.cookie_signature(parts[0], parts[1]) != parts[2]:
# Verify the cookie signature in a constant time manner to prevent
# attackers from guessing the correct signature value (code snippet
# borrowed from http://rdist.root.org/2009/05/28/ \
# timing-attack-in-google-keyczar-library/ ).
correctMac = self.cookie_signature(parts[0], parts[1])
if len(correctMac) != len(parts[2]):
raise Exception("Invalid cookie signature %r", value)
result = 0
for x, y in zip(correctMac, parts[2]):
result |= ord(x) ^ ord(y)
if result:
raise Exception("Invalid cookie signature %r", value)

try:
Expand Down Expand Up @@ -266,4 +275,4 @@ def info(self):
return None

def authn_service(self):
return self._cache.get(self.group, self.session_id)["service"]
return self._cache.get(self.group, self.session_id)["service"]