Skip to content

Commit 26e85ce

Browse files
committed
Added a catch for malformed apikey input.
- Legacy-Id: 17769
1 parent 02804ba commit 26e85ce

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

ietf/person/models.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -351,7 +351,10 @@ class PersonalApiKey(models.Model):
351351
def validate_key(cls, s):
352352
import struct, hashlib, base64
353353
assert isinstance(s, bytes)
354-
key = base64.urlsafe_b64decode(s)
354+
try:
355+
key = base64.urlsafe_b64decode(s)
356+
except Exception:
357+
return None
355358
id, salt, hash = struct.unpack(KEY_STRUCT, key)
356359
k = cls.objects.filter(id=id)
357360
if not k.exists():

0 commit comments

Comments
 (0)