Skip to content

Fix use-after-free and double-free in RemoveFilament (3.27.x) - #6368

Merged
larsewi merged 1 commit into
cfengine:3.27.xfrom
larsewi:use-after-free-3.37.x
Sep 24, 2026
Merged

larsewi merged 1 commit into
cfengine:3.27.xfrom
larsewi:use-after-free-3.37.x

Conversation

@larsewi

@larsewi larsewi commented Sep 24, 2026

Copy link
Copy Markdown
Contributor

Backported from #6358

RemoveFilament() frees `filament` (and destroys filament->items) when
StringSetSize(filament->items) == 0, but had no `return` after that
branch -- every other early-exit branch in this function does. Execution
fell through unconditionally to `OpenDB(&db, filament->db_id)`, a
use-after-free read of the just-freed filament, and at the end of the
function `StringSetDestroy(filament->items)` / `free(filament)` ran
again unconditionally -- a double-free of both filament and its items
set on that path.

Verified with a standalone AddressSanitizer repro (RemoveFilament's body
extracted verbatim, stub types matching the real DBFilament/StringSet
shapes): unfixed, ASan reports a real heap-use-after-free at the
OpenDB(&db, filament->db_id) line; with this one-line `return;` added
(matching every other early-exit branch's own pattern in this file),
clean.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
(cherry picked from commit aecc166)
@larsewi
larsewi force-pushed the use-after-free-3.37.x branch from b111e77 to 69b27f1 Compare September 24, 2026 10:11
@larsewi

larsewi commented Sep 24, 2026

Copy link
Copy Markdown
Contributor Author

@cf-bottom Jenkins please :)

@cf-bottom

Copy link
Copy Markdown

@larsewi
larsewi merged commit 948bc6f into cfengine:3.27.x Sep 24, 2026
42 checks passed
@larsewi
larsewi deleted the use-after-free-3.37.x branch September 24, 2026 21:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants