mirror of
https://github.com/google/brotli.git
synced 2026-07-08 17:56:58 +00:00
Use-after-free in BrotliEncoderCompressStream when prepared dictionary retains pointer to caller buffer #550
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @hgarrereyn on GitHub (Sep 25, 2025).
There is a potential UAF when
BrotliEncoderPrepareDictionaryretains a stale pointer to the original dictionary buffer passed in. Other APIs have explicitly documented lifetime rules about ownership, but I couldn't find any comments/documentation aboutBrotliEncoderPrepareDictionaryindicating the original buffer is expected to be kept alive.Tested on the most recent commit:
85d46ce6As a user I would expect either:
BrotliEncoderPrepareDictionarymakes a copy of the underlying buffer, and does not retain a pointer to the original source (thus users can free it)The following testcase triggers an ASAN violation caused by retaining a pointer to an underlying dictionary buffer which is freed before trying to perform compression:
testcase
report
@eustas commented on GitHub (Sep 25, 2025):
I agree, that documentation should be done more visible and explicit. Here is what we have now:
9686382ff3/c/enc/compound_dictionary.h (L22)@eustas commented on GitHub (Sep 25, 2025):
Clarified in #1332