|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2006-01-10 12:20 UTC] tony2001@php.net
[2006-01-10 12:31 UTC] djmaze at cpgnuke dot com
[2006-01-10 12:37 UTC] tony2001@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Nov 02 13:00:01 2025 UTC |
Description: ------------ When using preg_replace() with the 'e' modifier you can exploit variables since the $ sign doesn't get backslashed. Tested on several PHP versions both 4.x and 5.x Reproduce code: --------------- <?php error_reporting(E_ALL); $exploited = 'my password'; $exploit = '[php]$exploited[/php]'; function highlight_php($txt) { return "<pre>$txt</pre>"; } echo preg_replace('#\[PHP\](.*?)\[/PHP\]#sie', 'highlight_php("\\1")', $exploit); # exploited echo preg_replace('#\[PHP\](.*?)\[/PHP\]#sie', 'highlight_php(\'\\1\')', $exploit); # no exploit ?> Expected result: ---------------- <pre>$exploited</pre> Actual result: -------------- <pre>my password</pre>