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
#![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
An arithmetic operation produces a value that exceeds the integer type's maximum, causing it to wrap to an unexpected small value. Typical impact: incorrect size calculations leading to heap overflows or logic errors.
CVE-2026-42199 has a CVSS score of 6.2 (Medium). The vector is requires local access, no privileges required, and no user interaction. A CVSS score reflects the worst-case severity of the vulnerability, not your specific exposure. Whether this affects your application depends on whether the vulnerable code is present and reachable in your environment. A fixed version is available (1.0.1); upgrading removes the vulnerable code path.
Affected versions
Security releases
Kodem intelligence
Severity tells you how bad this could be in the worst case. It does not tell you whether you are exposed. Exploitability and impact are functions of runtime truth: whether the vulnerable code is present, reachable, and actually executes in your application. A vulnerable package can sit in your dependency tree and never run.
Kodem, an Intelligent Application Security platform, uses runtime intelligence to reveal which vulnerabilities actually execute in production, so teams prioritize the ones that genuinely matter. Kodem's runtime-powered SCA identifies whether this CVE is reachable in your applications.
Remediation advice
Kodem Kai can prioritize this vulnerability in your dependency tree and generate a fix recommendation.
Frequently Asked Questions
- What is CVE-2026-42199? CVE-2026-42199 is a medium-severity integer overflow or wraparound vulnerability in grid (rust), affecting versions >= 0.17.0, <= 1.0.0. It is fixed in 1.0.1. An arithmetic operation produces a value that exceeds the integer type's maximum, causing it to wrap to an unexpected small value.
- How severe is CVE-2026-42199? CVE-2026-42199 has a CVSS score of 6.2 (Medium). This score reflects the worst-case severity of the vulnerability, not your specific exposure. Whether it represents real risk in your environment depends on whether the vulnerable code is present and reachable.
- Which versions of grid are affected by CVE-2026-42199? grid (rust) versions >= 0.17.0, <= 1.0.0 is affected.
- Is there a fix for CVE-2026-42199? Yes. CVE-2026-42199 is fixed in 1.0.1. Upgrade to this version or later.
- Is CVE-2026-42199 exploitable, and should I be worried? Whether CVE-2026-42199 is exploitable in your environment depends on whether the vulnerable code is present and reachable. A CVSS score is a worst-case rating; it does not account for your specific deployment, configuration, or usage patterns. Kodem, an Intelligent Application Security platform, uses runtime intelligence to show which vulnerabilities actually execute in production, so you can focus on the ones that represent real risk. Get a demo
- What actually determines whether CVE-2026-42199 is exploitable, and how bad it is? Exploitability and impact are not fixed properties of a CVE. They depend on runtime truth: whether the vulnerable code is present, reachable, and actually executes in your application. A high CVSS score on a dependency that never runs is not the same as real risk. Kodem, an Intelligent Application Security platform, uses runtime intelligence to reveal which vulnerabilities actually execute in production, so teams prioritize the ones that genuinely matter.
- How do I fix CVE-2026-42199? Upgrade
gridto 1.0.1 or later.