# CVE-2017-16021: Regular Expression Denial Of Service in uri-js

> Attackers can cause a denial of service by supplying malicious URLs to the uri-js library, leading to excessive CPU usage and application hangs.

- **Severity:** Medium 6.5 (`CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:N/I:N/A:H`)
- **Exploited in the wild:** Not known
- **Login needed:** Any signed-in user
- **Attackable:** Over the internet
- **Victim action needed:** Not needed
- **Fix available:** Yes
- **Published:** 4 Jun 2018
- **Updated:** 17 Sep 2024
- **Also known as:** GHSA-333w-rxj3-f55r

## What is CVE-2017-16021?

CVE-2017-16021 is a medium-severity denial of service vulnerability in HackerOne uri-js node module, published on 4 Jun 2018. Any signed-in user can exploit it over the network, with no action from the victim.

### Official description

uri-js is a module that tries to fully implement RFC 3986. One of these features is validating whether or not a supplied URL is valid or not. To do this, uri-js uses a regular expression, This regular expression is vulnerable to redos. This causes the program to hang and the CPU to idle at 100% usage while uri-js is trying to validate if the supplied URL is valid or not. To check if you're vulnerable, look for a call to `require("uri-js").parse()` where a user is able to send their own input. This affects uri-js 2.1.1 and earlier.

Weakness: CWE-1333 (Inefficient Regular Expression Complexity), CWE-400 (Uncontrolled Resource Consumption)

## Which versions are affected by CVE-2017-16021?

2 open source packages ship an affected version, including uri-js. It affects 1 product.


| Package | Ecosystem | Affected | Fixed in |
| --- | --- | --- | --- |
| `uri-js` | npm | All versions | 3.0.0 |
| `uri-js` | npm | All versions | 3.0.0 |

Products: Garycourt Uri-Js.

## How do I fix CVE-2017-16021?

Upgrade uri-js to 3.0.0 or later.

## Is CVE-2017-16021 being exploited?

There is no known exploitation of CVE-2017-16021 in the wild and no public exploit code.

## Fix prompt for AI coding agents

```text
Check this codebase for CVE-2017-16021 and fix it if it is affected.

What it is: CVE-2017-16021 is a medium-severity denial of service vulnerability in HackerOne uri-js node module, published on 4 Jun 2018. Any signed-in user can exploit it over the network, with no action from the victim.
Exploitation: There is no known exploitation of CVE-2017-16021 in the wild and no public exploit code.

Affected packages and fixed versions:
- uri-js (npm): affected all versions; fixed in 3.0.0
- uri-js (npm): affected all versions; fixed in 3.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-2017-16021/ (Markdown: https://insights.sbomify.com/CVE-2017-16021/index.md)
```

## Sources

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

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