CVE-2026-42199: Grid Integer Overflow Vulnerability

MODERATE
Advisory Identifier: GHSA-38c5-483c-4qqp
CVSS 6.2
CWE-190
Published
Advisory Summary

CVE-2026-42199 is a MODERATE (CVSS 6.2) integer overflow vulnerability (CWE-190: Integer Overflow or Wraparound) affecting Grid libraries in the crates.io ecosystem. The issue involves integer overflow in grid::expand_rows leads to safe-api undefined behavior. Remediation is available by upgrading affected packages to version 1.0.1.

CVE-2026-42199 at a Glance

CVE Identifier CVE-2026-42199
GHSA Identifier GHSA-38c5-483c-4qqp
Severity MODERATE
CVSS v3.1 Base Score 6.2
CWE Classification CWE-190: Integer Overflow or Wraparound
Affected Product Grid
Package Ecosystem crates.io
Published Date
Last Updated

Security Impact

CVSS: 6.2

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

Attack Vector Local (AV:L)
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-2026-42199

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

grid fixed: 1.0.1
Upgrade grid to 1.0.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 grid

How to Check if You Are Affected

To determine whether your application is affected by CVE-2026-42199, inspect your project dependencies for Grid:

inspect dependencies for grid

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

### Summary An integer overflow in `Grid::expand_rows()` can corrupt the relationship between the grid’s logical dimensions and its backing storage. After the internal invariant is broken, the safe API get() may invoke get_unchecked() with an invalid index, resulting in Undefined Behavior. ### Details Tested Version: grid = "1.0.0" expand_rows() computes the new backing length using unchecked arithmetic: `self.data.len() + rows * self.cols ` If rows * self.cols or the subsequent addition overflows usize, the result wraps in release builds and self.data may be resized to a length much smaller than logically required. After that, if the grid is in ColumnMajor order, the function performs in-place rotation using indices derived from: ``` let total_rows = self.rows + row_added; let col_idx = i * total_rows; self.data[col_idx..col_idx + total_rows + i].rotate_right(i); ``` These computations also rely on the assumption that the backing storage has been resized to the correct length. Once the earlier length computation has wrapped, this assumption no longer holds, so the function may operate on invalid ranges or otherwise enter an inconsistent state. Finally, the function updates logical metadata with: `self.rows += rows; ` As a result, the grid can end up with logical dimensions that no longer match the actual backing storage. Subsequent safe API calls such as get() may then rely on corrupted metadata and reach unsafe internal accesses, resulting in invalid unchecked access and Undefined Behavior. ### PoC ```rust #![forbid(unsafe_code)] use grid::Grid; fn main() { let mut g = Grid::from_vec(vec![1u8, 2u8], 2); g.expand_rows(usize::MAX / 2); g.get(0, 0); // triggers UB in get_unchecked } ``` ### Impact - Invalid unchecked access (`get_unchecked`) reached via safe API - Confirmed by Miri (release-mode): ``` error: Undefined Behavior: `assume` called with `false` --> ..../grid-1.0.0/src/lib.rs:527:9 | 527 | self.data.get_unchecked(index) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Undefined Behavior occurred here ``` - Potential crash / denial of service in release-builds (e.g., SIGSEGV, Illegal instruction) - Violates Rust’s safety guarantees despite using only safe code

CVE-2026-42199 Affected Grid Versions

1 component(s)
Fixed Versions:
1.0.1
Product / Package Ecosystem Affected Versions Fixed Version
grid
crates.io
≥ 0.17.0
< 1.0.1
1.0.1

References

Frequently Asked Questions

