fix(storage): allow nested mail classes in rule unserialize - #38
Merged
Merged
Conversation
The ZDI-20-1051 allowed_classes lockdown omitted Horde_Mail_Rfc822_* objects nested in Ingo_Rule_Addresses, causing __PHP_Incomplete_Class and TypeError on count() when opening whitelist/blacklist/vacation. Centralize the allowlist, add the missing mail classes, harden Addresses accessors, and add a regression test. Fixes #36
There was a problem hiding this comment.
Pull request overview
This PR fixes rule loading failures caused by the restricted unserialize() allowlist introduced in 4.0.0-RC3 by explicitly permitting the nested Horde_Mail_Rfc822_* objects embedded in address-based rules, and by guarding address accessors against incomplete/unexpected unserialized state.
Changes:
- Centralizes the
unserialize()allowed_classeslist inIngo_Storage::unserializeAllowedClasses()and reuses it for prefs and Mongo-backed rule loading. - Hardens
Ingo_Rule_Addressesto safely handle cases where the internal address list is not aHorde_Mail_Rfc822_List(e.g., incomplete class instances). - Adds a regression unit test to verify allowlist completeness and that whitelist rules round-trip without losing addresses.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
lib/Storage.php |
Introduces a single source of truth for the unserialize allowlist, including nested RFC822 mail object classes. |
lib/Storage/Prefs.php |
Switches prefs-backed rule loading to use the centralized allowlist. |
lib/Storage/Mongo.php |
Switches Mongo-backed rule loading to use the centralized allowlist. |
lib/Rule/Addresses.php |
Adds a defensive accessor to ensure _addr is always a usable Horde_Mail_Rfc822_List. |
test/Ingo/Unit/StorageUnserializeTest.php |
Adds regression coverage for whitelist round-trip and allowlist contents. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Address review feedback: match the existing unit suite base class instead of extending PHPUnit\\Framework\\TestCase directly.
ralflang
added a commit
that referenced
this pull request
Jul 18, 2026
Release version 4.0.1 Merge pull request #38 from horde/fix/unserialize-mail-allowed-classes test(storage): extend Ingo_Unit_TestBase in unserialize test fix(storage): allow nested mail classes in rule unserialize Merge pull request #37 from horde/fix/form-v3-deprecation-warnings fix(ingo): remove deprecated ->type indirection in spam form fix(ingo): remove deprecated getInfo() $info argument in vacation form
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
allowed_classeslockdown.Horde_Mail_Rfc822_*objects insideIngo_Rule_Addresseswere missing from the unserialize allowlist, so$_addrbecame__PHP_Incomplete_Class.Fixes #36
Motivation
Ingo 4.0.0-RC3 restricted
unserialize()to Ingo rule classes only. Address-based rules embedHorde_Mail_Rfc822_List/Horde_Mail_Rfc822_Address, which were not listed. Script generation then calledcount($rule)and crashed.Changes
Ingo_Storage::unserializeAllowedClasses()including the nested mail classes; use it from Prefs and Mongo storage.Ingo_Rule_Addressesaccessors against incomplete address lists.StorageUnserializeTest.ZDI gadget classes remain blocked; only the classes already present in legitimate serialized rule data are allowed.
Test plan
vendor/bin/phpunit --bootstrap vendor/autoload.php vendor/horde/ingo/test/Ingo/Unit/StorageUnserializeTest.php