Critical severity9.8NVD Advisory· Published Jan 23, 2017· Updated May 13, 2026
CVE-2016-7036
CVE-2016-7036
Description
python-jose before 1.3.2 allows attackers to have unspecified impact by leveraging failure to use a constant time comparison for HMAC keys.
Affected packages
Versions sourced from the GitHub Security Advisory.
| Package | Affected versions | Patched versions |
|---|---|---|
python-josePyPI | < 1.3.2 | 1.3.2 |
Affected products
1- cpe:2.3:a:python-jose_project:python-jose:*:*:*:*:*:*:*:*Range: <=1.3.1
Patches
173007d6887a7Merge pull request #35 from mpdavis/hmac-timing
2 files changed · +27 −1
jose/jwk.py+2 −1 modified@@ -19,6 +19,7 @@ from jose.constants import ALGORITHMS from jose.exceptions import JWKError from jose.utils import base64url_decode +from jose.utils import constant_time_string_compare # PyCryptodome's RSA module doesn't have PyCrypto's _RSAobj class # Instead it has a class named RsaKey, which serves the same purpose. @@ -159,7 +160,7 @@ def sign(self, msg): return hmac.new(self.prepared_key, msg, self.hash_alg).digest() def verify(self, msg, sig): - return sig == self.sign(msg) + return constant_time_string_compare(sig, self.sign(msg)) class RSAKey(Key):
jose/utils.py+25 −0 modified@@ -1,5 +1,6 @@ import base64 +import hmac def calculate_at_hash(access_token, hash_alg): @@ -58,3 +59,27 @@ def timedelta_total_seconds(delta): delta (timedelta): A timedelta to convert to seconds. """ return delta.days * 24 * 60 * 60 + delta.seconds + + +def constant_time_string_compare(a, b): + """Helper for comparing string in constant time, independent + of the python version being used. + + Args: + a (str): A string to compare + b (str): A string to compare + """ + + try: + return hmac.compare_digest(a, b) + except AttributeError: + + if len(a) != len(b): + return False + + result = 0 + + for x, y in zip(a, b): + result |= ord(x) ^ ord(y) + + return result == 0
Vulnerability mechanics
Generated by null/stub on May 9, 2026. Inputs: CWE entries + fix-commit diffs from this CVE's patches. Citations validated against bundle.
References
8- github.com/mpdavis/python-jose/pull/35/commits/89b46353b9f611e9da38de3d2fedf52331167b93nvdIssue TrackingPatchThird Party AdvisoryWEB
- github.com/mpdavis/python-jose/releases/tag/1.3.2nvdIssue TrackingPatchThird Party AdvisoryWEB
- github.com/advisories/GHSA-w799-prg3-cx77ghsaADVISORY
- nvd.nist.gov/vuln/detail/CVE-2016-7036ghsaADVISORY
- github.com/mpdavis/python-jose/commit/73007d6887a7517ac07c6e755e494baee49ef513ghsaWEB
- github.com/pypa/advisory-database/tree/main/vulns/python-jose/PYSEC-2017-28.yamlghsaWEB
- web.archive.org/web/20210123221523/http://www.securityfocus.com/bid/95845ghsaWEB
- www.securityfocus.com/bid/95845nvd
News mentions
0No linked articles in our index yet.