Skip to content

fix(command): restrict allowed_classes in CommandJob unserialize() to prevent RCE#41582

Open
DeepDiver1975 wants to merge 2 commits into
masterfrom
security/fix-commandjob-unserialize
Open

fix(command): restrict allowed_classes in CommandJob unserialize() to prevent RCE#41582
DeepDiver1975 wants to merge 2 commits into
masterfrom
security/fix-commandjob-unserialize

Conversation

@DeepDiver1975
Copy link
Copy Markdown
Member

Summary

  • CommandJob::run() called \unserialize($data) without allowed_classes, allowing PHP Object Injection if an attacker writes a crafted payload to oc_jobs.argument (e.g. via SQL injection or shared-hosting DB access)
  • __wakeup()/__destruct() gadget chains from Guzzle, Symfony, and Doctrine could achieve RCE as the web-server user
  • Fix: two-pass deserialization — Pass 1 extracts class name without instantiation, Pass 2 restricts to only the verified ICommand class

Security Impact

High (defense-in-depth) — exploitation requires prior DB write access; escalates that to full RCE

Test plan

  • Tests verify legitimate ICommand objects still execute correctly
  • Tests verify gadget payloads targeting non-ICommand classes are blocked
  • Run make test TEST_PHP_SUITE=lib/Command

🤖 Generated with Claude Code

… prevent RCE

CommandJob::run() called unserialize() without the allowed_classes
option, enabling PHP Object Injection via POP gadget chains (Guzzle,
Symfony, Doctrine) if an attacker can write to the oc_jobs table.

Replace bare unserialize() with a two-pass strategy: Pass 1 uses
allowed_classes=false to safely extract the stored class name without
instantiating anything. After verifying the class implements ICommand,
Pass 2 permits only that specific class, blocking all gadget chains.

Signed-off-by: Thomas Müller <thomas.mueller@owncloud.com>
Signed-off-by: Thomas Müller <1005065+DeepDiver1975@users.noreply.github.com>
@update-docs
Copy link
Copy Markdown

update-docs Bot commented Jun 5, 2026

Thanks for opening this pull request! The maintainers of this repository would appreciate it if you would create a changelog item based on your changes.

Signed-off-by: Thomas Müller <1005065+DeepDiver1975@users.noreply.github.com>
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.

1 participant