{"id":48,"date":"2010-05-31T12:31:05","date_gmt":"2010-05-31T11:31:05","guid":{"rendered":"http:\/\/www.floyd.ch\/?p=48"},"modified":"2023-05-31T08:55:07","modified_gmt":"2023-05-31T07:55:07","slug":"new-injection-vector-for-php","status":"publish","type":"post","link":"https:\/\/www.floyd.ch\/?p=48","title":{"rendered":"New Injection Vector for PHP"},"content":{"rendered":"<p>I was thinking about a new injection vector for PHP. It exploits the possibility of arrays in GET\/POST parameters. I want to show it with a XSS example. Imagine the following code in a PHP script (e.g. index.php):<\/p>\n<pre class=\"brush: php; title: ; notranslate\" title=\"\">\r\n&lt;?php\r\n\/\/if $_GET&#x5B;'id'] is an array this means (string)$_GET&#x5B;'id'] is &quot;Array&quot;\r\n\/\/and obviously there is no &quot;&lt;&quot; in &quot;Array&quot;...\r\n\/\/strpos returns false if '&lt;' is not in $_GET&#x5B;'id']\r\nif(strpos($_GET&#x5B;'id'],&quot;&lt;&quot;) === false)\r\n   someLibraryEchoBack($_GET&#x5B;'id']);\r\nelse\r\n   echo &quot;&lt; is not allowed&quot;;\r\n\r\nfunction someLibraryEchoBack($value){\r\n   if(is_array($value)){\r\n      foreach($value as $key =&gt; $string)\r\n         echo $string;\r\n   }\r\n   else\r\n      echo $value;\r\n}\r\n?&gt;\r\n<\/pre>\n<p>The script would have the following output:<\/p>\n<table>\n<tbody>\n<tr>\n<td width=\"70%\"><strong>URI<\/strong><\/td>\n<td><strong>HTML Response<\/strong><\/td>\n<\/tr>\n<tr>\n<td>\/index.php?id=&lt;h2&gt;A&lt;<\/td>\n<td>< is not allowed<\/td>\n<\/tr>\n<tr>\n<td>\/index.php?id[]=&lt;h2&gt;A&lt;<\/td>\n<td>&lt;h2&gt;A&lt;\/h2&gt;<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>Anyone ever heard of this? At least you get some funny PHP errors for some web applications&#8230;<\/p>\n<p>Update: Of course <a href=\"https:\/\/www.exploit-db.com\/exploits\/9410\">there are already exploits<\/a> with this kind of attack.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I was thinking about a new injection vector for PHP. It exploits the possibility of arrays in GET\/POST parameters. I want to show it with a XSS example. Imagine the following code in a PHP script (e.g. index.php): &lt;?php \/\/if &hellip; <a href=\"https:\/\/www.floyd.ch\/?p=48\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[],"class_list":["post-48","post","type-post","status-publish","format-standard","hentry","category-web-penetration-testing"],"_links":{"self":[{"href":"https:\/\/www.floyd.ch\/index.php?rest_route=\/wp\/v2\/posts\/48","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.floyd.ch\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.floyd.ch\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.floyd.ch\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.floyd.ch\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=48"}],"version-history":[{"count":40,"href":"https:\/\/www.floyd.ch\/index.php?rest_route=\/wp\/v2\/posts\/48\/revisions"}],"predecessor-version":[{"id":1377,"href":"https:\/\/www.floyd.ch\/index.php?rest_route=\/wp\/v2\/posts\/48\/revisions\/1377"}],"wp:attachment":[{"href":"https:\/\/www.floyd.ch\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=48"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.floyd.ch\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=48"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.floyd.ch\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=48"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}