Re: com php-src: Fixed bug #71039 exec functions ignore length but look for NULL termination: ext/standard/exec.c
ext/standard/tests/general_functions/escapeshellarg_bug71039.phpt ext/standard/tests/general_functions/escapeshellcmd_bug71039.phpt
| From: | Yasuo Ohgaki | Date: | Tue, 02 Feb 2016 22:04:15 +0000 |
| Subject: | Re: com php-src: Fixed bug #71039 exec functions ignore length but look for NULL termination: ext/standard/exec.c ext/standard/tests/general_functions/escapeshellarg_bug71039.phpt ext/standard/tests/general_functions/escapeshellcmd_bug71039.phpt |
||
| References: | 1 2 3 | Groups: | php.cvs |
| Request: | Send a blank email to php-cvs+get-90916@lists.php.net to get a copy of this message | ||
Hi Anatol,
On Tue, Feb 2, 2016 at 11:13 PM, Anatol Belski <anatol.php@belski.net> wrote:
> Thanks for the comments. The decision for failing hard here was, that we don't really
> can't evaluate what to do. If you look at the initial issue in the ticket, passing string
> "bad\0worse" can be dangerous as internally we don't know what is safe - fe to stop
> parsing at \0, or to glue the both parts together, or whatever. Yeah, external inputs are dangerous
> and we cannot prevent anyone to accept them. So E_WARNING were a nogo. E_RECOVERABLE_ERROR (or an
> exception somewhen) could come into question, just such invalid inputs are actually an unusual case
> and again some situation that cannot be evaluated, so it was decided just for more safety. As what
> happens if user catches the error and has an empty sting that is expected to build a composite
> command (which possibly could build some erroneous dangerous command)? Another discussion about this
> happened also in #71270.
I agree that handling shell command escape is extremely hard and
escapeshellcmd() should never used for external inputs,
escapeshellarg() is far better than escapeshellcmd(), but it is
dangerous. I've written at least 4 blog articles that conclude "User
must validate inputs before passing them to commands".
As you know, Windows handles command parameter differently by rather
defacto standard parameter parsing in programs. Perfect escape is
simply not feasible not only by this, but also other reasons. (UNIX OS
has too many shells who knows every valiant of proper escaping)
However, E_ERROR is too much because I would like to have last chance
to show meaningful error page/message by catching errors from them.
Users should know E_RECOVERABLE_ERROR must result in execution
termination. (I never pass unvalidated inputs to them, but users do)
For this reason, E_RECOVERABLE_ERROR should be used for these. IMHO.
Teaching users hard way is possible option, though.
Anyway, it seems I or other person must implement for PHP 7.1
execv/execve version of exec() ASAP.
https://bugs.php.net/bug.php?id=68599
Since I have limited knowledge for Windows, you would be the right
person for this task :) Please feel free to take over the bug report.
Regards,
--
Yasuo Ohgaki
yohgaki@ohgaki.net