Code review and software testing: static, dynamic, fuzzing

7 min 4 sections 5 practice questions 8 sources citedISC2 objective 6.2

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.

Static against dynamic testing
PointStatic testingDynamic testing
What it needsThe source codeA running copy of the program
When it can startAs soon as code is writtenOnce the program can run
What it finds wellRisky coding patterns, wherever they are in the codeWhat actually happens with real input, including faults in setup
Typical weaknessReports some problems that are not realTests 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.

  1. Planning. The moderator checks the code is ready, and picks a small team of about four. The inspectors are not the author.
  2. Overview. The author explains the code's purpose and design to the team, and parts are assigned.
  3. Preparation. Each inspector studies the code alone and notes possible defects.
  4. Inspection meeting. The team goes through the code together and records defects. It names problems but does not design fixes.
  5. Rework. The author fixes the defects.
  6. 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.

Four kinds of application security tool
ToolWhat it looks atHowStrength and limit
Static application security testing (SAST)Source code, without running itReads the code for known risky patterns and out-of-date partsRuns as soon as code is written. Reports some false alarms
Dynamic application security testing (DAST)The running program, from outsideSends attacks through the program's front, like an outside attacker, with no view of the codeFew false alarms. Cannot say which line is at fault
Interactive application security testing (IAST)The running program, from insideA monitor placed inside the program watches each test as it happensPoints to the exact line. Needs the program running under test
Runtime application self-protection (RASP)The live program in useA monitor inside the program spots attacks on it and blocks themA protection, not a test

Each software test looks at a different stage

Each software test looks at a different stageTwo frames in order: the source code, read by code review and SAST, and the program running in testing, checked by DAST, IAST and fuzzing. Outside them, the live program is guarded by RASP.Source codestatic: read, not runCode reviewpeople read the codeSASTa tool reads the codeRunning in testingdynamic: run and probedDASTattacks from outsideIASTa monitor inside watchesFuzzingmasses of odd inputLive in usereal customersRASPblocks attacks;not a testEach software test looks at a different stageTwo frames in order: the source code, read by code review and SAST, and the program running in testing, checked by DAST, IAST and fuzzing. Outside them, the live program is guarded by RASP.Source codestatic: read, not runCode reviewpeople read the codeSASTa tool reads the codeRunning in testingdynamic: run and probedDASTattacks from outsideIASTa monitor inside watchesFuzzingmasses of odd inputLive in usereal customersRASPblocks attacks;not a test
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.

  1. 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.
  2. 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.
  3. 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.

Mutation fuzzing against generation fuzzing
PointMutation fuzzingGeneration fuzzing
How inputs are madeBy changing existing valid inputs: flipping, cutting, repeating or swapping partsFrom a description of what valid input looks like, built new each time
Set-upQuick: needs only some sample inputsSlow: someone must describe the input format
DepthMany inputs are rejected at the first checkInputs 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?

  1. A Fagan inspection of the code that reads the files
  2. Mutation fuzzing that alters sample customer files
  3. Generation fuzzing built from the file format description
  4. A second static analysis tool from another supplier
Decide on your answer, then open the reasoning
  1. The aim is to see what happens when the running program meets malformed files. That calls for dynamic testing.
  2. Rule out d: static analysis is already running, and a second tool still does not run the program.
  3. 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.
  4. 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

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.

Which kind of tool is this?

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

  1. 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.

    Read this part again

  2. 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.

    Read this part again

  3. 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.

    Read this part again

  4. 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.

    Read this part again

Sources