TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Subprocesses are generally bad news

32 pointsby tbodtabout 7 years ago

6 comments

StefanKarpinskiabout 7 years ago
I had similar thoughts some time ago but came to a very different conclusion: anything the shell can do a programming language could do just as well, given the right interface. The fact that languages don&#x27;t make it easy to spawn subprocesses safely doesn&#x27;t mean that they couldn&#x27;t do so. The right solution is making it both convenient <i>and</i> safe to do shell-like things from within a real programming language. So I made sure that Julia does this right:<p><a href="https:&#x2F;&#x2F;julialang.org&#x2F;blog&#x2F;2012&#x2F;03&#x2F;shelling-out-sucks" rel="nofollow">https:&#x2F;&#x2F;julialang.org&#x2F;blog&#x2F;2012&#x2F;03&#x2F;shelling-out-sucks</a><p><a href="https:&#x2F;&#x2F;julialang.org&#x2F;blog&#x2F;2013&#x2F;04&#x2F;put-this-in-your-pipe" rel="nofollow">https:&#x2F;&#x2F;julialang.org&#x2F;blog&#x2F;2013&#x2F;04&#x2F;put-this-in-your-pipe</a>
评论 #16819186 未加载
评论 #16817753 未加载
userbinatorabout 7 years ago
<i>&quot;I&#x27;ll just escape it&quot; is a typical and yet unacceptable response to this.</i><p>There seems to be some sort of &quot;cult&quot; (for lack of better term) around this mentality of &quot;it&#x27;s too hard so don&#x27;t do it&quot;, which unfortunately only makes things worse overall. Escaping rules are well-defined (they must be, by necessity), and sooner or later you&#x27;re going to have to do something involving it; not to mention the important superset of things to keep in mind when writing code, of which escaping is only a fraction: the general principle of &quot;consider <i>all</i> input&quot;. Always assume that all 256 values of a byte can and will show up in any external input, and plan accordingly.
评论 #16817582 未加载
评论 #16817607 未加载
评论 #16817708 未加载
ggmabout 7 years ago
Because the shell is a generalized engine for executing things, and because magic defines textfiles as candidate executables nominating either the shell or a shell-exec binary to interpret them, and because system() jacks all of this to say you can invoke a shell with all its awesome to invoke scripts which invoke a binary to parse them.<p>If the shell was only rsh, and if the set of binaries you can invoke was constrained, and if the network and system calls were accessed through strace() barriers which limited what you could do.. We might have less problems. Except that in the end, people don&#x27;t code or script for secure execution so the context of &#x27;what harm can I do from here&#x27; turns out to be a lot wider than many people think.
cafxxabout 7 years ago
Hello inetd, my old friend<p>I&#x27;ve come to talk with you again<p>Because bugs softly creeping<p>Pwned my server while I was sleeping...
AstralStormabout 7 years ago
The premise is faulty. Subprocesses are fine, it is the POSIX shell that should be avoided. Or any interpreted language. Smallest tool for the job.<p>Use exec* calls, right options for your process handling class and there is no problem.<p>As a bonus feel free to spawn&#x2F;fork your current application.<p>Linking pipes and file descriptors is also not that hard. (Though they are a cruddy that may be nicer to wrap in something like 0mq.)
codemacabout 7 years ago
This is sanitizing input, yes?<p>Didn&#x27;t seem to be too specific to subprocesses, just some places where folks use input directly.