Vulnerabilities in pkg:golang/cosmossdk.io/math

PACKAGE
Advisory Summary

GHSA-7225-m954-23v7 is a HIGH cosmossdk.io/math: mismatched bit-length validation vulnerability (CWE-190: Integer Overflow or Wraparound) affecting ASA-2024-010 libraries in the Go ecosystem. The issue involves cosmossdk.io/math: mismatched bit-length validation in sdk.int and sdk.dec can lead to panic. Remediation is available by upgrading affected packages to version 1.4.0.

1 Known Advisory Record(s)
Package Vulnerability Intelligence

pkg:golang/cosmossdk.io/math

1 Known Advisory Record(s)

Vulnerability advisories affecting package pkg:golang/cosmossdk.io/math. Select an advisory below to view technical details or fixes.

Advisory ID CVE / NVD Severity Summary
GHSA-7225-m954-23v7 - HIGH ASA-2024-010: cosmossdk.io/math: Mismatched bit-length validation in sdk.Int and sdk.Dec can lead to panic

GHSA-7225-m954-23v7 at a Glance

CVE Identifier N/A
GHSA Identifier GHSA-7225-m954-23v7
Severity HIGH
CVSS v3.1 Base Score N/A
CWE Classification CWE-190: Integer Overflow or Wraparound
Affected Product ASA-2024-010
Package Ecosystem Go
Published Date
Last Updated

How to Fix GHSA-7225-m954-23v7

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

cosmossdk.io/math fixed: 1.4.0
Upgrade cosmossdk.io/math to 1.4.0
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 cosmossdk.io/math

How to Check if You Are Affected

To determine whether your application is affected by GHSA-7225-m954-23v7, inspect your project dependencies for ASA-2024-010:

inspect dependencies for cosmossdk.io/math

Analyze the terminal output to locate any version of ASA-2024-010 in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 1.4.0), 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-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 ASA-2024-010, 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

