RUSTSEC-2026-0301

Vulnerability from osv_rustsec – Published: 2026-09-22 12:00 – Updated: 2026-09-22 20:47 – Source website
VLAI
Summary
Double free in `StackVec::retain` when a predicate or element `Drop` panics
Details

Summary

StackVec::retain committed its new length to self.len only after its internal loop completed. If the retain predicate or a removed element's Drop implementation panicked before the loop finished, unwinding proceeded with self.len still equal to the original, pre-retain length, leaving either a duplicated or already-destroyed element inside 0..len. StackVec's own Drop then revisited that slot, causing a double-drop (and for heap-owning types, a double-free).

Impact

Affects StackVec<T, CAP>::retain for T: Drop types where the predicate or the removed element's destructor can panic, on builds with unwinding enabled (panic = "unwind"). no_std/panic = "abort" builds cannot trigger this, since unwinding never occurs.

Patch

Fixed in 0.3.3 using an unwind-safe backshift guard, matching the approach alloc::vec::Vec::retain uses.


{
  "affected": [
    {
      "database_specific": {
        "categories": [
          "memory-corruption"
        ],
        "cvss": null,
        "informational": null
      },
      "ecosystem_specific": {
        "affected_functions": null,
        "affects": {
          "arch": [],
          "functions": [],
          "os": []
        }
      },
      "package": {
        "ecosystem": "crates.io",
        "name": "stack_collections",
        "purl": "pkg:cargo/stack_collections"
      },
      "ranges": [
        {
          "events": [
            {
              "introduced": "0.3.0"
            },
            {
              "fixed": "0.3.3"
            }
          ],
          "type": "SEMVER"
        }
      ],
      "versions": []
    }
  ],
  "aliases": [],
  "database_specific": {
    "license": "CC0-1.0"
  },
  "details": "## Summary\n\n`StackVec::retain` committed its new length to `self.len` only after\nits internal loop completed. If the retain predicate or a removed\nelement\u0027s `Drop` implementation panicked before the loop finished,\nunwinding proceeded with `self.len` still equal to the original,\npre-retain length, leaving either a duplicated or already-destroyed\nelement inside `0..len`. `StackVec`\u0027s own `Drop` then revisited that\nslot, causing a double-drop (and for heap-owning types, a double-free).\n\n## Impact\n\nAffects `StackVec\u003cT, CAP\u003e::retain` for `T: Drop` types where the\npredicate or the removed element\u0027s destructor can panic, on builds\nwith unwinding enabled (`panic = \"unwind\"`). `no_std`/`panic = \"abort\"`\nbuilds cannot trigger this, since unwinding never occurs.\n\n## Patch\n\nFixed in 0.3.3 using an unwind-safe backshift guard, matching the\napproach `alloc::vec::Vec::retain` uses.",
  "id": "RUSTSEC-2026-0301",
  "modified": "2026-09-22T20:47:48Z",
  "published": "2026-09-22T12:00:00Z",
  "references": [
    {
      "type": "PACKAGE",
      "url": "https://crates.io/crates/stack_collections"
    },
    {
      "type": "ADVISORY",
      "url": "https://rustsec.org/advisories/RUSTSEC-2026-0301.html"
    },
    {
      "type": "WEB",
      "url": "https://github.com/OverwrittenCode/stack_collections/pull/4"
    }
  ],
  "related": [],
  "severity": [],
  "summary": "Double free in `StackVec::retain` when a predicate or element `Drop` panics"
}



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…

Detection rules are retrieved from Rulezet.

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…