Skip to content

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

Merged
artonge merged 1 commit into
nextcloud:masterfrom
elicpeter:patch-1
Jun 11, 2026
Merged

fix(repair): restrict unserialize() in RemoveBrokenProperties#59979
artonge merged 1 commit into
nextcloud:masterfrom
elicpeter:patch-1

Conversation

@elicpeter

@elicpeter elicpeter commented Apr 28, 2026

Copy link
Copy Markdown
Contributor
  • 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

@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

@Altahrim Altahrim left a comment

Copy link
Copy Markdown
Collaborator

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

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

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.

@github-actions

Copy link
Copy Markdown
Contributor

Hello there,
Thank you so much for taking the time and effort to create a pull request to our Nextcloud project.

We hope that the review process is going smooth and is helpful for you. We want to ensure your pull request is reviewed to your satisfaction. If you have a moment, our community management team would very much appreciate your feedback on your experience with this PR review process.

Your feedback is valuable to us as we continuously strive to improve our community developer experience. Please take a moment to complete our short survey by clicking on the following link: https://cloud.nextcloud.com/apps/forms/s/i9Ago4EQRZ7TWxjfmeEpPkf6

Thank you for contributing to Nextcloud and we hope to hear from you soon!

(If you believe you should not receive this message, you can add yourself to the blocklist.)

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>
This was referenced Jun 5, 2026
@susnux susnux added the community pull requests from community label Jun 9, 2026
@susnux susnux modified the milestones: Nextcloud 34.0.1, Nextcloud 35 Jun 9, 2026
@artonge artonge merged commit 421e4de into nextcloud:master Jun 11, 2026
164 of 178 checks passed
@welcome

welcome Bot commented Jun 11, 2026

Copy link
Copy Markdown

Thanks for your first pull request and welcome to the community! Feel free to keep them coming! If you are looking for issues to tackle then have a look at this selection: https://github.com/nextcloud/server/issues?q=is%3Aopen+is%3Aissue+label%3A%22good+first+issue%22

@kesselb

kesselb commented Jun 11, 2026

Copy link
Copy Markdown
Contributor

/backport to stable34

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug community pull requests from community feedback-requested

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants