5.SOFTWARE AND WEB APPLICATION SECURITY
• The rapid development of web applications and their accessibility via the Internet to a potentially large pool of attackers mean these applications are particularly vulnerable.
• Often, developers develop the web application with insufficient awareness of security concerns.
• Safe programming practices should always be followed, even for seemingly innocuous programs.
6.BASIC SECURE CODING PRACTICES
• Handling program input
• Writing safe program code
• Interacting with the operating system and other programs
• Handling program output
• For more practices, see
7.HANDLING PROGRAM INPUT
• Incorrect handling of program input is one of the most common failings in software security.
• Program input refers to any source of data that originates outside the program and whose value is not explicitly known by the programmer when the code was written.
• This includes:
– Input size and buffer overflow
– Interpretation of program input
– Validating input syntax
– Input fuzzing
7.3.1 INPUT SIZE AND BUFFER OVERFLOW
• When reading or copying input from some source, programmers often make assumptions about the maximum expected size of input such as input would not exceed a few lines in size.
• As a result, the programmer allocates a certain size of buffer to hold the input.
• If it does exceed the size of the buffer, then a buffer overflow occurs, which can potentially compromise the execution of the program.
• Writing code that is safe against buffer overflows requires a mindset that regards any input as dangerous and processes it in a manner that does not expose the program to danger.
• With respect to the size of input, this means either using a dynamically sized buffer to ensure that sufficient space is available or processing the input in buffer sized blocks.
• Even if dynamically sized buffers are used, care is needed to ensure that the space requested does not exceed available memory.
• Should this occur, the program must handle this error gracefully.
7.3.2 INTERPRETATION OF PROGRAM INPUT