<?xml version="1.0" encoding="windows-1252"?>
<node id="1011666" title="Re: Unwanted parameter when executing CGI scripts" created="2013-01-04 11:12:02" updated="2013-01-04 11:12:02">
<type id="11">
note</type>
<author id="647953">
sundialsvc4</author>
<data>
<field name="doctext">
&lt;p&gt;
It also occurs to me to wonder, and with considerable alarm, &amp;ldquo;exactly what is it about your present algorithm which makes you &lt;em&gt;care&lt;/em&gt; that an &amp;lsquo;extra&amp;rsquo; parameter value is appearing in the data?&amp;rdquo; &amp;nbsp; Of particular concern to me is that perhaps the software is iterating through the parameters given and attempting to do something with them &amp;ldquo;no matter what they are,&amp;rdquo; on the very naïve and very dangerous assumption that only the &amp;ldquo;expected&amp;rdquo; parameter-names could actually be there. &amp;nbsp; (PHP was most-notorious for this in its earliest days, when it would &amp;ldquo;helpfully&amp;rdquo; introduce every POST/GET variable that it saw, right into the variable pool. &amp;nbsp; &amp;ldquo;Helpful&amp;rdquo; indeed it was, if one is not thinking of malice, and of course it didn&amp;rsquo;t last long. &amp;nbsp; But there are still probably some vulnerable web-sites out there that are still being hacked because of it.) &amp;nbsp; Your application should &lt;em&gt;know&lt;/em&gt; exactly what variable-names it might consider. &amp;nbsp; It should look only for submitted variables under those names, at the exclusion of any and all others. &amp;nbsp; It should, furthermore, validate each of these, using a regular-expression &lt;i&gt;(say)&lt;/i&gt;, before accepting any of them. &amp;nbsp; Never allow the user (which could well actually be a malicious &amp;ldquo;bot!&amp;rdquo;) to &amp;ldquo;stuff&amp;rdquo; anything into your application&amp;rsquo;s brain.
&lt;/p&gt;&lt;p&gt;
&lt;i&gt;(Edit:&lt;/i&gt; &amp;nbsp; Parameter validation should always occur in &lt;u&gt;two&lt;/u&gt; places. &amp;nbsp; First, the user interface should filter out typographic errors before attempting to submit anything to the host. &amp;nbsp; But second, the host should validate everything it receives, both syntactically then semantically. &amp;nbsp; I am of the opinion that, if anything &lt;em&gt;is&lt;/em&gt; found to be wrong in second-stage verification, the host perhaps should throw-out all of it, and perhaps using &lt;tt&gt;400 Bad Request&lt;/tt&gt;. &amp;nbsp; Ditto the presence of &amp;ldquo;unexpected&amp;rdquo; parameters in the input, on the rationale that it is &amp;ldquo;a bug, at best&amp;rdquo; for them to be present. &amp;nbsp; The client-side validation is for user convenience (and to reduce network bandwidth); the second is for the server&amp;rsquo;s own protection &lt;em&gt;and&lt;/em&gt; to facilitate the detection of legitimate errors &amp;ldquo;somewhere&amp;rdquo; in the software. &amp;nbsp; (Even in 100%-innocuous scenarios, the hardest thing about troubleshooting any problem is knowing that a problem exists.)
&lt;/p&gt;</field>
<field name="root_node">
1011634</field>
<field name="parent_node">
1011634</field>
</data>
</node>
