Testing software and judging its security

8 min 6 sections 5 practice questions 9 sources citedISC2 objectives 8.2, 8.3

Software is tested at several levels before anyone relies on it. Security testing uses tools that look at the program in different ways: reading its code, attacking it from outside, watching it from inside. Each tool finds some flaws and misses others. What is found then has to be weighed as risk, fixed or formally accepted, and measured over time. No background in testing or programming is assumed.

By the end of this unit you will be able to:

  • Put unit, integration, system and acceptance testing in order and explain regression testing
  • Tell apart verification and validation
  • Choose between SAST, DAST, IAST, RASP, software composition analysis and fuzzing for a given need
  • Explain how a flaw found in testing is analysed, treated and accepted
  • Name measures that show whether software security is working

The fix that broke the refunds

An illustrative example

A theatre's box office software miscalculated discounts for school groups. The supplier corrected the calculation, tested the discount screen, and confirmed it now gave the right price. The theatre installed the update on Friday.

On Saturday the box office could not issue refunds. The refund screen used the same calculation, and nobody had tried it. Two hundred customers queued for a cancelled matinee while staff wrote refunds by hand.

The supplier tested its fix and the fix worked. What kind of testing was missing?

Four levels of testing, and regression testing after every change

A car maker tests each part on a bench, then tests parts fitted together. Next it drives the finished car, and finally the buyer takes it for a drive. Software is tested at the same four levels.

  1. Unit testing: each small piece of a program, such as one calculation, is tested on its own, usually by the developer who wrote it.
  2. Integration testing: pieces are combined and tested to check that they work together and pass data correctly.
  3. System testing: the complete program is tested against its written requirements, including its security requirements.
  4. Acceptance testing: the customer or users test the program to decide whether to accept it. User acceptance testing is the common name.

Every change to a program can break something that was not changed. Regression testing repeats earlier tests after a change, to check that parts that used to work still work. It differs from retesting, which only checks that the change itself works. The theatre's supplier retested the discount screen and did no regression testing, so the broken refund screen went unnoticed.

Retest asks: does the fix work. Regression test asks: did the fix break anything else.

Verification asks if it was built right; validation, if it is right

A tailor can make a suit exactly to the measurements written on the order, and the customer can still find it useless because he needed a coat. The suit passed one check and failed another.

Verification
Objective evidence that the specified requirements have been met. It shows the product was built right, to its specification.
Validation
Objective evidence that the product meets the needs of its intended use. It shows the right product was built.

System testing against the specification is verification. Acceptance testing by users is mostly validation. A security requirement can pass verification and fail validation: the specification asked for passwords of eight characters, the code enforces eight, and the users' real needed a second factor.

Testing is worth more when the tester is not the author. Independent verification and validation (IV&V) is done by an organisation that is independent of the developers technically, in its management and in its funding. A developer who tests his own code checks the cases he already thought of. An independent tester brings the cases he missed.

Six ways to test a program's security, told apart

Static application security testing (SAST) examines code without running it, like proofreading a recipe. It usually reads the source code, and some tools analyse the compiled program instead. Dynamic application security testing (DAST) attacks the running program from outside through its screens and requests, as an attacker would, without seeing the code. Interactive application security testing (IAST) places an agent inside the running program during testing and watches what each test makes the code do.

Runtime application self-protection (RASP) also sits inside the running program, but in live use, and blocks inputs that would exploit a flaw. Software composition analysis (SCA) lists the outside components a product includes and checks them against known flaws and licence terms. Fuzzing feeds a running program large amounts of malformed or random input to make it fail. Mutation fuzzing, also called dumb fuzzing, changes real inputs at random. Generation fuzzing, also called intelligent fuzzing, builds inputs from a model of the data the program expects, so it reaches deeper code.

Software security testing methods compared
MethodLooks atProgram runningGood atMain limit
SASTSource code, or the compiled programNoKnown flaw patterns, with the file and lineMany false alarms. Misses configuration and runtime faults
DASTThe program from outsideYesFlaws an attacker can reach, including configurationCannot name the line at fault. Tests only what it reaches
IASTThe program from inside, during testingYesFlaws with the line and the runtime contextSees only code that the tests exercise
RASPThe program from inside, in live useYesBlocking an attack as it happensShields the flaw. Does not remove it
SCAOutside components and librariesNoKnown flaws and licences in borrowed codeSays nothing about the team's own code
FuzzingResponses to malformed inputYesCrashes and memory faults from unexpected inputEach failure still needs analysis

Common misconception

“RASP is a kind of testing that finds flaws before release.”

RASP is a protection that runs in production and blocks attacks on flaws that are still there. The testing methods find flaws so that they can be fixed.

What tools miss: code review and penetration testing

Automated tools find flaws that follow a known pattern. Some flaws need knowledge of what the program is for. Whether a clerk should see another branch's customers, or whether is used properly, depends on the business rules. Tools find these poorly.

Manual code review is a person reading the source code against the requirements. It is slow, so it is kept for the most critical parts, such as sign-in, payments and access checks. A , an authorised attack by skilled people, joins several small weaknesses into one real attack in a way no single tool does.

The strongest assurance combines the two kinds. Tools run on every change and catch common mistakes early and cheaply. People review the critical code and attack the finished system before release.

Risk analysis and mitigation: from a flaw found to a decision

Testing produces a list of flaws. A flaw is not yet a decision. Each one is analysed as a risk: how likely it is to be exploited, and what the harm would be. The drawn up during design says which and attackers matter most, so it guides that judgement.

  1. Record each flaw in a tracking system with enough detail to act on.
  2. Rate it by likelihood and impact, often starting from a published severity score.
  3. Choose a response: mitigate it by fixing the flaw or adding another control, avoid it by removing the feature, transfer it, or accept it.
  4. Where the permanent fix will take time, put a temporary mitigation in place and add the fix to the plan.
  5. Find the root cause, look for the same mistake elsewhere in the code, and change the process that let it in.
  6. Record what risk remains and who accepted it.

The risk left after treatment is the . A developer or tester does not accept it. The or the senior official who authorises the system to operate does, in writing, before release.

Evidence that software security is working

A single test result shows the state of one release. Effectiveness shows in measures tracked over many releases. Organisations set criteria for security checks in advance and record each approval, rejection and exception.

  • Open flaws by severity, and whether the count is falling
  • How long flaws of each severity stay open before they are fixed
  • Flaws found before release against flaws found after it
  • Share of releases that passed every security check without an exception
  • Repeat flaws: the same mistake found again after a root cause fix

Key performance indicators measure how well the security work is done. warn that risk is rising. A falling count of severe flaws found after release, with more found before it, is evidence that security moved earlier in development.

A question, worked through

An insurer has bought a claims application from a supplier. It received the compiled program only, with no source code. Before go-live the security manager must find whether the screens that accept claim details can be abused by injection. A test copy of the application is running in the insurer's test environment.

Which testing method is the BEST choice?

  1. Dynamic application security testing of the running test copy
  2. Static application security testing of the application's code
  3. Software composition analysis of the application's libraries
  4. Runtime application self-protection on the production system
Decide on your answer, then open the reasoning
  1. The question asks for a method that finds injection flaws in the claims screens before go-live, without source code.
  2. Rule out b. The insurer has no source code. Static analysis of the compiled program can only point at likely flaw patterns. It cannot show whether these screens can really be abused.
  3. Rule out d. RASP runs in production and blocks attacks. It does not find the flaw before go-live, and the system is not yet live.
  4. Between a and c: SCA finds known flaws in outside components. Injection in the supplier's own screens is not a known flaw in a library.
  5. DAST attacks the running program from outside, needs no source and tests exactly the screens in question. Option a.

Answer: A. Dynamic application security testing of the running test copy

Choosing between good answers

A question says the source code is not available
rule out manual code review. Static testing can still analyse the compiled program, but it reports likely flaw patterns. DAST, fuzzing and penetration testing show what an attacker can reach in the running program.
A question asks which test checks that a change has not broken existing functions
choose regression testing, not retesting of the change.
A question asks whether the product meets the users' real need
the answer is validation. Meeting the written specification is verification.
A question asks who accepts the risk of a flaw left unfixed at release
choose the system owner or authorising official, never the developer or the tester.

Try it

Follow a finding from the test result to the owner's decision and the retest.

Loading the preview.

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 test manager is explaining to a project board the security testing methods the team will use.

Match each method to what it does.

Choose the match for each entry. Every match has to be right.

What to remember

  • Testing runs at four levels: unit, integration, system and acceptance. Regression testing after each change checks that nothing else broke.
  • Verification checks the product against its specification. Validation checks that it meets the need it was built for.
  • SAST examines code without running it, usually the source code. DAST attacks the running program from outside. IAST watches it from inside during tests. RASP protects it in production.
  • Software composition analysis checks borrowed components. Fuzzing feeds malformed input to find failures.
  • Each flaw is rated as a risk and mitigated, avoided, transferred or accepted. Residual risk is accepted by the system owner, not the developer.
  • Security effectiveness is shown by measures over time, such as severe flaws found after release and how long flaws stay open.

Say it from memory

  1. How do SAST, DAST, IAST and software composition analysis differ, and which can work without the source code?

    SAST examines code without running it, usually the source but sometimes the compiled program, and names the line, with many false alarms. DAST attacks the running program from outside and needs no source. IAST watches the running program from inside during tests. SCA checks outside components for known flaws and licences. RASP blocks attacks in production. Fuzzing feeds malformed input.

    Read this part again

  2. What happens to a security flaw found in testing, and who accepts the risk that remains?

    It is recorded, rated by likelihood and impact, then mitigated by a fix or another control, avoided by removing the feature, transferred or accepted, with a temporary mitigation if the fix takes time. Its root cause is found and the process changed. The system owner or authorising official accepts the residual risk in writing.

    Read this part again

  3. How does regression testing differ from retesting?

    Retesting only checks that the change itself works. Regression testing repeats earlier tests after a change, to check that parts that used to work still work. Retest asks whether the fix works; regression testing asks whether the fix broke anything else.

    Read this part again

  4. How does verification differ from validation, and what makes verification and validation independent?

    Verification is objective evidence that the specified requirements were met: the product was built right. Validation is objective evidence that it meets the needs of its intended use: the right product was built. Independent verification and validation is done by an organisation independent of the developers technically, in its management and in its funding.

    Read this part again

  5. What do manual code review and penetration testing find that automated tools miss?

    Flaws that need knowledge of what the program is for, such as whether a clerk should see another branch's customers, or whether encryption is used properly. Manual review is kept for critical parts such as sign-in, payments and access checks. A penetration test joins several small weaknesses into one real attack.

    Read this part again

  6. Which measures over many releases show that software security work is effective?

    Open flaws by severity and whether the count is falling, and how long flaws stay open. Flaws found before release against after it, the share of releases passing every security check without an exception, and repeat flaws. More severe flaws found before release and fewer after shows security moved earlier.

    Read this part again

Sources