# CVE-2021-32740: Regular Expression Denial of Service in Addressable templates

> Attackers can cause denial of service in the Addressable Ruby library by providing maliciously crafted URI templates that trigger excessive resource consumption.

- **Severity:** High 7.5 (`CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H`)
- **Exploited in the wild:** Not known
- **Login needed:** Not needed
- **Attackable:** Over the internet
- **Victim action needed:** Not needed
- **Fix available:** Yes
- **Published:** 6 Jul 2021
- **Updated:** 3 Aug 2024
- **Also known as:** DEBIAN-CVE-2021-32740, GHSA-jxhc-q857-3j6g, MGASA-2021-0417, OESA-2021-1278, SUSE-SU-2021:2927-1, SUSE-SU-2021:2928-1, UBUNTU-CVE-2021-32740, openSUSE-SU-2024:11592-1, openSUSE-SU-2024:12247-1, openSUSE-SU-2024:13157-1

## What is CVE-2021-32740?

CVE-2021-32740 is a high-severity denial of service vulnerability in Fedoraproject Fedora, published on 6 Jul 2021. An attacker can exploit it over the internet without logging in, with no action from the victim.

### Official description

Addressable is an alternative implementation to the URI implementation that is part of Ruby's standard library. An uncontrolled resource consumption vulnerability exists after version 2.3.0 through version 2.7.0. Within the URI template implementation in Addressable, a maliciously crafted template may result in uncontrolled resource consumption, leading to denial of service when matched against a URI. In typical usage, templates would not normally be read from untrusted user input, but nonetheless, no previous security advisory for Addressable has cautioned against doing this. Users of the parsing capabilities in Addressable but not the URI template capabilities are unaffected. The vulnerability is patched in version 2.8.0. As a workaround, only create Template objects from trusted sources that have been validated not to produce catastrophic backtracking.

Weakness: CWE-400 (Uncontrolled Resource Consumption)

## Which versions are affected by CVE-2021-32740?

2 open source packages ship an affected version, including addressable. It affects 2 products.


| Package | Ecosystem | Affected | Fixed in |
| --- | --- | --- | --- |
| `addressable` | RubyGems | From 2.3.0 | 2.8.0 |
| `addressable` | RubyGems | From 2.3.0 | 2.8.0 |
| `rubygem-addressable` | SUSE:OpenStack Cloud Crowbar 8 | All versions | 2.3.6-3.3.3 |
| `rubygem-addressable` | SUSE:OpenStack Cloud Crowbar 9 | All versions | 2.3.6-4.3.3 |
| `ruby3.2-rubygem-http` | openSUSE:Tumbleweed | All versions | 5.1.0-1.4 |
| `rubygem-http` | openSUSE:Tumbleweed | All versions | 5.1.0-1.1 |

Products: Addressable Project Addressable, Fedoraproject Fedora.

## How do I fix CVE-2021-32740?

Upgrade addressable to 2.8.0 or later.

## Is CVE-2021-32740 being exploited?

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

## Other vulnerabilities in Fedoraproject Fedora

- [CVE-2026-35611](https://insights.sbomify.com/CVE-2026-35611/): Addressable has a Regular Expression Denial of Service in Addressable templates (high 7.5)

## Fix prompt for AI coding agents

```text
Check this codebase for CVE-2021-32740 and fix it if it is affected.

What it is: CVE-2021-32740 is a high-severity denial of service vulnerability in Fedoraproject Fedora, published on 6 Jul 2021. An attacker can exploit it over the internet without logging in, with no action from the victim.
Exploitation: There is no known exploitation of CVE-2021-32740 in the wild and no public exploit code.

Affected packages and fixed versions:
- addressable (RubyGems): affected from 2.3.0; fixed in 2.8.0
- addressable (RubyGems): affected from 2.3.0; fixed in 2.8.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-2021-32740/ (Markdown: https://insights.sbomify.com/CVE-2021-32740/index.md)
```

## Sources

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

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