Name: ASA-2024-010: Mismatched bit-length in `sdk.Int` and `sdk.Dec` can lead to panic Component: Cosmos SDK / Math Criticality: High (Considerable Impact, and Possible Likelihood per [ACMv1.2](https://github.com/interchainio/security/blob/main/resources/CLASSIFICATION_MATRIX.md)) Affected versions: `cosmossdk.io/math` package versions <= `math/v1.3.0` Affected users: Chain Builders + Maintainers, Validators ### Impact The bit-length in `sdk.Int` and `sdk.Dec` are not aligned, which may present a possible panic condition when interacting with `Dec` types in an `Int` context. This issue was resolved by aligning the max size between the data types in the cosmossdk.io/math package. This issue impacts consumers of the cosmossdk.io/math, which includes popular modules including IBC-Go and tokenfactory (permissionless). If your chain interacts with APIs in the cosmossdk.io/math package, or utilizes a module that consumes this library, it is advised to update to the latest version at the time of the patch release by updating your project's go.mod dependency for cosmossdk.io/math. The patch can be applied without a hard-fork, and with a version bump in a chain's go.mod file like the following: #### `go.mod` ```diff - cosmossdk.io/math v1.3.0 + cosmossdk.io/math v1.4.0 ``` > [!NOTE] > When on a lower version than cosmossdk.io/math v1.3.0, please do a coordinated upgrade before upgrading to >= 1.3.0 ### Patches The new release of `cosmossdk.io/math v1.4.0` resolves this issue. Chains that utilize the cosmossdk.io/math library or modules that utilize the cosmossdk.io/math library should update to avoid this condition. ### Timeline * October 31, 2024, 6:55pm UTC: Issue reported to the Cosmos Bug Bounty program * October 31, 2024, 8:56pm UTC: Issue triaged by Amulet on-call, and distributed to Core team * Nov 15, 2024, 2:12am PST: Core team completes patch for issue * Nov 19, 2024, 8:00am PST / 16:00 GMT: Pre-notification delivered * Nov 20, 2024, 8:00am PST / 16:00 GMT: Patch made available This issue was reported by LonelySloth to the Cosmos Bug Bounty Program on HackerOne on October 31, 2024. If you believe you have found a bug in the Interchain Stack or would like to contribute to the program by reporting a bug, please see https://hackerone.com/cosmos. If you have questions about Interchain security efforts, please reach out to our official communication channel at [security@interchain.io](mailto:security@interchain.io). For more information about the Interchain Foundation’s engagement with Amulet, and to sign up for security notification emails, please see https://github.com/interchainio/security.

GHSA-7225-m954-23v7 Affected ASA-2024-010 Versions

1 component(s)
Fixed Versions:
1.4.0
Product / Package Ecosystem Affected Versions Fixed Version
cosmossdk.io/math
Go
< 1.4.0
1.4.0

References

Frequently Asked Questions

What is GHSA-7225-m954-23v7?
GHSA-7225-m954-23v7 is a security vulnerability in ASA-2024-010 involving cosmossdk.io/math: Mismatched bit-length validation in sdk.Int and sdk.Dec can lead to panic under CWE-190: Integer Overflow or Wraparound.
Which ASA-2024-010 versions are affected?
Affected versions include releases prior to 1.4.0 across affected packages: cosmossdk.io/math.
What version fixes GHSA-7225-m954-23v7?
Upgrading to 1.4.0 (or the latest patched release for your respective branch) resolves the vulnerability.
Is cosmossdk.io/math affected?
Yes, cosmossdk.io/math is affected in releases prior to 1.4.0. Upgrade your dependency to 1.4.0 or later.
What CWE is associated with GHSA-7225-m954-23v7?
GHSA-7225-m954-23v7 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 Go dependencies for GHSA-7225-m954-23v7?
Run the dependency tree command: 'inspect dependencies for cosmossdk.io/math'. 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-7225-m954-23v7",
  "modified" : "2024-11-22T20:48:48Z",
  "published" : "2024-11-20T18:23:51Z",
  "aliases" : [ ],
  "summary" : "ASA-2024-010: cosmossdk.io/math: Mismatched bit-length validation in sdk.Int and sdk.Dec can lead to panic",
  "details" : "Name: ASA-2024-010: Mismatched bit-length in `sdk.Int` and `sdk.Dec` can lead to panic \nComponent: Cosmos SDK / Math\nCriticality: High (Considerable Impact, and Possible Likelihood per [ACMv1.2](https://github.com/interchainio/security/blob/main/resources/CLASSIFICATION_MATRIX.md))\nAffected versions: `cosmossdk.io/math` package versions <= `math/v1.3.0`\nAffected users: Chain Builders + Maintainers, Validators\n\n### Impact\n\nThe bit-length in `sdk.Int` and `sdk.Dec` are not aligned, which may present a possible panic condition when interacting with `Dec` types in an `Int` context. This issue was resolved by aligning the max size between the data types in the cosmossdk.io/math package.\n\nThis issue impacts consumers of the cosmossdk.io/math, which includes popular modules including IBC-Go and tokenfactory (permissionless). If your chain interacts with APIs in the cosmossdk.io/math package, or utilizes a module that consumes this library, it is advised to update to the latest version at the time of the patch release by updating your project's go.mod dependency for cosmossdk.io/math.\n\nThe patch can be applied without a hard-fork, and with a version bump in a chain's go.mod file like the following:\n\n#### `go.mod`\n\n```diff\n- cosmossdk.io/math v1.3.0\n+ cosmossdk.io/math v1.4.0\n```\n\n> [!NOTE]  \n> When on a lower version than cosmossdk.io/math v1.3.0, please do a coordinated upgrade before upgrading to >= 1.3.0\n\n### Patches\n\nThe new release of `cosmossdk.io/math v1.4.0` resolves this issue.  Chains that utilize the cosmossdk.io/math library or modules that utilize the cosmossdk.io/math library should update to avoid this condition.\n\n### Timeline\n\n* October 31, 2024, 6:55pm UTC: Issue reported to the Cosmos Bug Bounty program\n* October 31, 2024, 8:56pm UTC: Issue triaged by Amulet on-call, and distributed to Core team\n* Nov 15, 2024, 2:12am PST: Core team completes patch for issue\n* Nov 19, 2024, 8:00am PST / 16:00 GMT: Pre-notification delivered\n* Nov 20, 2024, 8:00am PST / 16:00 GMT: Patch made available\n\n\nThis issue was reported by LonelySloth to the Cosmos Bug Bounty Program on HackerOne on October 31, 2024. If you believe you have found a bug in the Interchain Stack or would like to contribute to the program by reporting a bug, please see https://hackerone.com/cosmos.\n\nIf you have questions about Interchain security efforts, please reach out to our official communication channel at [security@interchain.io](mailto:security@interchain.io).  For more information about the Interchain Foundation’s engagement with Amulet, and to sign up for security notification emails, please see https://github.com/interchainio/security.  \n\n",
  "severity" : [ {
    "type" : "CVSS_V4",
    "score" : "CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:N/VI:N/VA:H/SC:N/SI:N/SA:N"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "Go",
      "name" : "cosmossdk.io/math"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "1.4.0"
      } ]
    } ],
    "database_specific" : {
      "last_known_affected_version_range" : "<= 1.3.0"
    }
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/cosmos/cosmos-sdk/security/advisories/GHSA-7225-m954-23v7"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/cosmos/cosmos-sdk/commit/c6522a72a45c34897f9fc85d438c0b74d52f8862"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/cosmos/cosmos-sdk"
  }, {
    "type" : "WEB",
    "url" : "https://pkg.go.dev/vuln/GO-2024-3279"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-190" ],
    "severity" : "HIGH",
    "github_reviewed" : true,
    "github_reviewed_at" : "2024-11-20T18:23:51Z",
    "nvd_published_at" : null
  }
}