CVE-2026-25541: Bytes :reserve Vulnerability

MODERATE
Advisory Identifier: GHSA-434x-w66g-qw3r
CWE-680
Published
Advisory Summary

CVE-2026-25541 is a MODERATE :reserve vulnerability (CWE-680: Integer Overflow to Buffer Overflow) affecting Bytes libraries in the crates.io ecosystem. The issue involves :reserve. Remediation is available by upgrading affected packages to version 1.11.1.

CVE-2026-25541 at a Glance

CVE Identifier CVE-2026-25541
GHSA Identifier GHSA-434x-w66g-qw3r
Severity MODERATE
CVSS v3.1 Base Score N/A
CWE Classification CWE-680: Integer Overflow to Buffer Overflow
Affected Product Bytes
Package Ecosystem crates.io
Published Date
Last Updated

How to Fix CVE-2026-25541

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

bytes fixed: 1.11.1
Upgrade bytes to 1.11.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 bytes

How to Check if You Are Affected

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

inspect dependencies for bytes

Analyze the terminal output to locate any version of Bytes in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 1.11.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-680: Integer Overflow to Buffer Overflow, where the product performs a calculation to determine how much memory to allocate, but an integer overflow can occur that causes less memory to be allocated than expected, leading to a buffer overflow. In Bytes, 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

# Details In the unique reclaim path of `BytesMut::reserve`, the condition ```rs if v_capacity >= new_cap + offset ``` uses an unchecked addition. When `new_cap + offset` overflows `usize` in release builds, this condition may incorrectly pass, causing `self.cap` to be set to a value that exceeds the actual allocated capacity. Subsequent APIs such as `spare_capacity_mut()` then trust this corrupted `cap` value and may create out-of-bounds slices, leading to UB. This behavior is observable in release builds (integer overflow wraps), whereas debug builds panic due to overflow checks. ## PoC ```rs use bytes::*; fn main() { let mut a = BytesMut::from(&b"hello world"[..]); let mut b = a.split_off(5); // Ensure b becomes the unique owner of the backing storage drop(a); // Trigger overflow in new_cap + offset inside reserve b.reserve(usize::MAX - 6); // This call relies on the corrupted cap and may cause UB & HBO b.put_u8(b'h'); } ``` # Workarounds Users of `BytesMut::reserve` are only affected if integer overflow checks are configured to wrap. When integer overflow is configured to panic, this issue does not apply. This vulnerability is also known as [RUSTSEC-2026-0007](https://rustsec.org/advisories/RUSTSEC-2026-0007.html).

CVE-2026-25541 Affected Bytes Versions

1 component(s)
Fixed Versions:
1.11.1
Product / Package Ecosystem Affected Versions Fixed Version
bytes
crates.io
≥ 1.2.1
< 1.11.1
1.11.1

References

Frequently Asked Questions

What is CVE-2026-25541?
CVE-2026-25541 is a security vulnerability in Bytes involving :reserve under CWE-680: Integer Overflow to Buffer Overflow.
Which Bytes versions are affected?
Affected versions include releases prior to 1.11.1 across affected packages: bytes.
What version fixes CVE-2026-25541?
Upgrading to 1.11.1 (or the latest patched release for your respective branch) resolves the vulnerability.
Is bytes affected?
Yes, bytes is affected in releases prior to 1.11.1. Upgrade your dependency to 1.11.1 or later.
What CWE is associated with CVE-2026-25541?
CVE-2026-25541 is classified under CWE-680: Integer Overflow to Buffer Overflow (The product performs a calculation to determine how much memory to allocate, but an integer overflow can occur that causes less memory to be allocated than expected, leading to a buffer overflow.).
How can I check crates.io dependencies for CVE-2026-25541?
Run the dependency tree command: 'inspect dependencies for bytes'. 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-434x-w66g-qw3r",
  "modified" : "2026-02-05T00:37:18Z",
  "published" : "2026-02-03T19:17:46Z",
  "aliases" : [ "CVE-2026-25541" ],
  "summary" : "bytes has integer overflow in BytesMut::reserve",
  "details" : "# Details\n\nIn the unique reclaim path of `BytesMut::reserve`, the condition\n```rs\nif v_capacity >= new_cap + offset\n```\nuses an unchecked addition. When `new_cap + offset` overflows `usize` in release builds, this condition may incorrectly pass, causing `self.cap` to be set to a value that exceeds the actual allocated capacity. Subsequent APIs such as `spare_capacity_mut()` then trust this corrupted `cap` value and may create out-of-bounds slices, leading to UB.\n\nThis behavior is observable in release builds (integer overflow wraps), whereas debug builds panic due to overflow checks.\n\n## PoC\n\n```rs\nuse bytes::*;\n\nfn main() {\n    let mut a = BytesMut::from(&b\"hello world\"[..]);\n    let mut b = a.split_off(5);\n\n    // Ensure b becomes the unique owner of the backing storage\n    drop(a);\n\n    // Trigger overflow in new_cap + offset inside reserve\n    b.reserve(usize::MAX - 6);\n\n    // This call relies on the corrupted cap and may cause UB & HBO\n    b.put_u8(b'h');\n}\n```\n\n# Workarounds\n\nUsers of `BytesMut::reserve` are only affected if integer overflow checks are configured to wrap. When integer overflow is configured to panic, this issue does not apply.\n\nThis vulnerability is also known as [RUSTSEC-2026-0007](https://rustsec.org/advisories/RUSTSEC-2026-0007.html).",
  "severity" : [ {
    "type" : "CVSS_V4",
    "score" : "CVSS:4.0/AV:L/AC:L/AT:N/PR:N/UI:N/VC:N/VI:N/VA:H/SC:N/SI:N/SA:N/E:P"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "crates.io",
      "name" : "bytes"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "1.2.1"
      }, {
        "fixed" : "1.11.1"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/tokio-rs/bytes/security/advisories/GHSA-434x-w66g-qw3r"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2026-25541"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/tokio-rs/bytes/commit/d0293b0e35838123c51ca5dfdf468ecafee4398f"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/tokio-rs/bytes"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/tokio-rs/bytes/releases/tag/v1.11.1"
  }, {
    "type" : "WEB",
    "url" : "https://rustsec.org/advisories/RUSTSEC-2026-0007.html"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-680" ],
    "severity" : "MODERATE",
    "github_reviewed" : true,
    "github_reviewed_at" : "2026-02-03T19:17:46Z",
    "nvd_published_at" : "2026-02-04T22:16:00Z"
  }
}