ATS 12-13 Security Testing 1
ATS 12-13 Security Testing 1
ATS 12-13 Security Testing 1
&
Security Testing
Bugs a.k.a. …
• Defect • Failure
• Fault • Inconsistency
• Problem • Product
• Error Anomaly
• Incident • Product
• Anomaly Incidence
• Variance • Feature :-)
Defective Software
• We develop programs that contain defects
– How many? What kind?
• Hard to predict the future, however…
it is highly likely, that the software we
(including you!) will develop in the future
will not be significantly better.
Sources of Problems
• Requirements Definition: Erroneous, incomplete,
inconsistent requirements.
• Design: Fundamental design flaws in the software.
• Implementation: Mistakes in chip fabrication, wiring,
programming faults, malicious code.
• Support Systems: Poor programming languages,
faulty compilers and debuggers, misleading
development tools.
Sources of Problems (Cont’d)
• Inadequate Testing of Software:
Incomplete testing, poor verification,
mistakes in debugging.
• Evolution: Sloppy redevelopment or
maintenance, introduction of new flaws in
attempts to fix old flaws.
Adverse Effects of Faulty
Software
• Communications: Loss or corruption of
communication media, non delivery of
data.
• Space Applications: Lost lives, launch
delays.
• Defense and Warfare: Misidentification of
friend or enemy.
Adverse Effects of Faulty
Software (Cont’d)
• Transportation: Deaths, delays, sudden
acceleration, inability to brake.
• Safety-critical Applications: Death,
injuries.
• Electric Power: Death, injuries, power
outages, long-term health hazards
(radiation).
Adverse Effects of Faulty
Software (Cont’d)
• Money Management: Fraud, violation of
privacy, shutdown of stock exchanges and
banks, negative interest rates.
• Control of Elections: Wrong results
(intentional or non-intentional).
• Control of Jails: Technology-aided escape
attempts and successes, accidental release
of inmates, failures in software controlled
locks.
• Law Enforcement: False arrests and
imprisonments.
Discussion …
• Have you heard of other software bugs?
– In the media?
– From personal experience?
• Does this embarrass you as a future
software engineer?
Specification
“if you can’t say it, you can’t do it”
• Testing programs to
establish the presence of
system defects
Test documents
• Test plan
– Quality objectives, resource needs, schedules,
assignments, methods, etc.
• Test cases
– Inputs and expected outputs.
• Bug reports
– E.g., the Bugzilla web-based bug tracker.
• Test tools and automation
• Metrics, statistics, and summaries
– Number of unresolved bugs, mean time to repair a
bug, etc.
The testing process
• Component testing
– Testing of individual program components
– Usually the responsibility of the component
developer (except sometimes for critical systems)
– Tests are derived from the developer’s
experience
• Integration testing
– Testing of groups of components integrated to
create a system or sub-system
– The responsibility of an independent testing team
– Tests are based on a system specification
Testing phases
Defect testing
• The goal of defect testing is to discover
defects in programs
• A successful defect test is a test which
causes a program to behave in an
anomalous way
• Tests show the presence not the absence
of defects
Test data and test cases
• Test data Inputs which have been devised
to test the system
• Test cases Inputs to test the system and
the predicted outputs from these inputs if
the system operates according to its
specification
– Scenario (Inputs, preconditions, post-
conditions etc.)
– Test data is required to create the test case
• Test Data Generation
The defect testing process
Black-box testing
(functional Testing)
• An approach to testing where the program
is considered as a ‘black-box’
• The program test cases are based on the
system specification
• Test planning can begin early in the
software process
Black-box testing
Structural testing
(White Box Testing)
• Sometime called white-box testing
• Derivation of test cases according to
program structure. Knowledge of the
program is used to identify additional test
cases
• Objective is to exercise all program
statements
(not all path combinations)
White-box testing
Coverage Metrics
• Coverage metrics
– Statement coverage: all statements in the programs should be
executed at least once
– Branch coverage: all branches in the program should be
executed at least once
– Path coverage: all execution paths in the program should be
executed at least once
• The best case would be to execute all paths through the code, but
there are some problems with this:
– the number of paths increases fast with the number of branches in
the program
– the number of executions of a loop may depend on the input
variables and hence may not be possible to determine
– most of the paths can be infeasible
Statement Coverage
assignAbsolute(int x)
{ Consider this program segment, the test set
if (x < 0) T = {x=-1} will give statement coverage,
x := -x; however not branch coverage
z := x;
}
B0
Control Flow Graph: (x < 0)
true false
B1 Test set {x=-1} does not
x := -x execute this edge, hence, it
does not give branch coverage
B2
z := x
Control Flow Graphs (CFGs)
• Nodes in the control flow graph are basic blocks
– A basic block is a sequence of statements always entered at the
beginning of the block and exited at the end
• Edges in the control flow graph represent the control flow
if (x < y) { B0 (x < y)
x = 5 * y; Y N
x = x + 3;
} x = 5 * y B1 B2 y = 5
else x = x + 3
y = 5;
x = x+y;
x = x+y B3
• Select a test set T such that by executing program P for each test
case d in T, each edge of P’s control flow graph is traversed at least
once
B0
(x < 0)
true false
B1 Test set {x=-1} does not
x := -x execute this edge, hence, it
does not give branch coverage