CVE-2024-28122: JWX vulnerable to a denial of service attack using compressed JWE message

Published Mar 8, 2024
·
Updated

Summary This vulnerability allows an attacker with a trusted public key to cause a Denial-of-Service (DoS) condition by crafting a malicious JSON Web Encryption (JWE) token with an exceptionally high compression ratio. When this token is processed by the recipient, it results in significant memory allocation and processing time during decompression.

Details

The attacker needs to obtain a valid public key to compress the payload. It needs to be valid so that the recipient can use to successfully decompress the payload. Furthermore in context JWT processing in the v2 versions, the recipient must explicitly allow JWE handling .

The attacker then crafts a message with high compression ratio, e.g. a payload with very high frequency of repeating patterns that can decompress to a much larger size. If the payload is large enough, recipient who is decompressing the data will have to allocate a large amount of memory, which then can lead to a denial of service.

The original report includes a reference to [1], but there are some very subtle differences between this library and the aforementioned issue. The most important aspect is that the referenced issue focuses on JWT processing, whereas this library is intentionally divided into parts that comprise JOSE, i.e. JWT, JWS, JWE, JWK. In particular, v2 of this library does not attempt to handle JWT payload enveloped in a JWE message automatically (v1 attempted to do this automatically, but it was never stable).

Reflecting this subtle difference, the approach taken to mitigate this vulnerability is slightly different from the referenced issue. The referenced issue limits the size of JWT when parsing, but the fixes for this library limits the maximum size of the decompressed data when decrypting JWE messages. Therefore the fix in this library is applicable regardless of the usage context, and a limit is now imposed on the size of the message that our JWE implementation can handle.

Proof of Concept

Modified from the original report to fit the vulnerability better:

go // The value below just needs to be "large enough" so that the it puts enough strain on the // recipient's environment. The value below is a safe size on my machine to run the test // without causing problems. When you increase the payload size, at some point the processing // will be slow enough to virtually freeze the program or cause a memory allocation error const payloadSize = 1 << 31

privkey, err := rsa.GenerateKey(rand.Reader, 2048) require.NoError(t, err, rsa.GenerateKey should succeed) pubkey := &privkey.PublicKey payload := strings.Repeat("x", payloadSize)

encrypted, err := jwe.Encrypt([]byte(payload), jwe.WithKey(jwa.RSAOAEP, pubkey), jwe.WithContentEncryption("A128CBC-HS256"), jwe.WithCompress(jwa.Deflate)) require.NoError(t, err, jwe.Encrypt should succeed) , err = jwe.Decrypt(encrypted, jwe.WithKey(jwa.RSAOAEP, privkey)) // Will be allocating large amounts of memory require.Error(t, err, jwe.Decrypt should fail)

References

[1] CVE-2024-21319

Other sources

JWX is Go module implementing various JWx (JWA/JWE/JWK/JWS/JWT, otherwise known as JOSE) technologies. This vulnerability allows an attacker with a trusted public key to cause a Denial-of-Service (DoS) condition by crafting a malicious JSON Web Encryption (JWE) token with an exceptionally high compression ratio. This issue has been patched in versions 1.2.29 and 2.0.21.

— NVD

Affected Software

4 affected componentsFixes available
go/github.com/lestrrat-go/jwx<1.2.29
1.2.29
go/github.com/lestrrat-go/jwx/v2<2.0.21
2.0.21
lestrrat-go jwx<1.2.29
lestrrat-go jwx>=2.0.0<2.0.21

Event History

Mar 8, 2024
Advisory Published
via GitHub·03:06 PM
Mar 9, 2024
CVE Published
via MITRE·12:45 AM
Data Sourced
via MITRE·12:45 AM
DescriptionSeverityWeakness
Data Sourced
via NVD·01:15 AM
DescriptionSeverityWeakness
Data Sourced
via NVD·01:15 AM
Affected Software

Frequently Asked Questions

1

What is the severity of CVE-2024-28122?

CVE-2024-28122 is classified as a Denial-of-Service (DoS) vulnerability.

2

How do I fix CVE-2024-28122?

To resolve CVE-2024-28122, update the JWX Go module to version 1.2.29 or 2.0.21.

3

What causes the vulnerability CVE-2024-28122?

CVE-2024-28122 is caused by a maliciously crafted JSON Web Encryption (JWE) token that exploits a trusted public key.

4

Which software is affected by CVE-2024-28122?

CVE-2024-28122 affects the JWX module versions below 1.2.29 and below 2.0.21.

5

What are the implications of CVE-2024-28122?

Exploitation of CVE-2024-28122 can lead to a DoS condition, impacting the availability of the affected service.

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