Docsity

Understanding Software Security: Common Vulnerabilities & Defensive Programming, Slides of Computer Security

Partial preview of the text

Download Understanding Software Security: Common Vulnerabilities & Defensive Programming and more Slides Computer Security in PDF only on Docsity!

Lecture 17

Software Security

Secure programs

  • Security implies some degree of trust that the

program enforces expected

  • confidentiality,
  • integrity, and
  • availability.
  • How can we look at software component and

assess its security?

Software Security Issues

  • many vulnerabilities result from poor

programming practices

  • consequence from insufficient checking and

validation of data and error codes

  • awareness of these issues is a critical initial step in writing more secure program code
  • software error categories:
  • insecure interaction between components
  • risky resource management
  • porous defenses

CWE/SANS

Top 25 Most

Dangerous Software Errors

Software Quality and Reliability

  • concerned with accidental failure of program
    • as a result of some theoretically random, unanticipated input, system interaction, or use of incorrect code
  • improve using structured design and testing to

identify and eliminate as many bugs as possible

from a program

  • concern is how often they are triggered
  • failures are expected to follow some form of

probability distribution

Software Security

  • attacker chooses probability distribution,

specifically targeting bugs that result in a

failure that can be exploited by the attacker

  • triggered by inputs that differ dramatically

from what is usually expected

  • unlikely to be identified by common testing

approaches

Defensive Programming

  • also called secure programming
  • a form of defensive design to ensure continued

function of software despite unforeseen usage

  • requires attention to all aspects of program

execution, environment, and type of data it

processes

  • assume nothing, check all potential errors
  • programmer never assumes a particular function

call or library will work as advertised so handles it

in the code

Abstract Program Model

Security by Design

  • security and reliability are common design

goals in most engineering disciplines

  • software development not as mature
    • much higher failure levels tolerated
  • despite having a number of software

development and quality standards

  • main focus is general development lifecycle
  • increasingly identify security as a key goal

Handling Program Input

  • incorrect handling is a very common failing
  • input is any source of data from outside and

whose value is not explicitly known by the

programmer when the code was written

  • must identify all data sources
  • explicitly validate assumptions on size and

type of values before use

Interpretation of Program Input

  • program input may be binary or text
    • binary interpretation depends on encoding and is usually application specific
  • there is an increasing variety of character sets

being used

  • care is needed to identify just which set is being used and what characters are being read
  • failure to validate may result in an exploitable

vulnerability

Injection Attacks

  • flaws relating to invalid handling of input data,
    • specifically when program input data can accidentally or deliberately influence the flow of execution of the program
  • most often occur in scripting languages
    • encourage reuse of other programs and system utilities where possible to save coding effort
    • often used as Web CGI scripts

Safety Extension to Perl Finger CGI Script

  • adds a test that ensures user input contains

just alphanumeric characters

  • if it doesn’t, the script terminates with an error message specifying the supplied input contained illegal characters

SQL Injection Attack

  • user supplied input is used to construct a SQL

request to retrieve information from a database

  • vulnerability is similar to command injection
    • difference is that SQL metacharacters are used rather than shell metacharacters
    • to prevent this type of attack the input must be validated before use