# CVE-2024-21664: Parsing JSON serialized payload without protected field can lead to segfault

> A nil pointer dereference in the jwx Go library allows attackers to crash systems performing JWS verification via crafted JSON payloads.

- **Severity:** Medium 4.3 (`CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:N/I:N/A:L`)
- **Exploited in the wild:** Not known
- **Login needed:** Not needed
- **Attackable:** Over the internet
- **Victim action needed:** A user has to click or open something
- **Fix available:** Yes
- **Published:** 9 Jan 2024
- **Updated:** 17 Jun 2025
- **Also known as:** GHSA-pvcr-v8j8-j5q3, GO-2024-2454, MINI-3w4v-wc8m-6vpm, MINI-6c6p-2vff-7rvf, MINI-7fmq-v75f-gqm3, MINI-cgwv-cgmv-rfwv, MINI-f323-cwp2-26r8, MINI-h59q-7gcq-jwm6, MINI-hmx4-qf7r-vj78, MINI-j2m9-rjw9-j534, MINI-m5g4-r467-qqhr, MINI-q4h3-q26q-7489, MINI-q839-2mv9-jm37, MINI-qcrc-36qj-77hv

## What is CVE-2024-21664?

CVE-2024-21664 is a medium-severity vulnerability in lestrrat-go jwx, published on 9 Jan 2024. An attacker can exploit it over the internet without logging in, and only if a user opens a file or follows a link.

### Official description

jwx is a Go module implementing various JWx (JWA/JWE/JWK/JWS/JWT, otherwise known as JOSE) technologies. Calling `jws.Parse` with a JSON serialized payload where the `signature` field is present while `protected` is absent can lead to a nil pointer dereference. The vulnerability can be used to crash/DOS a system doing JWS verification. This vulnerability has been patched in versions 2.0.19 and 1.2.28.

Weakness: CWE-476 (NULL Pointer Dereference)

## Which versions are affected by CVE-2024-21664?

6 open source packages ship an affected version, including github.com/lestrrat-go/jwx and github.com/lestrrat-go/jwx/v2. It affects 1 product.


| Package | Ecosystem | Affected | Fixed in |
| --- | --- | --- | --- |
| `github.com/lestrrat-go/jwx` | Go | From 1.0.8 | 1.2.28 |
| `github.com/lestrrat-go/jwx` | Go | From 1.0.8 | 1.2.28 |
| `github.com/lestrrat-go/jwx` | Go | From 1.0.8 | 1.2.28 |
| `github.com/lestrrat-go/jwx/v2` | Go | All versions | 2.0.19 |
| `github.com/lestrrat-go/jwx/v2` | Go | All versions | 2.0.19 |
| `github.com/lestrrat-go/jwx/v2` | Go | All versions | 2.0.19 |

Products: Lestrrat-Go Jwx.

## How do I fix CVE-2024-21664?

Upgrade github.com/lestrrat-go/jwx to 1.2.28 or later.

## Is CVE-2024-21664 being exploited?

It is not confirmed as exploited in the wild, but public exploit code for CVE-2024-21664 exists.

## Other vulnerabilities in lestrrat-go jwx

- [CVE-2024-28122](https://insights.sbomify.com/CVE-2024-28122/): JWX vulnerable to a denial of service attack using compressed JWE message (medium 6.8)
- [CVE-2023-49290](https://insights.sbomify.com/CVE-2023-49290/): Malicious parameters can cause a denial of service in lestrrat-go/jwx (medium 5.3)

## Fix prompt for AI coding agents

```text
Check this codebase for CVE-2024-21664 and fix it if it is affected.

What it is: CVE-2024-21664 is a medium-severity vulnerability in lestrrat-go jwx, published on 9 Jan 2024. An attacker can exploit it over the internet without logging in, and only if a user opens a file or follows a link.
Exploitation: It is not confirmed as exploited in the wild, but public exploit code for CVE-2024-21664 exists.

Affected packages and fixed versions:
- github.com/lestrrat-go/jwx (Go): affected from 1.0.8; fixed in 1.2.28
- github.com/lestrrat-go/jwx (Go): affected from 1.0.8; fixed in 1.2.28
- github.com/lestrrat-go/jwx (Go): affected from 1.0.8; fixed in 1.2.28
- github.com/lestrrat-go/jwx/v2 (Go): affected all versions; fixed in 2.0.19
- github.com/lestrrat-go/jwx/v2 (Go): affected all versions; fixed in 2.0.19
- github.com/lestrrat-go/jwx/v2 (Go): affected all versions; fixed in 2.0.19

Task:
1. Search the dependency manifests and lockfiles (for example package.json, package-lock.json, requirements.txt, poetry.lock, uv.lock, pom.xml, build.gradle, go.mod, Cargo.lock, Gemfile.lock) and any Dockerfiles for the affected packages, including transitive dependencies.
2. If an affected version is in use, upgrade it to the fixed version for its release line with the project's package manager, so the lockfile is regenerated. Prefer the smallest upgrade that fixes it.
3. If there is no fix, or the upgrade would break the build, do not guess: explain the risk and the safest workaround instead.
4. Run the tests and summarise what changed and why.
5. If nothing in the project is affected, say so and change nothing.

Reference: https://insights.sbomify.com/CVE-2024-21664/ (Markdown: https://insights.sbomify.com/CVE-2024-21664/index.md)
```

## Sources

- CVE record: https://www.cve.org/CVERecord?id=CVE-2024-21664
- NVD: https://nvd.nist.gov/vuln/detail/CVE-2024-21664
- OSV: https://osv.dev/vulnerability/CVE-2024-21664

---
From sbomify Insights: https://insights.sbomify.com/CVE-2024-21664/
Summaries are generated and may contain mistakes; the official description above is the record.
