Skip to content

fix(storage): allow nested mail classes in rule unserialize - #38

Merged
TDannhauer merged 2 commits into
FRAMEWORK_6_0from
fix/unserialize-mail-allowed-classes
Jul 16, 2026
Merged

TDannhauer merged 2 commits into
FRAMEWORK_6_0from
fix/unserialize-mail-allowed-classes

Conversation

@TDannhauer

Copy link
Copy Markdown
Contributor

Summary

  • Fix TypeError when opening whitelist/blacklist/vacation (and other address rules) after the ZDI-20-1051 allowed_classes lockdown.
  • Nested Horde_Mail_Rfc822_* objects inside Ingo_Rule_Addresses were missing from the unserialize allowlist, so $_addr became __PHP_Incomplete_Class.

Fixes #36

Motivation

Ingo 4.0.0-RC3 restricted unserialize() to Ingo rule classes only. Address-based rules embed Horde_Mail_Rfc822_List / Horde_Mail_Rfc822_Address, which were not listed. Script generation then called count($rule) and crashed.

Changes

  • Add Ingo_Storage::unserializeAllowedClasses() including the nested mail classes; use it from Prefs and Mongo storage.
  • Harden Ingo_Rule_Addresses accessors against incomplete address lists.
  • Add regression test 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
  • With prefs-backed Ingo rules that include whitelist/blacklist addresses, open Whitelist, Blacklist, and Vacation without error
  • Confirm sieve/script preview still lists whitelisted addresses

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

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_classes list in Ingo_Storage::unserializeAllowedClasses() and reuses it for prefs and Mongo-backed rule loading.
  • Hardens Ingo_Rule_Addresses to safely handle cases where the internal address list is not a Horde_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.

Comment thread test/Ingo/Unit/StorageUnserializeTest.php Outdated
Address review feedback: match the existing unit suite base class
instead of extending PHPUnit\\Framework\\TestCase directly.
@TDannhauer
TDannhauer merged commit 0b05bda into FRAMEWORK_6_0 Jul 16, 2026
1 check failed
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
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.

Error trying to access/edit rules, script

2 participants