Skip to content

Commit f3276d8

Browse files
committed
Merge pull request jpadilla#66 from wbolster/issue-65
Verify that decoded header and payload are json objects
2 parents a8fc518 + 3def634 commit f3276d8

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

jwt/__init__.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -340,6 +340,8 @@ def load(jwt):
340340
header = json.loads(header_data.decode('utf-8'))
341341
except ValueError as e:
342342
raise DecodeError('Invalid header string: %s' % e)
343+
if not isinstance(header, Mapping):
344+
raise DecodeError('Invalid header string: must be a json object')
343345

344346
try:
345347
payload_data = base64url_decode(payload_segment)
@@ -349,6 +351,8 @@ def load(jwt):
349351
payload = json.loads(payload_data.decode('utf-8'))
350352
except ValueError as e:
351353
raise DecodeError('Invalid payload string: %s' % e)
354+
if not isinstance(payload, Mapping):
355+
raise DecodeError('Invalid payload string: must be a json object')
352356

353357
try:
354358
signature = base64url_decode(crypto_segment)

0 commit comments

Comments
 (0)