CVE-2021-21304: Dynamoose Prototype Pollution Vulnerability

HIGH
Advisory Identifier: GHSA-rrqm-p222-8ph2
CVSS 7.2
CWE-1321 CWE-915
Published
Advisory Summary

CVE-2021-21304 is a HIGH (CVSS 7.2) prototype pollution vulnerability (CWE-1321: Improperly Controlled Modification of Object Prototype Attributes ('Prototype Pollution')) affecting Dynamoose libraries in the npm ecosystem. The issue involves prototype pollution in dynamoose. Remediation is available by upgrading affected packages to version 2.7.0.

CVE-2021-21304 at a Glance

CVE Identifier CVE-2021-21304
GHSA Identifier GHSA-rrqm-p222-8ph2
Severity HIGH
CVSS v3.1 Base Score 7.2
CWE Classification CWE-1321: Improperly Controlled Modification of Object Prototype Attributes ('Prototype Pollution')
Affected Product Dynamoose
Package Ecosystem npm
Published Date
Last Updated

Security Impact

CVSS: 7.2

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:C/C:L/I:L/A:N).

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

How to Fix CVE-2021-21304

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

dynamoose fixed: 2.7.0
npm install dynamoose@2.7.0
Verify Direct and Transitive Dependencies

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

npm ls dynamoose

How to Check if You Are Affected

To determine whether your Node.js application is affected by CVE-2021-21304, inspect your project dependencies using npm:

npm ls dynamoose

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

Note: The npm ls dynamoose command inspects dependencies declared in your package.json and lockfile; it does not perform automated runtime dynamic scanning.

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-1321: Improperly Controlled Modification of Object Prototype Attributes ('Prototype Pollution'), where the product receives input from an upstream component that specifies attributes that are to be initialized or updated in an object, but it does not properly control modifications of attributes of the object prototype. In Dynamoose, 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

### Impact In Dynamoose versions 2.0.0-2.6.0 there was a prototype pollution vulnerability in the internal utility method [`lib/utils/object/set.ts`](https://github.com/dynamoose/dynamoose/blob/master/lib/utils/object/set.ts). This method is used throughout the codebase for various operations throughout Dynamoose. We have not seen any evidence of this vulnerability being exploited. We do not believe this issue impacts v1.x.x since this method was added as part of the v2 rewrite. This vulnerability also impacts v2.x.x beta/alpha versions. ### Patches v2.7.0 includes a patch for this vulnerability. ### Workarounds We are unaware of any workarounds to patch this vulnerability other than upgrading to v2.7.0 or greater. ### References - Patch commit hash: 324c62b4709204955931a187362f8999805b1d8e ### For more information If you have any questions or comments about this advisory: * [Contact me](https://charlie.fish/contact) * [Read our Security Policy](https://github.com/dynamoose/dynamoose/blob/master/SECURITY.md) ### Credit - GitHub CodeQL Code Scanning

CVE-2021-21304 Affected Dynamoose Versions

1 component(s)
Fixed Versions:
2.7.0
Product / Package Ecosystem Affected Versions Fixed Version
dynamoose
npm
≥ 2.0.0
< 2.7.0
2.7.0

References

Frequently Asked Questions

What is CVE-2021-21304?
CVE-2021-21304 is a security vulnerability in Dynamoose involving Prototype Pollution in Dynamoose under CWE-1321: Improperly Controlled Modification of Object Prototype Attributes ('Prototype Pollution').
Which Dynamoose versions are affected?
Affected versions include releases prior to 2.7.0 across affected packages: dynamoose.
What version fixes CVE-2021-21304?
Upgrading to 2.7.0 (or the latest patched release for your respective branch) resolves the vulnerability.
Is dynamoose affected?
Yes, dynamoose is affected in releases prior to 2.7.0. Upgrade your dependency to 2.7.0 or later.
What is the CVSS score of CVE-2021-21304?
CVE-2021-21304 has a CVSS v3.1 base score of 7.2 (HIGH) with vector string CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:C/C:L/I:L/A:N.
What CWE is associated with CVE-2021-21304?
CVE-2021-21304 is classified under CWE-1321: Improperly Controlled Modification of Object Prototype Attributes ('Prototype Pollution') (The product receives input from an upstream component that specifies attributes that are to be initialized or updated in an object, but it does not properly control modifications of attributes of the object prototype.).
How can I check npm dependencies for CVE-2021-21304?
Run the dependency tree command: 'npm ls dynamoose'. 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-rrqm-p222-8ph2",
  "modified" : "2022-05-26T19:58:25Z",
  "published" : "2021-02-08T17:44:01Z",
  "aliases" : [ "CVE-2021-21304" ],
  "summary" : "Prototype Pollution in Dynamoose",
  "details" : "### Impact\n\nIn Dynamoose versions 2.0.0-2.6.0 there was a prototype pollution vulnerability in the internal utility method [`lib/utils/object/set.ts`](https://github.com/dynamoose/dynamoose/blob/master/lib/utils/object/set.ts). This method is used throughout the codebase for various operations throughout Dynamoose.\n\nWe have not seen any evidence of this vulnerability being exploited.\n\nWe do not believe this issue impacts v1.x.x since this method was added as part of the v2 rewrite. This vulnerability also impacts v2.x.x beta/alpha versions.\n\n### Patches\n\nv2.7.0 includes a patch for this vulnerability.\n\n### Workarounds\n\nWe are unaware of any workarounds to patch this vulnerability other than upgrading to v2.7.0 or greater.\n\n### References\n\n- Patch commit hash: 324c62b4709204955931a187362f8999805b1d8e\n\n### For more information\n\nIf you have any questions or comments about this advisory:\n\n* [Contact me](https://charlie.fish/contact)\n* [Read our Security Policy](https://github.com/dynamoose/dynamoose/blob/master/SECURITY.md)\n\n### Credit\n\n- GitHub CodeQL Code Scanning",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:C/C:L/I:L/A:N"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "npm",
      "name" : "dynamoose"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "2.0.0"
      }, {
        "fixed" : "2.7.0"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/dynamoose/dynamoose/security/advisories/GHSA-rrqm-p222-8ph2"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2021-21304"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/dynamoose/dynamoose/commit/324c62b4709204955931a187362f8999805b1d8e"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/dynamoose/dynamoose"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/dynamoose/dynamoose/releases/tag/v2.7.0"
  }, {
    "type" : "WEB",
    "url" : "https://www.npmjs.com/package/dynamoose"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-1321", "CWE-915" ],
    "severity" : "HIGH",
    "github_reviewed" : true,
    "github_reviewed_at" : "2021-02-08T17:43:18Z",
    "nvd_published_at" : "2021-02-08T18:15:00Z"
  }
}