CVE-2021-22880: Activerecord Denial of Service Vulnerability

HIGH
Advisory Identifier: GHSA-8hc4-xxm3-5ppp
CVSS 7.5
CWE-400
Published
Advisory Summary

CVE-2021-22880 is a HIGH (CVSS 7.5) denial of service vulnerability (CWE-400: Uncontrolled Resource Consumption) affecting Activerecord libraries in the RubyGems ecosystem. The issue involves active record subject to regular expression denial-of-service (redos). Remediation is available by upgrading affected packages to version 5.2.4.5, 6.0.3.5, 6.1.2.1.

CVE-2021-22880 at a Glance

CVE Identifier CVE-2021-22880
GHSA Identifier GHSA-8hc4-xxm3-5ppp
Severity HIGH
CVSS v3.1 Base Score 7.5
CWE Classification CWE-400: Uncontrolled Resource Consumption
Affected Product Activerecord
Package Ecosystem RubyGems
Published Date
Last Updated

Security Impact

CVSS: 7.5

The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H).

Attack Vector Network (AV:N)
Attack Complexity Low (AC:L)
Privileges Required None (PR:N)
User Interaction None (UI:N)
Scope Unchanged (S:U)
Confidentiality None (C:N)
Integrity None (I:N)
Availability High (A:H)

How to Fix CVE-2021-22880

To remediate this vulnerability, upgrade all affected Activerecord dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.

activerecord fixed: 5.2.4.5
Upgrade activerecord to 5.2.4.5
activerecord fixed: 6.0.3.5
Upgrade activerecord to 6.0.3.5
activerecord fixed: 6.1.2.1
Upgrade activerecord to 6.1.2.1
Verify Direct and Transitive Dependencies

Run the following command in your project directory to verify that all resolved dependencies use the patched release:

inspect dependencies for activerecord

How to Check if You Are Affected

To determine whether your application is affected by CVE-2021-22880, inspect your project dependencies for Activerecord:

inspect dependencies for activerecord

Analyze the terminal output to locate any version of Activerecord in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 5.2.4.5), your application is affected.

Note: Verify declared build manifests and deployed runtime container environments.

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-400: Uncontrolled Resource Consumption, where the product does not properly control the allocation and maintenance of a limited resource. In Activerecord, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.

Source Advisory Statement

The PostgreSQL adapter in Active Record before 6.1.2.1, 6.0.3.5, 5.2.4.5 suffers from a regular expression denial of service (REDoS) vulnerability. Carefully crafted input can cause the input validation in the `money` type of the PostgreSQL adapter in Active Record to spend too much time in a regular expression, resulting in the potential for a DoS attack. This only impacts Rails applications that are using PostgreSQL along with money type columns that take user input.

CVE-2021-22880 Affected Activerecord Versions

3 component(s)
Fixed Versions:
5.2.4.56.0.3.56.1.2.1
Product / Package Ecosystem Affected Versions Fixed Version
activerecord
RubyGems
≥ 5.0.0
< 5.2.4.5
5.2.4.5
activerecord
RubyGems
≥ 6.0.0
< 6.0.3.5
6.0.3.5
activerecord
RubyGems
≥ 6.1.0
< 6.1.2.1
6.1.2.1

References

Frequently Asked Questions

What is CVE-2021-22880?
CVE-2021-22880 is a security vulnerability in Activerecord involving Active Record subject to Regular Expression Denial-of-Service (ReDoS) under CWE-400: Uncontrolled Resource Consumption.
Which Activerecord versions are affected?
Affected versions include releases prior to 5.2.4.5, 6.0.3.5, 6.1.2.1 across affected packages: activerecord.
What version fixes CVE-2021-22880?
Upgrading to 5.2.4.5, 6.0.3.5, 6.1.2.1 (or the latest patched release for your respective branch) resolves the vulnerability.
Is activerecord affected?
Yes, activerecord is affected in releases prior to 5.2.4.5, 6.0.3.5, 6.1.2.1. Upgrade your dependency to 5.2.4.5, 6.0.3.5, 6.1.2.1 or later.
What is the CVSS score of CVE-2021-22880?
CVE-2021-22880 has a CVSS v3.1 base score of 7.5 (HIGH) with vector string CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H.
What CWE is associated with CVE-2021-22880?
CVE-2021-22880 is classified under CWE-400: Uncontrolled Resource Consumption (The product does not properly control the allocation and maintenance of a limited resource.).
How can I check RubyGems dependencies for CVE-2021-22880?
Run the dependency tree command: 'inspect dependencies for activerecord'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "schema_version" : "1.4.0",
  "id" : "GHSA-8hc4-xxm3-5ppp",
  "modified" : "2023-07-03T22:08:31Z",
  "published" : "2021-03-02T03:44:14Z",
  "aliases" : [ "CVE-2021-22880" ],
  "summary" : "Active Record subject to Regular Expression Denial-of-Service (ReDoS)",
  "details" : "The PostgreSQL adapter in Active Record before 6.1.2.1, 6.0.3.5, 5.2.4.5 suffers from a regular expression denial of service (REDoS) vulnerability. Carefully crafted input can cause the input validation in the `money` type of the PostgreSQL adapter in Active Record to spend too much time in a regular expression, resulting in the potential for a DoS attack. This only impacts Rails applications that are using PostgreSQL along with money type columns that take user input.",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "RubyGems",
      "name" : "activerecord"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "5.0.0"
      }, {
        "fixed" : "5.2.4.5"
      } ]
    } ],
    "database_specific" : {
      "last_known_affected_version_range" : "<= 5.2.4.4"
    }
  }, {
    "package" : {
      "ecosystem" : "RubyGems",
      "name" : "activerecord"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "6.0.0"
      }, {
        "fixed" : "6.0.3.5"
      } ]
    } ],
    "database_specific" : {
      "last_known_affected_version_range" : "<= 6.0.3.4"
    }
  }, {
    "package" : {
      "ecosystem" : "RubyGems",
      "name" : "activerecord"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "6.1.0"
      }, {
        "fixed" : "6.1.2.1"
      } ]
    } ],
    "database_specific" : {
      "last_known_affected_version_range" : "<= 6.1.2.0"
    }
  } ],
  "references" : [ {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2021-22880"
  }, {
    "type" : "WEB",
    "url" : "https://hackerone.com/reports/1023899"
  }, {
    "type" : "WEB",
    "url" : "https://discuss.rubyonrails.org/t/cve-2021-22880-possible-dos-vulnerability-in-active-record-postgresql-adapter/77129"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/rails/rails"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/rubysec/ruby-advisory-db/blob/master/gems/activerecord/CVE-2021-22880.yml"
  }, {
    "type" : "WEB",
    "url" : "https://groups.google.com/g/rubyonrails-security/c/ZzUqCh9vyhI"
  }, {
    "type" : "WEB",
    "url" : "https://lists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/message/MO5OJ3F4ZL3UXVLJO6ECANRVZBNRS2IH"
  }, {
    "type" : "WEB",
    "url" : "https://lists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/message/XQ3NS4IBYE2I3MVMGAHFZBZBIZGHXHT3"
  }, {
    "type" : "WEB",
    "url" : "https://security.netapp.com/advisory/ntap-20210805-0009"
  }, {
    "type" : "WEB",
    "url" : "https://www.debian.org/security/2021/dsa-4929"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-400" ],
    "severity" : "HIGH",
    "github_reviewed" : true,
    "github_reviewed_at" : "2021-03-02T03:40:01Z",
    "nvd_published_at" : "2021-02-11T18:15:00Z"
  }
}