RUSTSEC-2026-0197

Source
https://rustsec.org/advisories/RUSTSEC-2026-0197
Import Source
https://github.com/rustsec/advisory-db/blob/osv/crates/RUSTSEC-2026-0197.json
JSON Data
https://api.osv.dev/v1/vulns/RUSTSEC-2026-0197
Published
2026-03-11T12:00:00Z
Modified
2026-07-03T13:45:04.208022006Z
Summary
`Matrix{2,3,4}::swap_columns` can trigger undefined behavior for identical indices
Details

The Matrix2::swap_columns, Matrix3::swap_columns, and Matrix4::swap_columns implementations call ptr::swap(&mut self[a], &mut self[b]).

When a == b, these safe APIs create two mutable references to the same matrix column and pass them to ptr::swap. This violates Rust's aliasing rules and can trigger undefined behavior. The issue can be reproduced from safe Rust by calling swap_columns with identical column indices, for example m.swap_columns(0, 0).

A minimal fix is to return early when the two column indices are equal before calling ptr::swap.

Database specific
{
    "license": "CC0-1.0"
}
References

Affected packages

crates.io / cgmath

Package

Affected ranges

Type
SEMVER
Events
Introduced
0.0.0-0

Ecosystem specific

{
    "affected_functions": null,
    "affects": {
        "os": [],
        "functions": [
            "cgmath::Matrix2::swap_columns",
            "cgmath::Matrix3::swap_columns",
            "cgmath::Matrix4::swap_columns"
        ],
        "arch": []
    }
}

Database specific

informational
"unsound"
source
"https://github.com/rustsec/advisory-db/blob/osv/crates/RUSTSEC-2026-0197.json"
categories
[
    "memory-corruption"
]
cvss
null