All Input is Evil
Tuesday, November 18th, 2008Subscribe To Our Feed | Follow Us On Twitter | Get Updates on Email
In my previous posts, I have been emphasizing on validating Integer and String inputs by putting various checks in place. But now, I’ll suggest you to consider any type of input to your application or software as “Evil”. Consider the following two rules for any input data:
- All input is evil until proven otherwise.
- Data must be validated as it crosses the boundary between untrusted and trusted environments.
Till now, I explained how to validate Integer and String data, but today, I’ll explain what is to be validated in the input data. First things first, Look for valid data and reject everything else. You should deny all access until you are sure that the input in the request is valid. You should look for valid data and not look for invalid data for two reasons:
- There might be more than one valid way to represent the data.
-
- For example: a word “Rose” can be represented in many ways like “ROSE”, “rose”, “R%6fse”, “RoSE” et cetera. All the mentioned words are the variations of single word “Rose” and they are valid variations. But, This can definitely be a problem for an application.
-
- You might miss an invalid data pattern.
Consider the following code: (more…)
© Safer Code | All Input is Evil
|
Liked this post? Get FREE Updates Subscribe to RSS feed |