Software Flaws

25
SOFTWARE FLAWS

Transcript of Software Flaws

Page 1: Software Flaws

SOFTWARE FLAWS

Page 2: Software Flaws

Examples

• A NASA Mars Lander costing around a $165 million , crashed into Mars due to a software error in converting between different Metrics in Measurement. 

• Baggage handling system at the Denver airport was closed for 11 months costing a million dollars a day due to a Bug in the Software

Page 3: Software Flaws

• In 1996, the European Space agency’s  US$1 billion prototype Ariane 5 rocket was destroyed less than a minute after launch, due to a Bug in the on‐board guidance computer program.

• In June 1994, a Royal Air Force Chinook crashed into the Mull of Kintyre, killing 29. An investigation into the matter attributed it to a software Bug in the Aircrafts Engine Control Computer.

Page 4: Software Flaws

How Widespread is a Flaw 

• A Conservative estimate places the number of Bugs in a Software at 5 per 1000 lines of code(LOC). A typical computer might have 3000 executable files each of which contains approximately 100,000 LOC. Then on an average each executable file has 50 bugs, which implies about 150,000 bugs for a single computer!

Page 5: Software Flaws

Definition

A Software Flaw is the common term used to describe an error, bug, mistake, failure or fault in a computer program that produces an incorrect or unexpected result or causes it to behave in an unintended way.

Page 6: Software Flaws

What causes Flaws

• Most Bugs arise from errors in the source code or the design.

• Errors may also creep in because of compilers producing incorrect code.

Page 7: Software Flaws

Classes of Software Flaws

Broadly there are 3 classes of Software Flaws:• Buffer Overflow• Race condition• Incomplete mediation

Page 8: Software Flaws

Buffer Overflow

• A Buffer Overflow is an anomaly where a program, while writing data to a buffer, overruns the buffer's boundary and overwrites adjacent memory.

Consider an Example:A program has defined two data items which are adjacent in memory: an 8‐byte‐long string buffer, A, and a two‐byte integer, B. Initially, A contains nothing but zero bytes, and B contains the number 1979. Characters are one byte wide.

Page 9: Software Flaws

Buffer Overflow…

variable 

nameA B

value [null string] 1979

hex value 00 00 00 00 00 00 00 00 07 BB

Page 10: Software Flaws

Buffer Overflow…

• Now, the program attempts to store the null‐terminated string  "excessive" in the A buffer. By failing to check the length of the string, it overwrites the value of B:

variable 

nameA B

value 'e' 'x' 'c' 'e' 's' 's' 'i' 'v' 25856

hex 65 78 63 65 73 73 69 76 65 00

Page 11: Software Flaws

Buffer Overflow…

Although the programmer did not intend to change B at all, B's value has now been replaced by a number formed from part of the character string. In this example, on a big‐endian system that uses ASCII, "e" followed by a zero byte would become the number 25856. If B was the only other variable data item defined by the program, writing an even longer string that went past the end of B could cause an error such as a segmentation fault, terminating the process.

Page 12: Software Flaws

Protective Measures

• Choice of programming languageC and C++ provide no built‐in protection against accessing or overwriting data in any part of memory. More specifically, they do not check that data written to an array (the implementation of a buffer) is within the boundaries of that array.

Page 13: Software Flaws

Protective Measures…

Many other programming languages provide runtime checking and in some cases even compile‐time checking which might send a warning or raise an exception when C or C++ would overwrite data and continue to execute further instructions until erroneous results are obtained which might or might not cause the program to crash.Ex: Ada, Eiffel, Lisp, Modula‐2, Smalltalk, OCaml and such C‐derivatives as Cyclone and D. The Java and .NET bytecode environments also require bounds checking on all arrays.

Page 14: Software Flaws

• Use of safe librariesIt is recommended to avoid standard library functions which are not bounds checked, such as gets, scanf and strcpy. Instead strlcpy, strlcat function should be used.

Page 15: Software Flaws

Race Condition

A race condition occurs when multiple processes access and manipulate the same data concurrently, and the outcome of the execution depends on the particular order in which the access takes place.

Page 16: Software Flaws

Race Condition…

1.Allocate space

mkdir

2.Transfer Ownership

Page 17: Software Flaws

Race Condition

1.Allocate space

mkdir

3.Transfer Ownership

2. Create Link to password file

Page 18: Software Flaws

Incomplete Mediation

• Inputs to programs are often specified by untrusted users.

‐Web‐based applications are a common example.• The web application needs to ensure that what the user has entered constitutes a meaningful request. This is called mediation.

Page 19: Software Flaws

• Incomplete mediation occurs when the application accepts incorrect data from the user

• Sometimes this is hard to avoid– Phone number: 519-886-4567– This is a reasonable entry, that happens to be wrong

• We focus on catching entries that are clearly wrong– Not well formed

• DOB: 18-13-1988– Unreasonable values

• DOB: 12-10-1876

Page 20: Software Flaws

• What's the security issue here?

• What happens if someone fills in:– DOB: 98764874236492483649247836489236492

• Buffer overflow?– DOB: DROP DATABASE clients --

• SQL injection?

• We need to make sure that any user‐supplied input falls within well‐specified values, known to be safe

Page 21: Software Flaws

Client‐side mediation• You've probably visited web site with forms that do client‐sidemediation– When you click “submit”, Javascript code will first run validation checks on the data you entered

– If you enter invalid data, a popup will prevent you from submitting it

• Related issue: client‐side state– Many web sites rely on the client to keep state for them

– They will put hidden fields in the form which are passed back to the server when the user submits the form

Page 22: Software Flaws

Client‐side mediation• Problem: what if the user

– Turns off Javascript?– Edits the form before submitting it? (Greasemonkey)

– Writes a script that interacts with the web server instead of using a web browser at all?

– Connects to the server “manually”?(telnet server.com 80)

• Note that the user can send arbitrary (unmediated) values to the server this way

• The user can also modify any client‐side state

Page 23: Software Flaws

Example• At a bookstore website, the user orders a copy of the course text.  The server replies with a form asking the address to ship to.  This form has hidden fields storing the user's order– <input type=“hidden” name=“isbn”

value=“0-13-239077-9”><input type=“hidden” name=“quantity”

value=“1”><input type=“hidden” name=“unitprice”

value=“111.00”>

• What happens if the user changes the “unitprice” value to “50.00” before submitting the form?

Page 24: Software Flaws

Defences against incomplete mediation

• Client‐side mediation is an OK method to use in order to have a friendlier user interface, but is useless for security purposes.

• You have to do server‐side mediation, whether or not you also do client‐side.

• For values entered by the user:– Always do very careful checks on the values of all fields– These values can potentially contain completely arbitrary 8‐bit data (including accented chars, control chars, etc.) and be of any length

• For state stored by the client:– Make sure the client has not modified the data in any way

Page 25: Software Flaws

THANK YOU!

PRESENTED BY:

PRASHANT KUMARANOOP P.RAMACHANDRACHANDRASHEKHAR B.