Bad Software Greg Hoglund CTO, Cenzic, Inc. [email protected].

56
Bad Software Greg Hoglund CTO, Cenzic, Inc. [email protected]

Transcript of Bad Software Greg Hoglund CTO, Cenzic, Inc. [email protected].

Page 1: Bad Software Greg Hoglund CTO, Cenzic, Inc. greg@cenzic.com.

Bad Software

Greg Hoglund

CTO, Cenzic, Inc.

[email protected]

Page 2: Bad Software Greg Hoglund CTO, Cenzic, Inc. greg@cenzic.com.

What is Bad Software?

• Software that exposes confidential data to un-authenticate users

• Software which crashes or grinds to a halt when exposed to faulty inputs

• Software which allows an attacker to inject code and execute it

• Software which executes privileged commands for an attacker

Page 3: Bad Software Greg Hoglund CTO, Cenzic, Inc. greg@cenzic.com.

Denver Airport Baggage

• Unmanned carts on a track• Bad failure recovery/detection

– Piles of fallen bags would not stop the unloaders

• Carts got out of sync– Full carts continue to get loaded– Empty carts get unloaded

• Delayed airport opening for 11 months– $1 million dollars a day in cost due to interest bond

issues

Page 4: Bad Software Greg Hoglund CTO, Cenzic, Inc. greg@cenzic.com.

The last photo taken by the Mars Lander before it plunged to it’s death.**This photo was found on the Internet. It has not been independently verified.

Page 5: Bad Software Greg Hoglund CTO, Cenzic, Inc. greg@cenzic.com.

NASA Mars Lander

• Failed translation – English units into metric units – major error in spacecraft's path as it approached

Mars

• Crashed into the planet– Shut off descent engines prematurely

• Taxpayer cost: $165 Million

Page 6: Bad Software Greg Hoglund CTO, Cenzic, Inc. greg@cenzic.com.
Page 7: Bad Software Greg Hoglund CTO, Cenzic, Inc. greg@cenzic.com.

4 Marines Killed

• MV-22 Osprey Helicopter Crash

• Burst hydraulic failure

• Software caused backup system to fail

Page 8: Bad Software Greg Hoglund CTO, Cenzic, Inc. greg@cenzic.com.

Do these look alike?

Page 9: Bad Software Greg Hoglund CTO, Cenzic, Inc. greg@cenzic.com.

Navy shoots down Civilian Airliner

• IN 1988, the US Vicennes shoots down Airbus 320

• 290 human lives lost

• “cryptic and misleading output displayed by the tracking software “

Page 10: Bad Software Greg Hoglund CTO, Cenzic, Inc. greg@cenzic.com.

Microsoft’s $8.5 billion mistake

• I LOVE YOU was only possible because Microsoft Outlook was designed to execute programs that were mailed to it.

Page 11: Bad Software Greg Hoglund CTO, Cenzic, Inc. greg@cenzic.com.

Why we have Bad Software

• Networked Software is not designed to withstand a hostile environment

• Development tools do not prevent simple security bugs (i.e., buffer overflows)

• QA Testing methods do not address security

• Customers pay for bad software

Page 12: Bad Software Greg Hoglund CTO, Cenzic, Inc. greg@cenzic.com.

Getting Worse

• In order to compete, new services must be delivered

• New technology is not being properly tested for failures

• More connections, devices, and code

Page 13: Bad Software Greg Hoglund CTO, Cenzic, Inc. greg@cenzic.com.

What happens when buffer overflows and poor access controls lead to mobile code attacks on cellular phones?

Mobile code can effect distributed systems in a matter of hours

More Devices

Page 14: Bad Software Greg Hoglund CTO, Cenzic, Inc. greg@cenzic.com.

More Connections

• New protocols, delivery mediums

• A high degree of connectivity makes it possible for small failures to propagate and lead to massive outages– Telephone network outages– Power system grid failures

Page 15: Bad Software Greg Hoglund CTO, Cenzic, Inc. greg@cenzic.com.

More Code• Technology is being ‘glued’ together• More feature rich, more drivers and libraries

–In 1983, Microsoft word was only 27,000 LOC

Code Size400,000 Solaris 717 million Netscape40 million Space Station10 million Space Shuttle7 million Boeing 77735 million NT5Under 5 million Windows 951.5 million Linux

Page 16: Bad Software Greg Hoglund CTO, Cenzic, Inc. greg@cenzic.com.

More Exposure

• Massive increase in connectivity

• A vast network of relationships– Arpanet started with 12 nodes

