Right, security implications are one of the reasons why I've held back from proposing Shell Command. The lack of cross platform support is also a pain. This suggestion shares both of those problems.
Having dealt with long running child processes lately, I can also say that producing output line-by-line would be on my personal list of requirements.
So, yeah, interesting idea, but this is still an area that needs a lot of exploration on PyPI before we select an answer for the stdlib.
--
Sent from my phone, thus the relative brevity :)
What does this "shell processing" involve to understand what to turn off?
Why there is no way to turn off "shell processing"?
What's the primary reason that it is impossible to be turned off?
>> 3. shutil.run() is predictable and consistent - its arguments are not
>> dependent on each other, their combination doesn't change the function
>> behavior over and over requiring you iterate over the documentation
>> and warnings again and again
>
> As proposed, it certainly provides a predictable and consistent
> vulnerability to code injection attacks.
suprocess.* with shell=True provides the same entrypoint for injection
attacks, and security through obscurity doesn't help here. People
still use shell=True, because that's sometimes the only way to execute
external utilities properly. Even my synapses were silent when I
reviewed and used shell=True for Rietveld upload script and Spyder
IDE.
What will help is a better simple explanation in a prominent place,
with an example that people can really remember instead of frightening
them with warnings. People will ignore warning eventually, and after
endless experiments will subprocess.* params mess will just leave
shell=True because it works (I did so).
No sane web developer will use subprocess calls on server side at all.
Regardless of shell=True or not. For example, how can I be sure that
Graphviz is save from exploit through malicious input? No sane
developer will run shell script on a web side either. For those who
still want - there will be this simple explanation right on the
shutil.run() page - with link to proper vulnerability analysis instead
of uncertainty inducting warning.
shutil.run() is aimed for local operations.
>> 4. shutil.run() is the correct next level API over subprocess base
>> level. subprocess executes external process - that is its role, but
>> automatic ability to execute external process inside another external
>> process (shell) looks like a hack to me. Practical, but still a hack.
>
> It's only correct if you are in an environment where you don't care
> about security. If you care about security, you can't use it. If we're
> going to add yet another system() replacement, let's at least try and
> make it secure.
I am all ears how to make shutil.run() more secure. Right now I must
confess that I don't even realize.how serious is this problems, so if
anyone can came up with a real-world example with explanation of
security concern that could be copied "as-is" into documentation, it
will surely be appreciated not only by me.
anatoly techtonik wrote:Start here:
I am all ears how to make shutil.run() more secure. Right now I must
confess that I don't even realize.how serious is this problems, so if
anyone can came up with a real-world example with explanation of
security concern that could be copied "as-is" into documentation, it
will surely be appreciated not only by me.
http://cwe.mitre.org/top25/index.html
Code injection attacks include two of the top three security vulnerabilities, over even buffer overflows.
One sub-category of code injection:
OS Command Injection
http://cwe.mitre.org/data/definitions/78.html
On Thu, May 24, 2012 at 6:24 AM, geremy condra <deba...@gmail.com> wrote:Great links. Thanks. Do they still too generic to be placed in docs?
> On Wed, May 23, 2012 at 7:00 PM, Steven D'Aprano <st...@pearwood.info>
> wrote:
>>
>> anatoly techtonik wrote:
>>
>>> I am all ears how to make shutil.run() more secure. Right now I must
>>> confess that I don't even realize.how serious is this problems, so if
>>> anyone can came up with a real-world example with explanation of
>>> security concern that could be copied "as-is" into documentation, it
>>> will surely be appreciated not only by me.
>>
>>
>> Start here:
>>
>> http://cwe.mitre.org/top25/index.html
>>
>> Code injection attacks include two of the top three security
>> vulnerabilities, over even buffer overflows.
>>
>> One sub-category of code injection:
>>
>> OS Command Injection
>> http://cwe.mitre.org/data/definitions/78.html
Sorry, don't have too much time to watch it right now. Any specific
>
> I talked about this in my pycon talk this year. It's easy to avoid and
> disastrous to get wrong. Please don't do it this way.
slides, ideas or exceprts?
--
anatoly t.
On Mon, Jun 04, 2012 at 11:00:34PM -0700, geremy condra wrote:I am interested in more details. Would this make a good How (Not) To for
> The main idea was just that by combining a bit of awareness of common
> security anti-patterns (like this one) with a good test regimen and some
> script kiddie tools you can protect yourself from a lot of common
> vulnerabilities without being a security guru. I demonstrated how that
> process works on something fairly similar to this, but if you're interested
> in more details I'm happy to blather on or dredge up my slides.
the documentation?