Skip to content

fix(repair): restrict unserialize() in RemoveBrokenProperties#59979

Open
elicpeter wants to merge 2 commits intonextcloud:masterfrom
elicpeter:patch-1
Open

fix(repair): restrict unserialize() in RemoveBrokenProperties#59979
elicpeter wants to merge 2 commits intonextcloud:masterfrom
elicpeter:patch-1

Conversation

@elicpeter
Copy link
Copy Markdown

@elicpeter elicpeter commented Apr 28, 2026

  • Resolves: #

Summary

RemoveBrokenProperties::run() calls unserialize() on the propertyvalue column without restricting allowed_classes. The result is only compared against false to identify broken rows, so no class instantiation is needed. As written though, magic methods (__wakeup/__destruct) on any class referenced by the serialized payload still execute.

The runtime decoder for the same column already restricts deserialization. See apps/dav/lib/DAV/CustomPropertiesBackend.php:675-678, which passes ['allowed_classes' => self::ALLOWED_SERIALIZED_CLASSES]. This change applies the same hardening to the repair step. It uses ['allowed_classes' => false] since the unserialized value is never used, only its truthiness is checked.

No behavior change for valid or broken rows.

Found while testing an in-development static analysis tool I'm building against open-source PHP codebases.

TODO

  • ...

Checklist

AI (if applicable)

  • The content of this PR was partly or fully generated using AI

RemoveBrokenProperties::run() calls unserialize() on the property value column without restricting allowed_classes. The result is only compared against false to identify broken rows, so no class instantiation is needed. As written though, magic methods (__wakeup/__destruct) on any class referenced by the serialized payload still execute.

The runtime decoder for the same column already restricts deserialization. See apps/dav/lib/DAV/CustomPropertiesBackend.php:675-678, which passes ['allowed_classes' => self::ALLOWED_SERIALIZED_CLASSES]. This change applies the same hardening to the repair step. It uses ['allowed_classes' => false] since the unserialized value is never used, only its truthiness is checked.

No behavior change for valid or broken rows.  

Signed-off-by: Eli Peter <54954007+elicpeter@users.noreply.github.com>
@elicpeter elicpeter requested a review from a team as a code owner April 28, 2026 16:23
@elicpeter elicpeter requested review from Altahrim, ArtificialOwl, icewind1991 and salmart-dev and removed request for a team April 28, 2026 16:23
Copy link
Copy Markdown
Collaborator

@Altahrim Altahrim left a comment

Choose a reason for hiding this comment

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

Looks good, thank you!

@kesselb kesselb requested a review from Copilot April 30, 2026 14:57
@kesselb kesselb added this to the Nextcloud 34 milestone Apr 30, 2026
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Hardens the DAV properties repair step by preventing PHP object instantiation during unserialize() when scanning properties.propertyvalue for broken serialized payloads.

Changes:

  • Updates RemoveBrokenProperties::run() to call unserialize(..., ['allowed_classes' => false]) when checking whether propertyvalue is broken.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

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.

4 participants