• Machines that used to work behind closed doors are now exposed– Computers are now worn on belt-loops

Page 17: Bad Software Greg Hoglund CTO, Cenzic, Inc. greg@cenzic.com.

5 Million Backdoors

• 5 – 50 bugs per 1000/lines of code [Vaos/McGraw]*

3000 EXE’s

1 LOC ~ 10 bytes

~100K per EXE =10,000 LOC / EXE5 Bugs/1000 LOC =

50 bugs/EXE

=

150,000 Bugs/Host

X 30,000 HOSTS

4.5 Billion bugs

4.5 Billion X 10% = 500 Million Security Bugs500 Million X 10% = 5 Million Remote Security Bugs

Page 18: Bad Software Greg Hoglund CTO, Cenzic, Inc. greg@cenzic.com.

Software is always in the “bleeding edge” phase

• Windows 2000 shipped with 63,000 known bugs

Page 19: Bad Software Greg Hoglund CTO, Cenzic, Inc. greg@cenzic.com.

Software sucks because you buy it

• Yes, YOU the CONSUMER play a part in demanding bad software

• To demand new features in a very short time frame creates a time-to-market problem for reliable software– Will you wait two years for the features you

want?– Will you pay 10-times as much to get those

features?

Page 20: Bad Software Greg Hoglund CTO, Cenzic, Inc. greg@cenzic.com.

Deja Vu

• The same software bugs just keep hanging around– We knew about buffer overflows 15 years ago

• We are slow to adopt ideas– When will customers hold vendors liable for

buffer overflows?– Is it reasonable to accept buffer overflows in

production code?

Page 21: Bad Software Greg Hoglund CTO, Cenzic, Inc. greg@cenzic.com.

Other Industries Get Sued

• Software shops gather around to defer bugs, decide which ones to ‘patch later’, and which ones to ignore

• In other industries, safety flaws that are not corrected result in major class-action suits

Page 22: Bad Software Greg Hoglund CTO, Cenzic, Inc. greg@cenzic.com.

How come vendors don’t fix this stuff?

• They can afford not to!• Hardware is expensive to replace – so huge

investments are placed into testing hardware prior to release– Intel F00F bug cost $500 million

• Software bugs can be patched and downloaded from a web-site– They pass the cost of a bug to the customer

Page 23: Bad Software Greg Hoglund CTO, Cenzic, Inc. greg@cenzic.com.

Software is not a Steel Bridge

• The methods used for testing in traditional analog systems do not apply to software

• With a bridge, you extrapolate results– What happens in between a 1000 kg test and a

10,000 kg test?– The system is continuous– State changes are gradual and predictable

Page 24: Bad Software Greg Hoglund CTO, Cenzic, Inc. greg@cenzic.com.

Discrete systems

• State changes are not predictable

• Numbers can change between

00001111

and

11110000

in an instant

Page 25: Bad Software Greg Hoglund CTO, Cenzic, Inc. greg@cenzic.com.

Let the compiler do the Diagnostics

• If programmers had to book time on the mainframe two weeks in advance, they would invest countless hours checking their work

• Code hackers today just bounce code off the compiler until all the errors go away– This puts the responsibility of “code review” on

the compiler

Page 26: Bad Software Greg Hoglund CTO, Cenzic, Inc. greg@cenzic.com.

Form follows Failure

• Sub-synchronous resonance in power systems– The addition of series AC capacitors in high energy power

systems increases electrical stability– However, due to line inductance, the capacitors create

electrical oscillations that effect the mechanical generator

• Mohave Generating Station, Southern Nevada, 1971 – This snapped the drive shaft on a generator twice before it

was properly diagnosed– This phenomenon is now a serious consideration is any

power system design

Page 27: Bad Software Greg Hoglund CTO, Cenzic, Inc. greg@cenzic.com.

How to Fix Bad Software

• Better compilers and languages– More formal, more tractable

• Failure analysis and fault-injection

• Hold vendors liable

• Stop buying it

Page 28: Bad Software Greg Hoglund CTO, Cenzic, Inc. greg@cenzic.com.

Security testing requiresattacking the software.

The software should be testedfor the unexpected and theunknown.

Software will never be placedor deployed into a trustedor predictable environment.

Security Testing

Page 29: Bad Software Greg Hoglund CTO, Cenzic, Inc. greg@cenzic.com.

The Missing Leg of Software Reliability

Functional Performance FunctionalPerformance

ReliabilityReliability ReliabilityReliability

Security

Traditional QA testing methods have never addressedsecurity. Software systems cannot be reliable unlessthey are secure.

Page 30: Bad Software Greg Hoglund CTO, Cenzic, Inc. greg@cenzic.com.

Security Testing History

• Attack and Pen

• Source Code Review

• Network Scanning

• Fault Injection

• Full Disclosure

Page 31: Bad Software Greg Hoglund CTO, Cenzic, Inc. greg@cenzic.com.

Fault Injection

• Source code changes require recompile

• Binary instrumentation requires host agent

• API input testing requires test harness

• Network input testing requires additional network node

Page 32: Bad Software Greg Hoglund CTO, Cenzic, Inc. greg@cenzic.com.

Black Box

• Can be automated

• Can easily find ‘low hanging fruit’

• Automated Tools:– ISICS– Spike– Hailstorm™– PROTOS

Page 33: Bad Software Greg Hoglund CTO, Cenzic, Inc. greg@cenzic.com.

MSQL Overflow with Spikes_binary("12 01 00 34 00 00 00 00 00 00 15 00 06 01 00 1b");

s_binary("00 01 02 00 1c 00 0c 03 00 28 00 04 ff 08 00 02");

//this is probably a length fields_binary("10 00 00 00");

//make this bigs_string_variable("MSSQLServer");s_binary("00 24 01 00 00");

Page 34: Bad Software Greg Hoglund CTO, Cenzic, Inc. greg@cenzic.com.

UDP-1434 SQL Overflow

Buffer Attack Injected Into Protocol Statement

Page 35: Bad Software Greg Hoglund CTO, Cenzic, Inc. greg@cenzic.com.

0040e890 e87b8cffff call 0040e895 c3 ret

0040e896 8bc0 movFAULT ->0040e898 8b10 mov 0040e89a 33c9 xor

Page 36: Bad Software Greg Hoglund CTO, Cenzic, Inc. greg@cenzic.com.

White Box

• IDA-Pro (reverse assemble)

• More expensive and requires an expert

• Very time consuming

Page 37: Bad Software Greg Hoglund CTO, Cenzic, Inc. greg@cenzic.com.

IDA reverse of popular app-server’s “CanonicalizeURIPath”

Page 38: Bad Software Greg Hoglund CTO, Cenzic, Inc. greg@cenzic.com.

A Fusion – Grey Box

• Combines:– A runtime debugger

• SoftIce

• GDB

– A white box tool• IDA

– A black box tool• Hailstorm™

Page 39: Bad Software Greg Hoglund CTO, Cenzic, Inc. greg@cenzic.com.

Using Instrumentation

• Using Rational Purify™

• Using API call hooks

• Using Code-coverage (gcov, etc)– Cananocalization routines– Filtering routines– Decision logic– Parsers

Page 40: Bad Software Greg Hoglund CTO, Cenzic, Inc. greg@cenzic.com.

Hailstorm™ crashes MS-SQL 7

Page 41: Bad Software Greg Hoglund CTO, Cenzic, Inc. greg@cenzic.com.

Input Path Tracing

• Path tracing– ltrace– truss

• Data tracing– Gdb breakpoints– Modified ltrace

• Where is user-data getting placed?– Trusted API calls?

Page 42: Bad Software Greg Hoglund CTO, Cenzic, Inc. greg@cenzic.com.

Boron Tagging with GDB.text:00056140 INTutil_uri_is_evil_internal:.text:00056140 ldsb [%o0], %o1.text:00056144 mov 1, %o3.text:00056148 mov 2, %o4.text:0005614C cmp %o1, 0.text:00056150 be,pn %icc, loc_561F4.text:00056154 mov %o0, %o5.text:00056158 mov %o2, %o0.text:0005615C mov 0, %o2.text:00056160 cmp %o1, 0x2F.text:00056164 .text:00056164 loc_56164:.text:00056164 bne,a %icc, loc_561DC

(gdb) x/8s $o00x97f030: “/iplanet/servers/TEST_STRING”0x97f064: "ervers/docs"0x97f070: "/usr/local/iplanet/docs"0x97f090: ""0x97f091: "\227ð\230"0x97f095: ""0x97f096: ""0x97f097: ""

TEST_STRING

Page 43: Bad Software Greg Hoglund CTO, Cenzic, Inc. greg@cenzic.com.

Using TRUSS on Solaris# truss -u *:: -vall -xall -p 2307 2>&1 | grep –v read | grep –v poll

The 2>&1 tag is required since truss does not deliver all of it’s data on the stdout pipe.

