[PATCH] Fix Heap-use-after-free in hash_table_destroy

shivam tiwari <[email protected]> Mon, 24 Mar 2025 13:02:16 +0530
Newsgroups gmane.comp.web.wget.general
Message-ID <CALz0HOpRn8z0hUVRLU36xdmrxf7yfJ3XMOOSU0YXExZUjWsdWA@mail.gmail.com>
--0000000000003f7a740631119b80
Content-Type: text/plain; charset="UTF-8"

Dear Wget Developers,

This patch fixes a Heap-use-after-free vulnerability in the
hash_table_destroy function.

Vulnerability Details:
Project: wget
Fuzzing Engine: honggfuzz
Fuzz Target: wget_options_fuzzer
Job Type: honggfuzz_asan_wget
Platform: Linux
Crash Type: Heap-use-after-free READ 8
Issue Link: https://issues.oss-fuzz.com/issues/385180607

Description of Changes:
The vulnerability was caused by accessing the hash table (ht) and its cells
after they had been freed. To resolve this issue, the following changes
were made:

Function Affected: hash_table_destroy
Resolution: After freeing ht->cells and ht, they are now set to NULL to
ensure they are not accessed again.By setting ht and its cells to NULL
after freeing them, we prevent any further access to the freed memory, thus
fixing the Heap-use-after-free vulnerability.
Thanks

--0000000000003f7a740631119b80
Content-Type: application/octet-stream; 
	name="0001-Fix-Heap-use-after-free-in-hash_table_destroy.patch"
Content-Disposition: attachment; 
	filename="0001-Fix-Heap-use-after-free-in-hash_table_destroy.patch"
Content-Transfer-Encoding: base64
Content-ID: <f_m8mqx9y40>
X-Attachment-Id: f_m8mqx9y40

RnJvbSBiN2ZmY2ViZjM3OGQxMzg4MWNlZjU1ZmVmMWZmMDAxZWNjMGQ0Y2VkIE1vbiBTZXAgMTcg
MDA6MDA6MDAgMjAwMQpGcm9tOiBTaGl2YW03LTEgPDU1MDQ2MDMxK1NoaXZhbTctMUB1c2Vycy5u
b3JlcGx5LmdpdGh1Yi5jb20+CkRhdGU6IE1vbiwgMjQgTWFyIDIwMjUgMDc6Mjc6MjMgKzAwMDAK
U3ViamVjdDogW1BBVENIXSBGaXggSGVhcC11c2UtYWZ0ZXItZnJlZSBpbiBoYXNoX3RhYmxlX2Rl
c3Ryb3kK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