<story><title>Exec($_GET</title><url>https://github.com/search?q=exec%28%24_GET&amp;ref=cmdform&amp;type=Code</url></story><parent_chain><item><author>deckiedan</author><text>As a theoretical aside, I wonder if it&amp;#x27;d be possible to have a typesystem based solution to these kinds of problems - where variables coming from the user (or from another program) are considered &amp;#x27;unsafe&amp;#x27; and the compiler refuses to let exec() or whatever use them until they&amp;#x27;ve been through a cleaner&amp;#x2F;tester of some kind...  (OK, I know PHP doesn&amp;#x27;t have a compiler as such - but a static checker of some kind could work the same...)</text></item></parent_chain><comment><author>gst</author><text>&lt;a href=&quot;https://en.wikipedia.org/wiki/Taint_checking&quot; rel=&quot;nofollow&quot;&gt;https:&amp;#x2F;&amp;#x2F;en.wikipedia.org&amp;#x2F;wiki&amp;#x2F;Taint_checking&lt;/a&gt;</text></comment>
<story><title>Exec($_GET</title><url>https://github.com/search?q=exec%28%24_GET&amp;ref=cmdform&amp;type=Code</url></story><parent_chain><item><author>deckiedan</author><text>As a theoretical aside, I wonder if it&amp;#x27;d be possible to have a typesystem based solution to these kinds of problems - where variables coming from the user (or from another program) are considered &amp;#x27;unsafe&amp;#x27; and the compiler refuses to let exec() or whatever use them until they&amp;#x27;ve been through a cleaner&amp;#x2F;tester of some kind...  (OK, I know PHP doesn&amp;#x27;t have a compiler as such - but a static checker of some kind could work the same...)</text></item></parent_chain><comment><author>Argorak</author><text>On the practical side, Ruby (MRI specifically) has such a system ($SAFE), that taints certain objects (e.g. those gained by IO) and only allows you to use them in certain fashions (e.g. only after explicit handling).&lt;p&gt;It&amp;#x27;s leaky as hell, because all components have to get the marking right. Also, not all Objects have equal trust levels. Objects created due to a HTTP request (GET-Parameters) should certainly be tainted, but how about Object read through IO - do we trust out filesystem? Do we trust the database? Thats more of an architectural decision.&lt;p&gt;In the end, the problem comes down to this: you have to whitelist the world and everything you miss is an error.</text></comment>