Vulnerabilities in pkg:npm/@chainsafe/lodestar

PACKAGE
Advisory Identifier: GHSA-cvj7-5f3c-9vg9
Advisory Summary

CVE-2022-29219 is a HIGH (CVSS 7.5) attesterslashing number overflow vulnerability (CWE-190: Integer Overflow or Wraparound) affecting @chainsafe/lodestar libraries in the npm ecosystem. The issue involves attesterslashing number overflow. Remediation is available by upgrading affected packages to version 0.36.0.

1 Known Advisory Record(s)
Package Vulnerability Intelligence

pkg:npm/@chainsafe/lodestar

1 Known Advisory Record(s)

Vulnerability advisories affecting package pkg:npm/@chainsafe/lodestar. Select an advisory below to view technical details or fixes.

Advisory ID CVE / NVD Severity Summary
GHSA-cvj7-5f3c-9vg9 CVE-2022-29219 HIGH AttesterSlashing number overflow

CVE-2022-29219 at a Glance

CVE Identifier CVE-2022-29219
GHSA Identifier GHSA-cvj7-5f3c-9vg9
Severity HIGH
CVSS v3.1 Base Score 7.5
CWE Classification CWE-190: Integer Overflow or Wraparound
Affected Product @chainsafe/lodestar
Package Ecosystem npm
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:H/A:N).

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

How to Fix CVE-2022-29219

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

@chainsafe/lodestar fixed: 0.36.0
npm install @chainsafe/lodestar@0.36.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 @chainsafe/lodestar

How to Check if You Are Affected

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

npm ls @chainsafe/lodestar

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

Note: The npm ls @chainsafe/lodestar 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-190: Integer Overflow or Wraparound, where the product performs a calculation that can produce an integer overflow or wraparound when the logic assumes that the resulting value will always be larger than the original value. this occurs when an integer value is incremented to a value that is too large to store in the associated representation. when this occurs, the value may become a very small or negative number. In @chainsafe/lodestar, 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 Possible consensus split given maliciously-crafted `AttesterSlashing` or `ProposerSlashing` being included on-chain. Since we represent `uint64` values as native javascript `number`s, there is an issue when those variables with large (greater than 2^53) `uint64` values are included on chain. In those cases, Lodestar may view _valid_ `AttesterSlashing` or `ProposerSlashing` as _invalid_, due to rounding errors in large `number` values. This causes a consensus split, where Lodestar nodes are forked away from the main network. Similarly Lodestar may consider _invalid_ `ProposerSlashing` as _valid_, thus including in proposed blocks that will be considered invalid by the network. ### Patches https://github.com/ChainSafe/lodestar/pull/3977 ### Workarounds Use `BigInt` to represent `Slot` and `Epoch` values in `AttesterSlashing` and `ProposerSlashing` objects. `BigInt` is too slow to be used in all `Slot` and `Epoch` cases, so we will carefully use `BigInt` just where necessary for consensus.

CVE-2022-29219 Affected @chainsafe/lodestar Versions

1 component(s)
Fixed Versions:
0.36.0
Product / Package Ecosystem Affected Versions Fixed Version
@chainsafe/lodestar
npm
< 0.36.0
0.36.0

References

Frequently Asked Questions

What is CVE-2022-29219?
CVE-2022-29219 is a security vulnerability in @chainsafe/lodestar involving AttesterSlashing number overflow under CWE-190: Integer Overflow or Wraparound.
Which @chainsafe/lodestar versions are affected?
Affected versions include releases prior to 0.36.0 across affected packages: @chainsafe/lodestar.
What version fixes CVE-2022-29219?
Upgrading to 0.36.0 (or the latest patched release for your respective branch) resolves the vulnerability.
Is @chainsafe/lodestar affected?
Yes, @chainsafe/lodestar is affected in releases prior to 0.36.0. Upgrade your dependency to 0.36.0 or later.
What is the CVSS score of CVE-2022-29219?
CVE-2022-29219 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:H/A:N.
What CWE is associated with CVE-2022-29219?
CVE-2022-29219 is classified under CWE-190: Integer Overflow or Wraparound (The product performs a calculation that can produce an integer overflow or wraparound when the logic assumes that the resulting value will always be larger than the original value. This occurs when an integer value is incremented to a value that is too large to store in the associated representation. When this occurs, the value may become a very small or negative number.).
How can I check npm dependencies for CVE-2022-29219?
Run the dependency tree command: 'npm ls @chainsafe/lodestar'. 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-cvj7-5f3c-9vg9",
  "modified" : "2022-05-24T22:21:10Z",
  "published" : "2022-05-24T22:21:10Z",
  "aliases" : [ "CVE-2022-29219" ],
  "summary" : "AttesterSlashing number overflow",
  "details" : "### Impact\n\nPossible consensus split given maliciously-crafted `AttesterSlashing` or `ProposerSlashing` being included on-chain.\n\nSince we represent `uint64` values as native javascript `number`s, there is an issue when those variables with large (greater than 2^53) `uint64` values are included on chain. In those cases, Lodestar may view _valid_ `AttesterSlashing` or `ProposerSlashing` as _invalid_, due to rounding errors in large `number` values. This causes a consensus split, where Lodestar nodes are forked away from the main network.\n\nSimilarly Lodestar may consider _invalid_ `ProposerSlashing` as _valid_, thus including in proposed blocks that will be considered invalid by the network.\n\n### Patches\n\nhttps://github.com/ChainSafe/lodestar/pull/3977\n\n### Workarounds\n\nUse `BigInt` to represent `Slot` and `Epoch` values in `AttesterSlashing` and `ProposerSlashing` objects. `BigInt` is too slow to be used in all `Slot` and `Epoch` cases, so we will carefully use `BigInt` just where necessary for consensus.",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:H/A:N"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "npm",
      "name" : "@chainsafe/lodestar"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "0.36.0"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/ChainSafe/lodestar/security/advisories/GHSA-cvj7-5f3c-9vg9"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2022-29219"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/ChainSafe/lodestar/pull/3977"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/ChainSafe/lodestar"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/ChainSafe/lodestar/releases/tag/v0.36.0"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-190" ],
    "severity" : "HIGH",
    "github_reviewed" : true,
    "github_reviewed_at" : "2022-05-24T22:21:10Z",
    "nvd_published_at" : "2022-05-24T15:15:00Z"
  }
}