What is CVE-2026-42199?
CVE-2026-42199 is a security vulnerability in Grid involving Integer Overflow in Grid::expand_rows Leads to Safe-API Undefined Behavior under CWE-190: Integer Overflow or Wraparound.
Which Grid versions are affected?
Affected versions include releases prior to 1.0.1 across affected packages: grid.
What version fixes CVE-2026-42199?
Upgrading to 1.0.1 (or the latest patched release for your respective branch) resolves the vulnerability.
Is grid affected?
Yes, grid is affected in releases prior to 1.0.1. Upgrade your dependency to 1.0.1 or later.
What is the CVSS score of CVE-2026-42199?
CVE-2026-42199 has a CVSS v3.1 base score of 6.2 (MODERATE) with vector string CVSS:3.1/AV:L/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H.
What CWE is associated with CVE-2026-42199?
CVE-2026-42199 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 crates.io dependencies for CVE-2026-42199?
Run the dependency tree command: 'inspect dependencies for grid'. 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-38c5-483c-4qqp",
  "modified" : "2026-05-13T13:37:34Z",
  "published" : "2026-04-24T15:57:36Z",
  "aliases" : [ "CVE-2026-42199" ],
  "summary" : "Grid: Integer Overflow in Grid::expand_rows Leads to Safe-API Undefined Behavior",
  "details" : "### Summary\nAn integer overflow in `Grid::expand_rows()` can corrupt the relationship between the grid’s logical dimensions and its backing storage. After the internal invariant is broken, the safe API get() may invoke get_unchecked() with an invalid index, resulting in Undefined Behavior.\n\n### Details\nTested Version: grid = \"1.0.0\"\n\nexpand_rows() computes the new backing length using unchecked arithmetic:\n\n`self.data.len() + rows * self.cols\n`\n\nIf rows * self.cols or the subsequent addition overflows usize, the result wraps in release builds and self.data may be resized to a length much smaller than logically required.\n\nAfter that, if the grid is in ColumnMajor order, the function performs in-place rotation using indices derived from:\n\n```\nlet total_rows = self.rows + row_added;\nlet col_idx = i * total_rows;\nself.data[col_idx..col_idx + total_rows + i].rotate_right(i);\n```\n\nThese computations also rely on the assumption that the backing storage has been resized to the correct length. Once the earlier length computation has wrapped, this assumption no longer holds, so the function may operate on invalid ranges or otherwise enter an inconsistent state.\n\nFinally, the function updates logical metadata with:\n\n`self.rows += rows;\n`\n\nAs a result, the grid can end up with logical dimensions that no longer match the actual backing storage. Subsequent safe API calls such as get() may then rely on corrupted metadata and reach unsafe internal accesses, resulting in invalid unchecked access and Undefined Behavior.\n\n### PoC\n```rust\n#![forbid(unsafe_code)]\n\nuse grid::Grid;\n\nfn main() {\n    let mut g = Grid::from_vec(vec![1u8, 2u8], 2);\n\n    g.expand_rows(usize::MAX / 2);\n\n    g.get(0, 0); // triggers UB in get_unchecked\n}\n```\n\n### Impact\n- Invalid unchecked access (`get_unchecked`) reached via safe API\n- Confirmed by Miri (release-mode):\n\n```\nerror: Undefined Behavior: `assume` called with `false`\n   --> ..../grid-1.0.0/src/lib.rs:527:9\n    |\n527 |         self.data.get_unchecked(index)\n    |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Undefined Behavior occurred here\n\n```\n- Potential crash / denial of service in release-builds (e.g., SIGSEGV, Illegal instruction)\n- Violates Rust’s safety guarantees despite using only safe code",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:L/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "crates.io",
      "name" : "grid"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0.17.0"
      }, {
        "fixed" : "1.0.1"
      } ]
    } ],
    "database_specific" : {
      "last_known_affected_version_range" : "<= 1.0.0"
    }
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/becheran/grid/security/advisories/GHSA-38c5-483c-4qqp"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2026-42199"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/becheran/grid/commit/be213bd3528727148bef2d523c89e95d1fd9c072"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/becheran/grid"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/becheran/grid/releases/tag/v1.0.1"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-190" ],
    "severity" : "MODERATE",
    "github_reviewed" : true,
    "github_reviewed_at" : "2026-04-24T15:57:36Z",
    "nvd_published_at" : "2026-05-08T22:16:31Z"
  }
}