RUSTSEC-2026-0332

Vulnerability from osv_rustsec – Published: 2026-09-08 12:00 – Updated: 2026-10-07 14:40 – Source website
VLAI
Summary
`WaveFormat::parse` reads past the end of a `&WAVEFORMATEX`
Details

WaveFormat::parse is a safe function that takes a &WAVEFORMATEX, which is only valid for reads of size_of::<WAVEFORMATEX>() (18) bytes. When the header has wFormatTag == WAVE_FORMAT_EXTENSIBLE and cbSize >= 22, the function reinterprets the reference as a WAVEFORMATEXTENSIBLE and reads 40 bytes. Nothing in the signature guarantees that the header sits at the start of a larger buffer, so safe code can trigger an out-of-bounds read:

use wasapi::WaveFormat;
use windows::Win32::Media::Audio::WAVEFORMATEX;
use windows::Win32::Media::KernelStreaming::WAVE_FORMAT_EXTENSIBLE;

let header = WAVEFORMATEX {
    wFormatTag: WAVE_FORMAT_EXTENSIBLE as u16,
    nChannels: 2,
    nSamplesPerSec: 48000,
    nAvgBytesPerSec: 384000,
    nBlockAlign: 8,
    wBitsPerSample: 32,
    cbSize: 22,
};
// Reads 22 bytes past the end of `header`.
let _ = WaveFormat::parse(&header);

A more likely way to hit this is to copy the header out of a format pointer returned by WASAPI (let fmt = unsafe { *ptr };) and pass &fmt. The copy keeps cbSize, but not the 22 bytes that follow it. The bytes read past the end are returned as the channel mask and subformat of the parsed format.

The flaw was corrected in commit 2562db7, released in 0.25.0. parse is now an unsafe fn that takes a *const WAVEFORMATEX, and the caller must guarantee that the pointer is valid for reads of size_of::<WAVEFORMATEX>() + cbSize bytes. WaveFormat::parse_from_blob_bytes (available since 0.23.0) is the safe alternative and checks the slice length against cbSize.


{
  "affected": [
    {
      "database_specific": {
        "categories": [
          "memory-exposure"
        ],
        "cvss": null,
        "informational": "unsound"
      },
      "ecosystem_specific": {
        "affected_functions": null,
        "affects": {
          "arch": [],
          "functions": [
            "wasapi::WaveFormat::parse"
          ],
          "os": [
            "windows"
          ]
        }
      },
      "package": {
        "ecosystem": "crates.io",
        "name": "wasapi",
        "purl": "pkg:cargo/wasapi"
      },
      "ranges": [
        {
          "events": [
            {
              "introduced": "0.20.0"
            },
            {
              "fixed": "0.25.0"
            }
          ],
          "type": "SEMVER"
        }
      ],
      "versions": []
    }
  ],
  "aliases": [],
  "database_specific": {
    "license": "CC0-1.0"
  },
  "details": "`WaveFormat::parse` is a safe function that takes a `\u0026WAVEFORMATEX`, which is\nonly valid for reads of `size_of::\u003cWAVEFORMATEX\u003e()` (18) bytes. When the header\nhas `wFormatTag == WAVE_FORMAT_EXTENSIBLE` and `cbSize \u003e= 22`, the function\nreinterprets the reference as a `WAVEFORMATEXTENSIBLE` and reads 40 bytes.\nNothing in the signature guarantees that the header sits at the start of a\nlarger buffer, so safe code can trigger an out-of-bounds read:\n\n```rust\nuse wasapi::WaveFormat;\nuse windows::Win32::Media::Audio::WAVEFORMATEX;\nuse windows::Win32::Media::KernelStreaming::WAVE_FORMAT_EXTENSIBLE;\n\nlet header = WAVEFORMATEX {\n    wFormatTag: WAVE_FORMAT_EXTENSIBLE as u16,\n    nChannels: 2,\n    nSamplesPerSec: 48000,\n    nAvgBytesPerSec: 384000,\n    nBlockAlign: 8,\n    wBitsPerSample: 32,\n    cbSize: 22,\n};\n// Reads 22 bytes past the end of `header`.\nlet _ = WaveFormat::parse(\u0026header);\n```\n\nA more likely way to hit this is to copy the header out of a format pointer\nreturned by WASAPI (`let fmt = unsafe { *ptr };`) and pass `\u0026fmt`. The copy\nkeeps `cbSize`, but not the 22 bytes that follow it. The bytes read past the\nend are returned as the channel mask and subformat of the parsed format.\n\nThe flaw was corrected in commit `2562db7`, released in 0.25.0. `parse` is now\nan `unsafe fn` that takes a `*const WAVEFORMATEX`, and the caller must\nguarantee that the pointer is valid for reads of\n`size_of::\u003cWAVEFORMATEX\u003e() + cbSize` bytes. `WaveFormat::parse_from_blob_bytes`\n(available since 0.23.0) is the safe alternative and checks the slice length\nagainst `cbSize`.",
  "id": "RUSTSEC-2026-0332",
  "modified": "2026-10-07T14:40:27Z",
  "published": "2026-09-08T12:00:00Z",
  "references": [
    {
      "type": "PACKAGE",
      "url": "https://crates.io/crates/wasapi"
    },
    {
      "type": "ADVISORY",
      "url": "https://rustsec.org/advisories/RUSTSEC-2026-0332.html"
    },
    {
      "type": "REPORT",
      "url": "https://github.com/HEnquist/wasapi-rs/issues/65"
    },
    {
      "type": "WEB",
      "url": "https://github.com/HEnquist/wasapi-rs/pull/64"
    }
  ],
  "related": [],
  "severity": [],
  "summary": "`WaveFormat::parse` reads past the end of a `\u0026WAVEFORMATEX`"
}



Log in or create an account to share your comment.




Tags
Taxonomy of the tags.


Loading…

Loading…

Loading…

Forecast uses a logistic model when the trend is rising, or an exponential decay model when the trend is falling. Fitted via linearized least squares.

Sightings

Author Source Type Date Other

Nomenclature

  • Seen: The vulnerability was mentioned, discussed, or observed by the user.
  • Confirmed: The vulnerability has been validated from an analyst's perspective.
  • Published Proof of Concept: A public proof of concept is available for this vulnerability.
  • Exploited: The vulnerability was observed as exploited by the user who reported the sighting.
  • Patched: The vulnerability was observed as successfully patched by the user who reported the sighting.
  • Not exploited: The vulnerability was not observed as exploited by the user who reported the sighting.
  • Not confirmed: The user expressed doubt about the validity of the vulnerability.
  • Not patched: The vulnerability was not observed as successfully patched by the user who reported the sighting.

Loading…

Loading…

Loading…

Related by attack behaviour

Vulnerabilities whose description is nearest to this one in the vector space of the CIRCL/vulnerability-attack-technique-biencoder model. This is a similarity search over the bi-encoder space (plain cosine), not a classification, and it has no measured accuracy.


Loading…