Code, Misuse Case and Interface Testing
Software must be tested for security as well as function. This lesson covers code review and testing, misuse case testing, coverage analysis and interface testing.
Learning outcomes
After completing this lesson, you will be able to:
- Describe code review, static and dynamic testing and fuzzing.
- Explain misuse case testing, coverage analysis and interface testing.
Code review and testing
Manual code review, from informal peer review to formal Fagan inspections with defined roles and stages, finds logic and design flaws that tools miss. Static analysis (SAST) examines source code or binaries without running them. Dynamic testing (DAST) exercises the running application. Fuzzing sends malformed, unexpected or random inputs to find crashes and input-handling flaws: mutation fuzzing alters valid inputs, while generation-based fuzzing builds inputs from a model of the expected format.
Testing levels include unit, integration, system and acceptance testing, and regression testing confirms that changes have not broken existing functions or reintroduced fixed vulnerabilities.
Each technique finds different flaws. Static analysis can scan every line of a large code base quickly and is good at finding patterns such as user input passed unchecked into a database query, but it reports many false positives and cannot see problems that only appear at run time. Dynamic testing sees the application as an attacker does, including configuration errors, but tests only the paths it manages to reach. Manual review is slow and expensive but is the best way to find flaws in authorisation logic and design, which tools rarely understand.
A Fagan inspection is a formal review with defined stages: planning, an overview, individual preparation, an inspection meeting where defects are recorded, rework by the author and follow-up to verify the fixes. Its formality makes it effective for critical code, such as authentication or cryptographic modules. Fuzzing complements reviews by finding flaws nobody thought to look for: a fuzzer feeding millions of malformed image files to a parser may discover a crash that reveals a memory corruption vulnerability.
Choosing a testing technique
Misuse cases and coverage analysis
Misuse case testing (abuse case testing) checks how a system responds to deliberate misuse, such as entering negative quantities, skipping workflow steps, replaying requests or changing an identifier to view another user's record. Misuse cases come from threat models and test business logic flaws that automated scanners rarely catch.
Coverage analysis measures how thoroughly tests exercise the software, calculated as the share of items tested. Code coverage metrics include statement, branch, condition, function and loop coverage; requirements coverage checks that every requirement, including security requirements, has tests. High coverage does not prove the absence of flaws, but low coverage reveals untested code.
A small calculation shows how coverage is reported. If a module has 200 branches and the test suite exercises 150 of them, branch coverage is 150 / 200 = 75%. The remaining 50 branches have never run during testing, and error-handling paths are often among them, which matters for security because attackers deliberately trigger errors. Statement coverage can be high while branch coverage is low: a test that takes only the true branch of every condition executes most statements but never tests what happens when a check fails.
Misuse cases are written in the same format as use cases but from an attacker's perspective. Alongside the use case "customer applies a discount code", the team writes misuse cases such as "customer applies the same code twice", "customer applies an expired code" and "customer edits the request to change the discount amount", each with the expected secure behaviour. These become test cases, which is how threat models turn into evidence that the system resists the threats identified.
The following diagram shows a business logic flaw that scanners miss.

Coverage arithmetic
Interface testing
Interface testing examines the points where users and systems interact with the software. User interface tests check input validation, error messages and hidden functions. Network interface tests check exposed services and handling of malformed traffic. API tests check authentication, authorisation on every object and function, input validation, rate limiting and data exposure. Tests include invalid and malicious inputs as well as valid ones.
Interfaces deserve focused testing because they are where assumptions meet. An API test for an order service might call each endpoint without a token, with another customer's token, with an expired token, with oversized fields, with unexpected data types and at a high request rate, and check that each produces a safe, specific error rather than data or a crash. It also checks what the response contains: an API that returns the full customer record when the mobile app displays only the name is exposing data unnecessarily, even if the user is authorised to see their own record. Interfaces between internal components, such as a message queue between services, are tested in the same way, because an attacker who reaches one component will use them.
Which interface is tested?
A logic flaw
An online store passes automated vulnerability scans, but a customer discovers that applying a discount code twice in quick succession doubles the discount. Which testing technique would most likely have found this?
This is a business logic flaw (and possibly a race condition) that scanners do not recognise. Misuse case testing based on a threat model of the checkout process, asking how a customer might abuse discounts, would likely have found it, supported by manual code review of the discount logic.
What does fuzzing test?
Show answer
How software handles malformed, unexpected or random input.
Exam Tips
Remember for the exam
- SAST examines code; DAST tests the running application; fuzzing tests input handling.
- Misuse cases find business logic flaws.
- Coverage = items tested divided by total items.