Skip to content

Fix heap-use-after-free in _decode_entities (CVE-2026-8829)#56

Merged
oalders merged 2 commits into
masterfrom
html-parser-decode-entities
May 19, 2026
Merged

Fix heap-use-after-free in _decode_entities (CVE-2026-8829)#56
oalders merged 2 commits into
masterfrom
html-parser-decode-entities

Conversation

@oalders

@oalders oalders commented May 19, 2026

Copy link
Copy Markdown
Member

Summary

Fixes a heap-use-after-free in _decode_entities (CVE-2026-8829).

When the input SV passed to _decode_entities is the same SV stored as a self-referential value in the entity hash, grow_gap() could realloc the SV's PV buffer, leaving repl pointing at freed memory. The fix copies the entity value into an owned buffer when the hash entry SV aliases the input SV, so repl stays valid after a later realloc.

The change is by Paul Johnson, who supplied it as a diff.

Test plan

  • New regression test in t/entities.t exercises _decode_entities with a self-aliased entity hash value and a payload large enough to force grow_gap() to realloc the SV's PV.

🤖 Generated with Claude Code

pjcj and others added 2 commits May 19, 2026 21:20
When the input SV passed to _decode_entities is the same SV stored as a
self-referential value in the entity hash, grow_gap() could realloc the
SV's PV buffer, leaving repl pointing at freed memory. Copy the entity
value into an owned buffer when the hash entry SV aliases the input SV.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@oalders
oalders force-pushed the html-parser-decode-entities branch from f2bd219 to 30e75c6 Compare May 19, 2026 21:21
@oalders
oalders merged commit dc20dd3 into master May 19, 2026
23 checks passed
@oalders
oalders deleted the html-parser-decode-entities branch May 19, 2026 21:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants