A type of security analysis. Runs the software on specific inputs and checks results against an oracle.
Exhaustive testing is infeasible. For example, adding two 64-bit integers has cases.
Testing can only prove what happens. Security requirements are often of the form “X never happens”, which testing cannot prove.
Test Design
Negative Testing
Checks what should not happen. Negative test cases assert failures.
Examples:
- Can I read without authorization?
- Can I connect with an invalid certificate?
Automated Techniques
Web Application Scanner
Crawls form and links like a browser, send attack-like and random data, and detect problems.
Examples:
- OWASP ZAP
- W3AF
- Burp Suite Pro
Fuzz Testing
Feeds large numbers of random or mutated inputs. Monitors for crashes, assertion failures, and memory leaks, instead of correct answers. The concept comes from Barton Miller, 1988. It often finds real defects quickly, with diminishing returns after fixes.
Input strategies:
- Fully random
- Mutation-based Also known as dumb fuzzing. Mutates sample inputs.
- Generation-based Also known as smart fuzzing. Models the input format.
Coverage-guided evolution routes inputs that hit new paths for more mutation.
Examples:
- American Fuzzy Lop (AFL, AFL++)
A coverage-guided mutation fuzzer. It instruments branch counts and prioritizes inputs hitting new edges. It once produced a valid JPEG starting from the text “hello”.
Address Sanitizer
Also known as ASan. Compiles with -fsanitize=address to catch buffer overflow,
use-after-free, and double-free. It uses shadow bytes and inaccessible red zones
around allocations.
Overhead is roughly 2x CPU and 2x to 4x memory. Sanitizers tolerate some false positives. Production exploit mitigations tolerate none.