A bank adds a component inside its live mobile banking service. The component watches each request as the program handles it and stops any request that looks like an attack.
Code review and software testing: static, dynamic, fuzzing
Software can be checked for security flaws in two ways: by reading its instructions, or by running it and watching what it does. People read code in reviews, tools read it automatically, and other tools attack the running program or feed it nonsense to see whether it breaks. No background is assumed. A security professional needs to know what each method finds, what it misses and when in a program's life it is used.
By the end of this unit you will be able to:
- Tell apart static and dynamic testing, and black, white and grey box testing of software
- Put in order the six steps of a Fagan inspection, and tell apart other kinds of code review
- Tell apart SAST, DAST, IAST and RASP
- Tell apart mutation and generation fuzzing
The quantity box that took a minus sign
An illustrative example
A garden furniture shop pays a small firm to build its new ordering website. The firm's programmer tests every page by placing ordinary orders, and all of them work. The site goes live.
A week later the shop's accountant finds a refund paid to a customer who never returned anything. The customer had typed minus five into the quantity box. The website multiplied the price by minus five and paid the money back to the customer's card. Nobody had tried typing anything unusual before the site went live.
Which two checks, one by reading and one by running the program, could have found this before the site went live?
Reading the code or running it: static and dynamic testing
A program starts as source code: instructions written by a programmer in a language people can read. Before it runs, the source code is usually translated into a form the computer runs directly. A mistake in the code that makes the program behave wrongly is a defect, often called a bug. A defect that an attacker can use is a security flaw.
There are two ways to look for defects. Static testing examines the code, or documents about it, without running the program. Dynamic testing runs the program, gives it input and checks what comes out. In software, input means anything given to a program: typed text, a file, a click or a message from another program.
| Point | Static testing | Dynamic testing |
|---|---|---|
| What it needs | The source code | A running copy of the program |
| When it can start | As soon as code is written | Once the program can run |
| What it finds well | Risky coding patterns, wherever they are in the code | What actually happens with real input, including faults in setup |
| Typical weakness | Reports some problems that are not real | Tests only the paths its input happens to reach |
The same idea gives three names for how much the tester sees. In white box testing the tester works from the source code. In black box testing the tester has only the running program, as an outside attacker would. Grey box testing combines the two. NIST's testing guide notes that reading the code cannot reveal defects introduced when parts are joined together or installed, so the two views are used together.
Code review by people, and the Fagan inspection
A code review is a check of source code by people other than its author, looking for defects before the program is used. Reviews range from informal to strict.
- Informal or over-the-shoulder review
- A colleague looks through the change with the author. Quick and cheap, with no set and no record.
- Pair programming
- Two programmers share one computer. One types, the other watches and thinks ahead, and they swap often. The review happens as the code is written.
- Tool-assisted review
- Changes are shown in a review tool. Reviewers comment on each line and the author must answer before the change is accepted. The tool keeps a record.
- Inspection
- The most formal review, with set roles, entry criteria, a meeting and measured results.
The best-known inspection method was developed by Fagan at IBM. A Fagan inspection has six steps.
- Planning. The moderator checks the code is ready, and picks a small team of about four. The inspectors are not the author.
- Overview. The author explains the code's purpose and design to the team, and parts are assigned.
- Preparation. Each inspector studies the code alone and notes possible defects.
- Inspection meeting. The team goes through the code together and records defects. It names problems but does not design fixes.
- Rework. The author fixes the defects.
- Follow-up. The moderator checks that every defect was fixed, and decides whether another inspection is needed.
Fagan in order: plan, overview, prepare, inspect, rework, follow up. Fixing happens in rework, never in the meeting.
SAST, DAST and IAST: three kinds of testing tool
People cannot read millions of lines. Tools carry most of the load, and their names say what they look at.
| Tool | What it looks at | How | Strength and limit |
|---|---|---|---|
| Static application security testing (SAST) | Source code, without running it | Reads the code for known risky patterns and out-of-date parts | Runs as soon as code is written. Reports some false alarms |
| Dynamic application security testing (DAST) | The running program, from outside | Sends attacks through the program's front, like an outside attacker, with no view of the code | Few false alarms. Cannot say which line is at fault |
| Interactive application security testing (IAST) | The running program, from inside | A monitor placed inside the program watches each test as it happens | Points to the exact line. Needs the program running under test |
| Runtime application self-protection (RASP) | The live program in use | A monitor inside the program spots attacks on it and blocks them | A protection, not a test |
Each software test looks at a different stage
Read this figure as text
A program passes from source code, to running on a test system, to live use. Each review, test or protection works at one of these stages, and the stage says whether it is static or dynamic.
- Source code is the program as the programmer wrote it. Static checks read it without running it: code review by people, from informal review to a Fagan inspection, and SAST, a tool that reads the code for risky patterns. The code is then built and run on a test system.
- Running in testing, dynamic checks need the program running: DAST attacks it from outside with no view of the code, IAST places a monitor inside that watches each test and points to the line at fault, and fuzzing feeds it masses of malformed or unexpected input. The tested program is then released.
- Live in use, the program serves real customers. RASP, runtime application self-protection, is a monitor inside the live program that detects and blocks attacks. It is a protection, not a test.
NIST's , SP 800-53, lists , manual code review, dynamic analysis and interactive testing as separate duties for developers. NIST's guidance on minimum verification for developers, Interagency Report 8397, adds the order: static analysis as soon as code is written, then dynamic tests and fuzzing once it runs.
Fuzzing: input the program never expected
Fuzzing, or fuzz testing, is that feeds a program huge numbers of malformed, unexpected or random inputs and watches for crashes, hangs and other failures. It is automated: a tool can try millions of inputs with little human effort. Each failure points to input the program does not handle safely, which is where attackers look first.
Fuzzers differ in how they make their inputs. Mutation fuzzing is also called dumb fuzzing, and generation fuzzing is also called intelligent or smart fuzzing.
| Point | Mutation fuzzing | Generation fuzzing |
|---|---|---|
| How inputs are made | By changing existing valid inputs: flipping, cutting, repeating or swapping parts | From a description of what valid input looks like, built new each time |
| Set-up | Quick: needs only some sample inputs | Slow: someone must describe the input format |
| Depth | Many inputs are rejected at the first check | Inputs pass the first checks and reach deeper code |
Fuzzing a date box
A mutation fuzzer takes 12/03/2025 and tries 12/03/20255, 1/203/2025 and 12//2025. A generation fuzzer knows a date is a day, a month and a year. It tries 31/02/2025, 00/13/1900 and 29/02/2100: inputs that look valid and test the program's date logic.
Fuzzing finds defects that ordinary tests miss, because ordinary tests use the inputs people expect. Testing the shop's quantity box with minus five, a huge number and letters is the same idea done by hand.
Common misconception
“Fuzzing is a way of scanning source code for flaws.”
Fuzzing is dynamic. It needs the program running, and it never reads the code. It works by watching what the program does with input it was not built for.
A question, worked through
A software firm writes a program that reads files sent in by customers. The files have a complicated, documented format. Its scanning tool reads the source code every night. The security lead wants to find out whether malformed files could crash the program. The test team has two weeks and a description of the file format.
Which testing approach BEST meets the security lead's aim?
Decide on your answer, then open the reasoning
- The aim is to see what happens when the running program meets malformed files. That calls for dynamic testing.
- Rule out d: static analysis is already running, and a second tool still does not run the program.
- Rule out a: an inspection is careful static review. It finds coding defects but does not show what the program does with millions of odd files.
- Between b and c: both are fuzzing. The format is complicated, so randomly altered files will mostly be rejected at the first check. The team has the format description and time to use it, so generation fuzzing will build files that pass the first checks and reach the deeper code.
Answer: C. Generation fuzzing built from the file format description
Choosing between good answers
- A question asks which test can be done before the program can run
- choose a static method: code review, inspection or SAST.
- A question asks how to find what unexpected or malformed input does to a program
- choose fuzzing. It is dynamic and automated.
- A question contrasts quick fuzzing from sample inputs with fuzzing built from a format description
- the first is mutation fuzzing, the second generation fuzzing. Generation reaches deeper code but costs more to set up.
- A question asks about a tool that blocks attacks on a live program from inside it
- that is RASP, a protection. SAST, DAST and IAST are tests.
Check your understanding
5 questions on this unit, easiest first. Confirm an answer to see the reasoning for it, then the right answer, the other options and the rule to reuse. Your answers are kept in this browser and feed readiness and review.
These questions are drafts that no named reviewer has approved yet.
Question 1 of 5
What to remember
- Static testing examines code without running it. Dynamic testing runs the program with input. Each finds defects the other misses.
- White box testing uses the source code, black box only the running program, and grey box both.
- A Fagan inspection runs planning, overview, preparation, inspection meeting, rework and follow-up. The meeting finds defects, the author fixes them in rework, and the moderator checks the fixes.
- SAST reads source code, DAST attacks the running program from outside, IAST watches it from inside during tests, and RASP protects it while live.
- Fuzzing feeds a running program masses of unexpected input. Mutation fuzzing alters valid samples. Generation fuzzing builds inputs from a description of the format.
Say it from memory
Name the main methods of code review and testing, and say whether each is static or dynamic.
Static: code review by people, from informal review and pair programming to the six-step Fagan inspection, and SAST tools that read the source code. Dynamic: DAST, which attacks the running program from outside, IAST, which watches it from inside during tests, and fuzzing, which feeds it unexpected input. Mutation fuzzing alters samples, and generation fuzzing builds inputs from a format description.
Give the six steps of a Fagan inspection in order, and say where defects are fixed.
Planning, overview, preparation, inspection meeting, rework, follow-up. The meeting names problems but does not design fixes. The author fixes the defects in rework, and the moderator checks every fix in follow-up.
What does each of SAST, DAST and IAST look at, and what is the main limit of each?
SAST reads source code without running it, and reports some false alarms. DAST attacks the running program from outside with no view of the code, and cannot say which line is at fault. IAST watches the running program from inside during tests and points to the exact line, but needs the program running under test.
What is fuzzing, and is it static or dynamic testing?
Fuzzing is dynamic testing that feeds a program huge numbers of malformed, unexpected or random inputs and watches for crashes, hangs and other failures. It needs the program running and never reads the code. Each failure points to input the program does not handle safely.
Sources
- Standard Glossary of Terms used in Software Testing, Version 3.2: Foundation Terms, International Software Testing Qualifications Board (ISTQB)Static analysis as evaluating a component without executing it, dynamic analysis as evaluating behaviour during execution, peer review, informal review and inspection as a formal review type.
- NIST SP 800-115: Technical Guide to Information Security Testing and Assessment, NISTWhite box application testing from the source code, black box testing against the running program without source code knowledge, grey box as the combination, and that code analysis cannot detect defects in interfaces between components or introduced in compilation, linking or installation.
- Software Quality Engineering, Chapter 14: Inspection (lecture slides), Jeff Tian, Southern Methodist University (Wiley-IEEE Computer Society Press, 2005)The six steps of Fagan inspection, a team of about four inspectors who are not the authors, defect identification but not solutions in the meeting, rework by the author and resolution verification by the moderator.
- Pair Programming (Agile Alliance Glossary), Agile AlliancePair programming as two programmers sharing one workstation, with a driver who types and a navigator, swapping roles often.
- SP 800-53 Rev. 5, Security and Privacy Controls for Information Systems and Organizations, NISTStatic code analysis, manual code reviews, dynamic code analysis including fuzz testing, and interactive application security testing as developer testing enhancements, and runtime application self-protection as runtime instrumentation that detects and blocks exploitation.
- NIST IR 8397: Guidelines on Minimum Standards for Developer Verification of Software, National Institute of Standards and TechnologyStatic analysis as soon as code is written, SAST and DAST as the static and dynamic kinds, dynamic testing having few false positives, fuzzing as automated testing with huge numbers of inputs, and mutation-based against generation-based fuzzing, with generation reaching deeper code but needing more set-up.
- OWASP Developer Guide: DAST tools, OWASP FoundationDAST tools work against the running application from outside without access to the source code.
- OWASP DevSecOps Guideline: Interactive Application Security Testing, OWASP FoundationIAST instruments the running application and reports each vulnerability with the line of code where it was observed.