Repository navigation
GH-68 Fix self-referential entity expansion - #69
Merged
Merged
Conversation
Ticket libwww-perlGH-68 - After the string grows, the byte at its end holds whatever the buffer held before, so an entity name that ran to the end could match a "name;" key on that stale byte.
Ticket libwww-perlGH-68 - Copy the string before the first write and expand from that copy, so `_decode_entities` gives the same result whether the entity table holds the string itself or a separate copy of it. - Drop the buffer added for CVE-2026-8829, which is not needed now that no pointer into the string survives a realloc. - Die if looking up a value runs Perl code that changes the string, since we hold pointers into it. Hold a reference to the string for the duration of the call and free the copy from the savestack, so neither is lost when that code dies.
pjcj
force-pushed
the
GH-68-self-entity
branch
from
September 19, 2026 00:36
897e160 to
df657bf
Compare
A tied entity table whose FETCH frees and reallocates the string being decoded must be caught by the mutation guard rather than left to read through a dangling pointer. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
oalders
force-pushed
the
GH-68-self-entity
branch
from
September 19, 2026 21:35
9599fd6 to
1511c9c
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
An entity whose value is the string being decoded produced a result that mixed decoded output, stale bytes and undecoded input, as reported in the ticket. The result now follows the rule the routine has always followed when the entity table holds a separate copy of that string. The entity expands once, to the value the table held when the call began.
Changes
name;key on the byte beyond the end, which holds stale content once the string has grown. This is its own commit, since the bug predates the ticket._decode_entities, which nothing stated before.Implications
_decode_entitiesalready gives when the table holds a copy of the string rather than the string itself. Those two calls look identical in Perl, so they ought to agree, and now they do.t/entities.tstill covers the payload which triggered the fault.grow_gap, but that is a rewrite of a hot loop and deserves its own ticket.Ticket
Closes #68