Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 843977 (CVE-2022-29217) - <dev-python/pyjwt-2.4.0: Key confusion through non-blocklisted public key formats
Summary: <dev-python/pyjwt-2.4.0: Key confusion through non-blocklisted public key for...
Status: RESOLVED FIXED
Alias: CVE-2022-29217
Product: Gentoo Security
Classification: Unclassified
Component: Vulnerabilities (show other bugs)
Hardware: All Linux
: Normal minor (vote)
Assignee: Gentoo Security
URL: https://github.com/jpadilla/pyjwt/sec...
Whiteboard: B4 [noglsa]
Keywords:
Depends on: 843980
Blocks:
  Show dependency tree
 
Reported: 2022-05-13 05:55 UTC by Michał Górny
Modified: 2022-10-22 17:21 UTC (History)
1 user (show)

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Michał Górny archtester Gentoo Infrastructure gentoo-dev Security 2022-05-13 05:55:32 UTC
> Disclosed by Aapo Oksman (Senior Security Specialist, Nixu Corporation).
>
>> PyJWT supports multiple different JWT signing algorithms. With JWT, an
>> attacker submitting the JWT token can choose the used signing algorithm.
>> 
>> The PyJWT library requires that the application chooses what algorithms
>> are supported. The application can specify
>> "jwt.algorithms.get_default_algorithms()" to get support for all
>> algorithms. They can also specify a single one of them (which is the
>> usual use case if calling jwt.decode directly. However, if calling
>> jwt.decode in a helper function, all algorithms might be enabled.)
>> 
>> For example, if the user chooses "none" algorithm and the JWT checker
>> supports that, there will be no signature checking. This is a common
>> security issue with some JWT implementations.
>> 
>> PyJWT combats this by requiring that the if the "none" algorithm is
>> used, the key has to be empty. As the key is given by the application
>> running the checker, attacker cannot force "none" cipher to be used.
>> 
>> Similarly with HMAC (symmetric) algorithm, PyJWT checks that the key is
>> not a public key meant for asymmetric algorithm i.e. HMAC cannot be used
>> if the key begins with "ssh-rsa". If HMAC is used with a public key, the
>> attacker can just use the publicly known public key to sign the token
>> and the checker would use the same key to verify.
>> 
>> From PyJWT 2.0.0 onwards, PyJWT supports ed25519 asymmetric algorithm.
>> With ed25519, PyJWT supports public keys that start with "ssh-", for
>> example "ssh-ed25519".
Comment 1 Michał Górny archtester Gentoo Infrastructure gentoo-dev Security 2022-05-13 10:59:35 UTC
cleanup done
Comment 2 John Helmert III archtester Gentoo Infrastructure gentoo-dev Security 2022-05-14 01:52:48 UTC
Thanks!
Comment 3 John Helmert III archtester Gentoo Infrastructure gentoo-dev Security 2022-05-28 22:22:41 UTC
CVE-2022-29217:

PyJWT is a Python implementation of RFC 7519. PyJWT supports multiple different JWT signing algorithms. With JWT, an attacker submitting the JWT token can choose the used signing algorithm. The PyJWT library requires that the application chooses what algorithms are supported. The application can specify `jwt.algorithms.get_default_algorithms()` to get support for all algorithms, or specify a single algorithm. The issue is not that big as `algorithms=jwt.algorithms.get_default_algorithms()` has to be used. Users should upgrade to v2.4.0 to receive a patch for this issue. As a workaround, always be explicit with the algorithms that are accepted and expected when decoding.
Comment 4 Michał Górny archtester Gentoo Infrastructure gentoo-dev Security 2022-10-22 15:31:03 UTC
I suppose it's a bit late to GLSA it, so just resolve?
Comment 5 John Helmert III archtester Gentoo Infrastructure gentoo-dev Security 2022-10-22 17:21:07 UTC
Sure, thanks!