Secure Coding mailing list archives

Some Interesting Topics arising from the SANS/CWE Top 25


From: brian at fortify.com (Brian Chess)
Date: Wed, 14 Jan 2009 21:25:45 -0800

In the one sense, we are talking about validating user input, which
mostly needs to concern itself with adhering to business requirements.
This meaning is not very important for security, but the other one,
validating data before something is done with it, is.

Yes, two forms of validation are required.  If you hang around with the
compliers crowd for too long, you?ll call them syntax validation and
semantic validation.
Syntax: ?the input must be an integer?
Semantics: ?the input must identify an account held in your name.?

It?s often possible and even desirable to perform syntax checking not long
after a program accepts its input.  You can bottleneck a program and make
sure all input runs through a syntax validation layer.  Not so with semantic
checks.  In many cases they are so closely related to the program logic that
ripping them out and creating an ?semantic validation layer? would
essentially double the length of the program and create a maintenance
nightmare.

So which form of input validation is security input validation?  Both!  In
most cases you can?t afford to skip either one.  Bad or absent syntax checks
lead generic kinds of problems like SQL injection.  Bad or absent semantic
checks lead to problems that are often more specific to the application at
hand.  

There?s a lot to say about input validation.  Jacob West and I wrote devoted
a full chapter to it in Secure Programming with Static Analysis
(http://www.amazon.com/dp/0321424778), but we found that the material
refused to stay in its cage?input validation got a lot of airtime when we
talked about the Web, when we talked about privileged programs, and then
again when we got around to the litany of common errors in C/C++ programs.

Brian


On 1/14/09 2:02 PM, "Ivan Ristic" <ivan.ristic at gmail.com> wrote:

On Wed, Jan 14, 2009 at 12:41 AM, Greg Beeley <Greg.Beeley at lightsys.org>
wrote:
Steve I agree with you on this one.  Both input validation and output
encoding
are countermeasures to the same basic problem...

I'd like to offer a different view for your consideration, which is
that input validation and output encoding actually don't have anything
to do with security. Those techniques are essential software building
blocks. While it is true that omission to use these techniques often
causes security issues, that only means such programs are insecure in
addition to being defective. I think that it's inherently wrong to
associate input validation and output encoding with security. Fix the
defects and the security issues will go away. On the other hand, if
you only fix the security issues you may be left with a number of
defects on your hands.

Input validation layers should focus on accepting only valid data (per
business requirements), while code that transmits data across system
boundaries should focus on using the exchange and communication
protocols correctly.

Actually, now that I think about it more, I think we are struggling
with the term input validation because the term has been overloaded.
In the one sense, we are talking about validating user input, which
mostly needs to concern itself with adhering to business requirements.
This meaning is not very important for security, but the other one,
validating data before something is done with it, is. If you take a
web application for example, you would ideally verify that all user
submitted data adheres to your business requirements.

--
Ivan Ristic
_______________________________________________
Secure Coding mailing list (SC-L) SC-L at securecoding.org
List information, subscriptions, etc - http://krvw.com/mailman/listinfo/sc-l
List charter available at - http://www.securecoding.org/list/charter.php
SC-L is hosted and moderated by KRvW Associates, LLC (http://www.KRvW.com)
as a free, non-commercial service to the software security community.
_______________________________________________


-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://krvw.com/pipermail/sc-l/attachments/20090114/59953dd8/attachment.html 


Current thread: