security: guard remaining unserialize() calls with allowed_classes => false - #28
Merged
Merged
Conversation
… false - controllers/settings.php: suppress warnings on malformed data with @ and guard with allowed_classes => false. - lib/Doctrine/Collection.php, Connection.php, Record.php: guard the Serializable::unserialize() implementations' internal unserialize() calls. - lib/Doctrine/Parser/YamlSf/Inline.php: guard unserialize() of embedded !!php/object: YAML scalars. - tests/Security/UnserializeTest.php: relax the settings.php guard check to accept either quote style.
xmacan
previously approved these changes
Sep 17, 2026
There was a problem hiding this comment.
🟡 Changes recommended
Doctrine and YAML deserialization compatibility issues remain unresolved.
Get a fresh assessment by requesting another Copilot review.
Pull request overview
Hardens remaining PHP unserialize() calls with allowed_classes => false and updates the related security test.
Changes:
- Guards settings, Doctrine, and YAML deserialization paths.
- Relaxes the test to accept either quote style.
File summaries
| File | Summary |
|---|---|
tests/Security/UnserializeTest.php |
Accepts either quote style for the guard check. |
lib/Doctrine/Record.php |
Guards record restoration but breaks serialized related-record references. |
lib/Doctrine/Parser/YamlSf/Inline.php |
Guards YAML object loading but breaks documented object round-tripping. |
lib/Doctrine/Connection.php |
Guards connection restoration but invalidates serialized table objects. |
lib/Doctrine/Collection.php |
Guards collection restoration but invalidates serialized record objects. |
controllers/settings.php |
Adds the deserialization class guard. |
Review details
Suppressed comments (1)
lib/Doctrine/Record.php:756
- The
objectcolumn path intentionally serializes its value inDoctrine_Record::serialize()(see lines 703-706), but this change now restores that payload with every class disabled. Any legitimate object-valued column therefore comes back as__PHP_Incomplete_Classinstead of the stored object. If object columns remain supported, use a validated class allowlist for this path; otherwise reject/disable the column type explicitly rather than silently changing its value type.
$this->_data[$k] = unserialize($this->_data[$k], array('allowed_classes' => false));
- Files reviewed: 6/6 changed files
- Comments generated: 4
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
bmfmancini
approved these changes
Sep 18, 2026
xmacan
approved these changes
Sep 18, 2026
Member
Author
|
Since we are modifying Doctrine in the near term, we have to take these things on. I don't like it, but it's one of the reasons that I wanted this one public archived. Not yet though. Let's attempt to give it more legs. |
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.
Updates
controllers/settings.php'sunserialize()call to:and audits the rest of the codebase for any other
unserialize()calls missing theallowed_classes => falseguard. Found and fixed 4 more:lib/Doctrine/Collection.phpandlib/Doctrine/Connection.php— internalunserialize()calls inside theirSerializable::unserialize()implementations.lib/Doctrine/Record.php— same, plus the per-columnunserialize()used when hydratingarray/objecttyped columns.lib/Doctrine/Parser/YamlSf/Inline.php—unserialize()of embedded!!php/object:YAML scalars.Also relaxed
tests/Security/UnserializeTest.php'ssettings.phpguard check to accept either quote style, since this line now uses double quotes.