Fix GH-21682: Add NOT_SERIALIZABLE to ZipArchive, XMLWriter, XMLReader, SNMP, tidy, tidyNode#26
Closed
Fix GH-21682: Add NOT_SERIALIZABLE to ZipArchive, XMLWriter, XMLReader, SNMP, tidy, tidyNode#26
Conversation
ZipArchive allowed serialization, producing a string that unserializes into an empty object with no open file handle. Add the @not-serializable annotation so serialize() throws an exception. Closes phpGH-21682
These classes wrap native C handles (libxml2 writer/reader, SNMP session, libTidy document/node) that cannot survive serialization. Unserializing produces a broken object with NULL internal pointers.
118e561 to
92a0bf7
Compare
bug72479.phpt and bug72434.phpt tested UAF vulnerabilities through unserialize(). With NOT_SERIALIZABLE, unserialize() rejects these classes entirely, preventing the UAF by construction. Update tests to verify the rejection.
92a0bf7 to
b7a9957
Compare
Owner
Author
|
Submitted upstream as php#21694 |
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.
Fixes php#21682
Six classes wrap native C handles but allow serialization. Unserializing them produces objects with NULL internal pointers.
Segfault:
tidyNode(ext/tidy): crashes onhasChildren(), danglingTidyNodepointerSilent data loss:
ZipArchive(ext/zip):numFilesreturns 0, archive contents gonetidy(ext/tidy):body()returns NULL,cleanRepair()no-opsSNMP(ext/snmp): methods run against a dead session without errorThrows on use:
XMLWriter(ext/xmlwriter): methods throw "Invalid or uninitialized XMLWriter object"XMLReader(ext/xmlreader):read()throws "Data must be loaded before reading"Adds
@not-serializableto all six soserialize()throws instead of producing broken objects.Two existing UAF exploit tests (
bug72479.phpt,bug72434.phpt) relied onunserialize()instantiating SNMP and ZipArchive objects. WithNOT_SERIALIZABLE,unserialize()rejects these classes outright, removing the UAF vector.