The output of the command will look something like:/67: <- libns-httpd40:__0FT_util_strftime_convPciTCc() = 50/67: -> libns-httpd40:__0FT_util_strftime_convPciTCc(0xff2ed342, 0x2, 0x2, 0/67: <- libns-httpd40:__0FT_util_strftime_convPciTCc() = 0xff2ed345/67: <- libns-httpd40:INTutil_strftime() = 20/67: -> libns-httpd40:INTsystem_strdup(0xff2ed330, 0x9, 0x41, 0x50)/67: -> libns-httpd40:INTpool_strdup(0x9e03a0, 0xff2ed330, 0x0, 0x0)/67: -> libc:strlen(0xff2ed330, 0x0, 0x0, 0x0)/67: <- libc:strlen() = 20/67: <- libns-httpd40:INTpool_strdup() = 0x9f8b10/67: <- libns-httpd40:INTsystem_strdup() = 0x9f8b10/67: <- libns-httpd40:time_cache_curr_strftime_logfmt() = 0x9f8b10/67: -> libc:strcpy(0xf7400710, 0x9f8b10, 0x0, 0x7efefeff)/67: <- libc:strcpy() = 0xf7400710/67: -> libc:strlen(0xf7400710, 0x9f8b28, 0xf7400710, 0x0)/67: <- libc:strlen() = 20/67: -> libc:strlen(0x9f4f48, 0x34508f, 0x0, 0x7efefeff)/67: <- libc:strlen() = 25

Page 44: Bad Software Greg Hoglund CTO, Cenzic, Inc. greg@cenzic.com.

Win32 hook on strcpy

Page 45: Bad Software Greg Hoglund CTO, Cenzic, Inc. greg@cenzic.com.

If there is code for it…

• What if?

• Assume filters fail

• Assume API call input can be controlled

• Map the capability of every DLL

• Controlled by process permissions and access control

Page 46: Bad Software Greg Hoglund CTO, Cenzic, Inc. greg@cenzic.com.

Every DLL that calls SetSecurityDescriptorDACL

Page 47: Bad Software Greg Hoglund CTO, Cenzic, Inc. greg@cenzic.com.

User Input

• What can the user directly control in terms of API calls?– Authentication calls– Filesystem– Database– Command shell

Page 48: Bad Software Greg Hoglund CTO, Cenzic, Inc. greg@cenzic.com.

Remote Capability

• Do any of the native calls operate over the network?– Domain specification– Data source specification– Ip address– NTFS Path name

Page 49: Bad Software Greg Hoglund CTO, Cenzic, Inc. greg@cenzic.com.

Authentication

• Response aggregation– User/password enumeration when errors differ

• No lockout– Brute force

• Failed logging– Alternative requests

• Can you specify a remote domain or target?– Proxied attacks

Page 50: Bad Software Greg Hoglund CTO, Cenzic, Inc. greg@cenzic.com.

Filesystem

• Can you control a filesystem path– What is the entire set of characters?

• Can you create files in a target directory– Create files that will be interpreted in a server

context

• Can you use remote pathname– //machine_name/etc

Page 51: Bad Software Greg Hoglund CTO, Cenzic, Inc. greg@cenzic.com.

Execution Flaws

• Code Insertion

• State Corruption

• Fatal Exception

Page 52: Bad Software Greg Hoglund CTO, Cenzic, Inc. greg@cenzic.com.

Architecture Flaws

• Lack of randomness– Hijacking keys

• No authentication– Bad configuration or design

• No compartments– Use the same buffer for crypto and clear

• Race conditions

Page 53: Bad Software Greg Hoglund CTO, Cenzic, Inc. greg@cenzic.com.

• Test before you buy

• Perform independent testing on the software

• Perform internal testing on the software

• Cooperate and create a shared testing lab

• Create an acceptance criteria

Take control of the Problem

Page 54: Bad Software Greg Hoglund CTO, Cenzic, Inc. greg@cenzic.com.

• Vote with your dollars• Force vendors into a comparison against

competitive products• Make the vendor produce a technically

credible security audit• Force vendors to accept liability associated

with a security bug– Make the vendor pay the cost of a bug

Make the vendor responsible

Page 55: Bad Software Greg Hoglund CTO, Cenzic, Inc. greg@cenzic.com.

• As the customers of technology, you have the right to demand safety and reliability

• Security knowledge is widespread

• Reliable software is secure

• Security testing is the only way to eliminate the bugs that undermine your systems

It’s Ultimately Your Decision

Page 56: Bad Software Greg Hoglund CTO, Cenzic, Inc. greg@cenzic.com.

Greg Hoglund

[email protected]

www.cenzic.com

Thank You