# CVE-2023-48238: JWT Algorithm Confusion in json-web-token library

> Attackers can bypass JWT signature verification by exploiting algorithm confusion, allowing unauthorized access to applications using this library.

- **Severity:** High 7.5 (`CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:H/A:N`)
- **Exploited in the wild:** Not known
- **Login needed:** Not needed
- **Attackable:** Over the internet
- **Victim action needed:** Not needed
- **Fix available:** Yes
- **Published:** 17 Nov 2023
- **Updated:** 8 Jun 2026
- **Also known as:** GHSA-4xw9-cx39-r355

## What is CVE-2023-48238?

CVE-2023-48238 is a high-severity vulnerability in joaquimserafim json-web-token, published on 17 Nov 2023. An attacker can exploit it over the internet without logging in, with no action from the victim.

### Official description

joaquimserafim/json-web-token is a javascript library use to interact with JSON Web Tokens (JWT) which are a compact URL-safe means of representing claims to be transferred between two parties. Versions prior to 4.0.0 are vulnerable to a JWT algorithm confusion attack. On line 86 of the 'index.js' file, the algorithm to use for verifying the signature of the JWT token is taken from the JWT token, which at that point is still unverified and thus shouldn't be trusted. To exploit this vulnerability, an attacker needs to craft a malicious JWT token containing the HS256 algorithm, signed with the public RSA key of the victim application. This attack will only work against this library is the RS256 algorithm is in use, however it is a best practice to use that algorithm. Version 4.0.0 fixes the issue.

Weakness: CWE-345 (Insufficient Verification of Data Authenticity)

## Which versions are affected by CVE-2023-48238?

2 open source packages ship an affected version, including json-web-token. It affects 1 product.


| Package | Ecosystem | Affected | Fixed in |
| --- | --- | --- | --- |
| `json-web-token` | npm | All versions | 4.0.0 |
| `json-web-token` | npm | All versions | 4.0.0 |

Products: Joaquimserafim Json Web Token.

## How do I fix CVE-2023-48238?

Upgrade json-web-token to 4.0.0 or later.

## Is CVE-2023-48238 being exploited?

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

## Fix prompt for AI coding agents

```text
Check this codebase for CVE-2023-48238 and fix it if it is affected.

What it is: CVE-2023-48238 is a high-severity vulnerability in joaquimserafim json-web-token, published on 17 Nov 2023. An attacker can exploit it over the internet without logging in, with no action from the victim.
Exploitation: It is not confirmed as exploited in the wild, but public exploit code for CVE-2023-48238 exists.

Affected packages and fixed versions:
- json-web-token (npm): affected all versions; fixed in 4.0.0
- json-web-token (npm): affected all versions; fixed in 4.0.0

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-2023-48238/ (Markdown: https://insights.sbomify.com/CVE-2023-48238/index.md)
```

## Sources

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

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