# CVE-2022-25883: semver vulnerable to Regular Expression Denial of Service

> An attacker can cause a denial of service by providing untrusted data to the semver library's range function, triggering excessive CPU consumption.

- **Severity:** Medium 5.3 (`CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:L/E:P`)
- **Exploited in the wild:** Not known
- **Login needed:** Not needed
- **Attackable:** Over the internet
- **Victim action needed:** Not needed
- **Fix available:** Yes
- **Published:** 21 Jun 2023
- **Updated:** 6 Dec 2024
- **Also known as:** AZL-27207, AZL-27208, AZL-43534, AZL-43717, AZL-44694, AZL-45168, CLSA-2026-1772496674, CLSA-2026-1773015263, CLSA-2026-1773015264, CLSA-2026-1775089629, CLSA-2026-1775089654, CLSA-2026-1776386161, CLSA-2026-1779065204, CLSA-2026-1779238050, CLSA-2026-1784509771, CLSA-2026-1784769500, CLSA-2026-1792473179, CLSA-2026-1792473264, DEBIAN-CVE-2022-25883, GHSA-c2qf-rxjj-qqgw, MINI-7h79-62v2-3j6x, MINI-8v88-r933-jw5h, ROOT-APP-NPM-CVE-2022-25883, UBUNTU-CVE-2022-25883, openSUSE-SU-2024:14012-1

## What is CVE-2022-25883?

CVE-2022-25883 is a medium-severity denial of service vulnerability in semver, published on 21 Jun 2023. An attacker can exploit it over the internet without logging in, with no action from the victim.

### Official description

Versions of the package semver before 7.5.2 are vulnerable to Regular Expression Denial of Service (ReDoS) via the function new Range, when untrusted user data is provided as a range.

Weakness: CWE-1333 (Inefficient Regular Expression Complexity)

## Which versions are affected by CVE-2022-25883?

6 open source packages ship an affected version, including semver. It affects 1 product.


| Package | Ecosystem | Affected | Fixed in |
| --- | --- | --- | --- |
| `semver` | npm | From 2.0.0-alpha | 5.7.2 |
| `semver` | npm | From 2.0.0-alpha | 5.7.2 |
| `semver` | npm | From 6.0.0 | 6.3.1 |
| `semver` | npm | From 6.0.0 | 6.3.1 |
| `semver` | npm | From 7.0.0 | 7.5.2 |
| `semver` | npm | From 7.0.0 | 7.5.2 |
| `velociraptor` | openSUSE:Tumbleweed | All versions | 0.7.0.4.git74.3426c0a-9.1 |

Products: Npmjs Semver.

## How do I fix CVE-2022-25883?

Upgrade semver to a fixed version for your release line: 5.7.2, 6.3.1 or 7.5.2.

## Is CVE-2022-25883 being exploited?

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

## Fix prompt for AI coding agents

```text
Check this codebase for CVE-2022-25883 and fix it if it is affected.

What it is: CVE-2022-25883 is a medium-severity denial of service vulnerability in semver, published on 21 Jun 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-2022-25883 exists.

Affected packages and fixed versions:
- semver (npm): affected from 2.0.0-alpha; fixed in 5.7.2
- semver (npm): affected from 2.0.0-alpha; fixed in 5.7.2
- semver (npm): affected from 6.0.0; fixed in 6.3.1
- semver (npm): affected from 6.0.0; fixed in 6.3.1
- semver (npm): affected from 7.0.0; fixed in 7.5.2
- semver (npm): affected from 7.0.0; fixed in 7.5.2

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

## Sources

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

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