CVE-2021-39168: @openzeppelin/contracts upgradeable TimelockController Vulnerability Vulnerability

CRITICAL
Advisory Identifier: GHSA-vrw4-w73r-6mm8
CVSS 10.0
CWE-269
Published
Advisory Summary

CVE-2021-39168 is a CRITICAL (CVSS 10.0) timelockcontroller vulnerability vulnerability (CWE-269: Improper Privilege Management) affecting @openzeppelin/contracts upgradeable libraries in the npm ecosystem. The issue involves timelockcontroller vulnerability in openzeppelin contracts. Remediation is available by upgrading affected packages to version 4.3.1, 3.4.2.

CVE-2021-39168 at a Glance

CVE Identifier CVE-2021-39168
GHSA Identifier GHSA-vrw4-w73r-6mm8
Severity CRITICAL
CVSS v3.1 Base Score 10.0
CWE Classification CWE-269: Improper Privilege Management
Affected Product @openzeppelin/contracts upgradeable
Package Ecosystem npm
Published Date
Last Updated

Security Impact

CVSS: 10.0

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:H/I:H/A:H).

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 High (C:H)
Integrity High (I:H)
Availability High (A:H)

How to Fix CVE-2021-39168

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

@openzeppelin/contracts-upgradeable fixed: 4.3.1
npm install @openzeppelin/contracts-upgradeable@4.3.1
@openzeppelin/contracts-upgradeable fixed: 3.4.2
npm install @openzeppelin/contracts-upgradeable@3.4.2
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 @openzeppelin/contracts-upgradeable

How to Check if You Are Affected

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

npm ls @openzeppelin/contracts-upgradeable

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

Note: The npm ls @openzeppelin/contracts-upgradeable 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-269: Improper Privilege Management, where the product does not properly assign, modify, track, or check privileges for an actor, creating an unintended sphere of control for that actor. In @openzeppelin/contracts upgradeable, 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 A vulnerability in `TimelockController` allowed an actor with the executor role to take immediate control of the timelock, by resetting the delay to 0 and escalating privileges, thus gaining unrestricted access to assets held in the contract. Instances with the executor role set to "open" allow anyone to use the executor role, thus leaving the timelock at risk of being taken over by an attacker. ### Patches A fix is included in the following releases of `@openzeppelin/contracts` and `@openzeppelin/contracts-upgradeable`: - 4.3.1 - 3.4.2 - 3.4.2-solc-0.7 Deployed instances of `TimelockController` should be replaced with a fixed version by migrating all assets, ownership, and roles. ### Workarounds Revoke the executor role from accounts not strictly under the team's control. We recommend revoking all executors that are not also proposers. When applying this mitigation, ensure there is at least one proposer and executor remaining. ### References [Post-mortem](https://forum.openzeppelin.com/t/timelockcontroller-vulnerability-postmortem/14958). ### Credits The issue was identified by an anonymous white hat hacker through [Immunefi](https://immunefi.com/). ### For more information If you have any questions or comments about this advisory, or need assistance executing the mitigation, email us at security@openzeppelin.com.

CVE-2021-39168 Affected @openzeppelin/contracts upgradeable Versions

2 component(s)
Fixed Versions:
4.3.13.4.2
Product / Package Ecosystem Affected Versions Fixed Version
@openzeppelin/contracts-upgradeable
npm
≥ 4.0.0
< 4.3.1
4.3.1
@openzeppelin/contracts-upgradeable
npm
≥ 3.3.0
< 3.4.2
3.4.2

References

Frequently Asked Questions

What is CVE-2021-39168?
CVE-2021-39168 is a security vulnerability in @openzeppelin/contracts upgradeable involving TimelockController vulnerability in OpenZeppelin Contracts under CWE-269: Improper Privilege Management.
Which @openzeppelin/contracts upgradeable versions are affected?
Affected versions include releases prior to 4.3.1, 3.4.2 across affected packages: @openzeppelin/contracts-upgradeable.
What version fixes CVE-2021-39168?
Upgrading to 4.3.1, 3.4.2 (or the latest patched release for your respective branch) resolves the vulnerability.
Is @openzeppelin/contracts-upgradeable affected?
Yes, @openzeppelin/contracts-upgradeable is affected in releases prior to 4.3.1, 3.4.2. Upgrade your dependency to 4.3.1, 3.4.2 or later.
What is the CVSS score of CVE-2021-39168?
CVE-2021-39168 has a CVSS v3.1 base score of 10.0 (CRITICAL) with vector string CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:C/C:H/I:H/A:H.
What CWE is associated with CVE-2021-39168?
CVE-2021-39168 is classified under CWE-269: Improper Privilege Management (The product does not properly assign, modify, track, or check privileges for an actor, creating an unintended sphere of control for that actor.).
How can I check npm dependencies for CVE-2021-39168?
Run the dependency tree command: 'npm ls @openzeppelin/contracts-upgradeable'. 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-vrw4-w73r-6mm8",
  "modified" : "2021-09-13T20:30:25Z",
  "published" : "2021-08-30T16:12:49Z",
  "aliases" : [ "CVE-2021-39168" ],
  "summary" : "TimelockController vulnerability in OpenZeppelin Contracts",
  "details" : "### Impact\n\nA vulnerability in `TimelockController` allowed an actor with the executor role to take immediate control of the timelock, by resetting the delay to 0 and escalating privileges, thus gaining unrestricted access to assets held in the contract. Instances with the executor role set to \"open\" allow anyone to use the executor role, thus leaving the timelock at risk of being taken over by an attacker.\n\n### Patches\n\nA fix is included in the following releases of `@openzeppelin/contracts` and `@openzeppelin/contracts-upgradeable`:\n- 4.3.1\n- 3.4.2\n- 3.4.2-solc-0.7\n\nDeployed instances of `TimelockController` should be replaced with a fixed version by migrating all assets, ownership, and roles.\n\n### Workarounds\n\nRevoke the executor role from accounts not strictly under the team's control. We recommend revoking all executors that are not also proposers. When applying this mitigation, ensure there is at least one proposer and executor remaining.\n\n### References\n\n[Post-mortem](https://forum.openzeppelin.com/t/timelockcontroller-vulnerability-postmortem/14958).\n\n### Credits\n\nThe issue was identified by an anonymous white hat hacker through [Immunefi](https://immunefi.com/).\n\n### For more information\n\nIf you have any questions or comments about this advisory, or need assistance executing the mitigation, email us at security@openzeppelin.com.\n",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:C/C:H/I:H/A:H"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "npm",
      "name" : "@openzeppelin/contracts-upgradeable"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "4.0.0"
      }, {
        "fixed" : "4.3.1"
      } ]
    } ]
  }, {
    "package" : {
      "ecosystem" : "npm",
      "name" : "@openzeppelin/contracts-upgradeable"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "3.3.0"
      }, {
        "fixed" : "3.4.2"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/OpenZeppelin/openzeppelin-contracts-upgradeable/security/advisories/GHSA-vrw4-w73r-6mm8"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2021-39168"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/OpenZeppelin/openzeppelin-contracts/commit/cec4f2ef57495d8b1742d62846da212515d99dd5"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/OpenZeppelin/openzeppelin-contracts-upgradeabl"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/CHANGELOG.md#431"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-269" ],
    "severity" : "CRITICAL",
    "github_reviewed" : true,
    "github_reviewed_at" : "2021-08-27T12:57:31Z",
    "nvd_published_at" : "2021-08-27T00:15:00Z"
  }
}