svn: /phpdoc/en/trunk/reference/exec/functions/ escapeshellcmd.xml
| From: | Ferenc Kovacs | Date: | Sat, 19 Nov 2011 23:04:42 +0000 |
| Subject: | svn: /phpdoc/en/trunk/reference/exec/functions/ escapeshellcmd.xml | ||
| Groups: | php.doc.cvs | ||
| Request: | Send a blank email to doc-cvs+get-9056@lists.php.net to get a copy of this message | ||
tyrael Sat, 19 Nov 2011 23:04:42 +0000
Revision: http://svn.php.net/viewvc?view=revision&revision=319565
Log:
fixing #60116
Bug: https://bugs.php.net/60116 (Feedback) escapeshellcmd()
cannot escape the chars which causes shell injection.
Changed paths:
U phpdoc/en/trunk/reference/exec/functions/escapeshellcmd.xml
Modified: phpdoc/en/trunk/reference/exec/functions/escapeshellcmd.xml
===================================================================
--- phpdoc/en/trunk/reference/exec/functions/escapeshellcmd.xml 2011-11-19 22:17:43 UTC (rev 319564)
+++ phpdoc/en/trunk/reference/exec/functions/escapeshellcmd.xml 2011-11-19 23:04:42 UTC (rev 319565)
@@ -63,14 +63,12 @@
<programlisting role="php">
<![CDATA[
<?php
-$e = escapeshellcmd($userinput);
+// We allow arbitrary number of arguments intentionaly here.
+$command = './configure '.$_POST['configure_options'];
+
+$escaped_command = escapeshellcmd($command);
-// here we don't care if $e has spaces
-system("echo $e");
-$f = escapeshellcmd($filename);
-
-// and here we do, so we use quotes
-system("touch \"/tmp/$f\"; ls -l \"/tmp/$f\"");
+system($escaped_command);
?>
]]>
</programlisting>
@@ -78,6 +76,17 @@
</para>
</refsect1>
+ <refsect1 role="notes">
+ <warning xmlns="http://docbook.org/ns/docbook">
+ <para>
+ <function>escapeshellcmd</function> should be used on the whole
+ command string, and it still allows the attacker to pass
+ arbitrary number of arguments. For escaping a single argument
+ <function>escapeshellarg</function> should be used instead.
+ </para>
+ </warning>
+ </refsect1>
+
<refsect1 role="seealso">
&reftitle.seealso;
<para>