COMP-222 · Lesson 4 of 12 · 20 min

Application security testing

▶ Video coming soon A video version of this lesson is on the way.

Priyanka Haldane, Ironwhistle's web and cloud application tester, had the member portal staging environment to herself from October 19. The staging site was a copy of the portal Prairiefold members used to view statements, update contact details and send secure messages, with synthetic member records instead of real ones. Prairiefold's development team had also agreed to share the portal's source repository for the week, read-only. Priyanka invited Tobias to watch, and started by drawing four boxes on the whiteboard labeled SAST, SCA, DAST and IAST. Most people, she said, know one or two of these. The exam expects all four, and the client deserves to know which one found each problem.

Objective 3.1 lists application scans in detail: dynamic application security testing (DAST), interactive application security testing (IAST), software composition analysis (SCA), and static application security testing (SAST), which includes source code analysis and the analysis of infrastructure as code. It also lists mobile scans. This lesson explains each technique, where it fits in the software life cycle, what it finds and misses, and how a tester reads its results. Infrastructure as code gets fuller treatment in lesson 5 alongside containers and cloud.

Four ways to look at an application

The four techniques differ in what they examine and when. Static testing reads the code without running it. Dynamic testing runs the application and attacks it from outside, like a user or attacker would. Interactive testing instruments the running application so that it can watch from inside while traffic flows through it. Composition analysis inventories the third-party components the application depends on and checks them against known vulnerabilities.

A horizontal software life cycle with five phases: code, build, test, staging and production. SAST sits under code and build. SCA spans code, build and production. IAST sits under test and staging. DAST sits under staging and production. Manual penetration testing spans staging and production.
Where each application testing technique usually runs in the software life cycle.
The four application testing techniques named in objective 3.1.
TechniqueExaminesNeedsGood atMisses
SASTSource code, bytecode or binaries, not runningAccess to codeUnsafe data flows, dangerous functions, hard-coded secrets; finds issues early with exact file and lineRuntime configuration, logic flaws, issues in deployed environment; can produce many false positives
SCAThird-party libraries and packagesManifest files, lock files or built artifactsKnown CVEs in dependencies; license issues; building a software bill of materialsFlaws in the organization's own code; whether the vulnerable function is actually used
DASTThe running application from outsideA reachable, running instanceReal behavior: injection, cross-site scripting, misconfigured headers, exposed files; no code neededCode paths it never reaches; exact location in code; complex workflows unless guided
IASTThe running application from inside, via an agentInstrumentation in a test environmentConfirming data flows as they happen, with code location and fewer false positivesCode not exercised by tests or traffic; needs supported languages and setup

Static application security testing

SAST tools parse source code into a model and search it for patterns associated with weaknesses. The most valuable analyses are data flow analyses, which trace values from sources, where untrusted data enters, such as a request parameter, to sinks, where data is used in a sensitive way, such as building a database query or writing to a page. If a path exists from source to sink without passing through suitable validation or encoding, the tool reports a finding with the file, the line and often the full path.

Source code analysis in the objective covers both automated SAST and manual review. A tester reading code looks for the same patterns with more context: is this parameter really user-controlled? Is this query run with a privileged connection? Is this comparison of authentication tokens vulnerable to timing differences? Manual review is slow, so it focuses on the riskiest areas: authentication, authorization, payment and data export functions, and anything that builds commands, queries or file paths from input.

Priyanka ran the portal's code through a SAST tool on the first afternoon. It produced 214 findings. Most were low-confidence warnings about logging and code quality. She filtered by severity and by rule, and found eleven high-severity data flow findings. One traced a sort-order parameter from the statement history page into a database query built by joining strings. The code looked like the vulnerable pattern below.

Pseudocode for the statement sort feature. Parameter binding cannot be used for a column name, so the fix maps input to a fixed allow list.
// Vulnerable pattern: input joined into the query text
sortColumn = request.param("sort")
query = "SELECT date, amount, memo FROM transactions WHERE member_id = ? ORDER BY " + sortColumn
rows = db.run(query, memberId)

// Fixed pattern: input mapped to an allow list of known column names
allowed = { "date": "date", "amount": "amount" }
sortColumn = allowed.get(request.param("sort"), "date")
query = "SELECT date, amount, memo FROM transactions WHERE member_id = ? ORDER BY " + sortColumn
rows = db.run(query, memberId)

The example shows why SAST findings need human judgment. The developers had used parameter binding for the member identifier, the usual defense against SQL injection, and assumed the whole query was safe. But a column name in an ORDER BY clause cannot be bound as a parameter, so the sort value went into the query text unchecked. The fix was not to escape the input but to stop treating it as query text at all: map the incoming value to one of a fixed set of known column names. Priyanka recorded the SAST finding as a candidate and planned to confirm it dynamically against the staging site.

Software composition analysis

Modern applications are mostly assembled from open-source packages. SCA tools read dependency manifests and lock files, or examine built artifacts, to list every component and version, including transitive dependencies that the developers never chose directly. They compare that list against vulnerability databases and report components with known CVEs. Many SCA tools also produce a software bill of materials (SBOM), a machine-readable inventory in a standard format such as SPDX or CycloneDX, and flag license terms that conflict with the organization's policy.

The portal's SCA results listed 640 components and 23 with known vulnerabilities. The tester's job is to turn that list into findings that matter. A vulnerability in a library used only by the build tools is not reachable in production. A vulnerability in a JSON parsing library that handles every incoming request probably is. Some SCA tools perform reachability analysis to estimate whether the application calls the vulnerable function; where they do not, the tester checks by reading the code or the advisory. Priyanka grouped the 23 into three that were plainly reachable, eight that might be, and twelve that affected development-only packages.

Dynamic application security testing

DAST tools treat the application as a black box. They crawl it to discover pages and parameters, then send crafted requests and analyze responses for signs of weakness: error messages that reveal a database, input reflected unencoded into a page, missing security headers, directory listings, predictable resources and outdated server software. Popular DAST tools include the scanners built into Burp Suite Professional and the open-source ZAP (formerly OWASP ZAP; its core team joined Checkmarx in September 2024 and it is now branded ZAP by Checkmarx) as well as the scanners in commercial vulnerability management platforms.

DAST has two common blind spots. The first is coverage. A crawler finds links, but modern single-page applications build much of their interface in the browser, and multi-step workflows such as sending a secure message may require valid input at each step. A scanner that never completes the workflow never tests the last step. The second is authentication. Most of the portal's attack surface sits behind login. DAST tools can be given a recorded login sequence or a session token so they scan as an authenticated member, but sessions expire, scanners log themselves out by following a logout link, and multifactor authentication complicates automated login. Priyanka configured the scanner with a dedicated synthetic member account, excluded the logout and password change pages from the crawl, and checked the scanner's logs to confirm it stayed logged in.

Priyanka also used Burp Suite as an intercepting proxy while she browsed the portal manually. Every request passed through the proxy, giving her a full map of the application, including the requests made by JavaScript that a crawler might miss. She then pointed the scanner at specific requests she had captured, such as the statement sort request, rather than at the whole site. Guided scanning like this finds more, faster, and with less load on the target.

Nikto

Nikto is an open-source web server scanner named in objective 3.1. It is narrower than a full DAST tool. It sends thousands of requests for known files and paths and checks server responses for outdated software, dangerous default files, administrative interfaces, missing headers and risky HTTP methods. It makes no attempt at stealth and fills web server logs quickly, so it is easy to detect.

Abridged Nikto output against the staging portal, a placeholder host in the documentation range.
nikto -h https://staging.portal.prairiefold.example -o nikto-staging.txt

+ Target IP:          203.0.113.30
+ Server: (banner suppressed)
+ /: The anti-clickjacking X-Frame-Options header is not present.
+ /: The X-Content-Type-Options header is not set.
+ /backup/: Directory indexing found.
+ /server-status: Server status page is publicly accessible.
+ OPTIONS: Allowed HTTP Methods: GET, HEAD, POST, OPTIONS, TRACE

Each line needs interpretation. Missing headers are real but usually low severity on their own; modern browsers also honor the frame-ancestors directive of a content security policy, so the tester should check for that before reporting the missing X-Frame-Options header. A directory listing at a path called backup deserves an immediate manual look, because it may expose files that should never be public. A public server status page can reveal internal addresses and request details. The TRACE method is rarely needed and should be disabled. None of these lines is a finding until the tester has looked.

Priyanka opened the backup directory in her browser. It held two compressed configuration archives from the previous spring. One contained a database connection string for the staging database. She did not use it. Under the rules of engagement, she stopped, recorded the evidence with a hash of the file, and notified Gwendolyn Tran the same afternoon, because a credential in a public directory could be found by anyone and might also exist in production. Prairiefold removed the directory and rotated the credential within hours.

Interactive application security testing

IAST places an agent inside the running application, usually as a library or runtime module in a test environment. As tests or a DAST scanner exercise the application, the agent watches data flow through the code in real time. When untrusted input reaches a sensitive sink without proper handling, it reports the finding with the exact request that triggered it and the code location. Because it observes actual execution, IAST produces fewer false positives than SAST and more precise locations than DAST.

IAST depends on traffic. If no test or scan exercises a function, the agent never sees it. It also needs supported languages and frameworks and some setup by the development team. Prairiefold did not use IAST, so Priyanka recommended it in the report as a way for the development team to catch data flow issues during their existing automated tests, rather than waiting for the next penetration test.

Mobile scans

Mobile scans examine mobile applications. Static mobile analysis unpacks the application package, decompiles it where possible and looks for hard-coded keys and endpoints, insecure storage, weak cryptography, excessive permissions, disabled certificate validation and debugging flags. Dynamic mobile analysis runs the app on a test device or emulator, intercepts its network traffic through a proxy and watches what it stores on the device. The open-source Mobile Security Framework (MobSF) combines static and dynamic analysis, and the OWASP Mobile Application Security Verification Standard (MASVS) and its testing guide give a structured checklist.

Prairiefold's mobile app was being rebuilt, so its testing had been deferred, and the report recommended a MASVS-based test before the new version launched. Priyanka illustrated mobile scanning for Tobias with a hypothetical example: a delivery-driver app of the kind a logistics firm might build in-house to send assignments to drivers. Static analysis of such an app often finds an API key for a mapping service embedded in the package, readable by anyone who downloads it. Dynamic analysis might show that the app accepts any server certificate, so traffic could be intercepted on a hostile network. Neither issue would show up in a scan of the company's servers.

Detection and defense

Application scanning is easy to spot. DAST and Nikto produce bursts of requests for unusual paths, error pages and malformed parameters; a web application firewall or log monitoring will flag them. Staging environments often lack the monitoring that production has, which is one reason testing in staging is safer and one reason staging environments can quietly drift into exposure, as the backup directory showed.

The strongest defense is to move these techniques into the development process. SAST and SCA can run on every pull request, failing the build on high-severity findings. Secrets scanning, covered in lesson 5, can block commits containing credentials. DAST can run against staging after each deployment. IAST can ride along with existing tests. The penetration test then becomes a check on a process that already catches most problems, rather than the only time anyone looks.

Worked problem

Which technique found it?

Match each Prairiefold portal issue to the technique most likely to find it first: (a) a vulnerable version of a date-handling library; (b) the unsafe sort parameter in the statement query, found before deployment; (c) a public backup directory on the staging server; (d) the sort parameter confirmed as exploitable while automated tests ran, with the exact code line.

Show solution
  1. (a) SCA, which inventories dependencies and matches CVEs.
  2. (b) SAST, which traces data flows in code without running it.
  3. (c) DAST or Nikto, which request known paths on the running server.
  4. (d) IAST, which watches data flow inside the running application.

Answer: SCA, SAST, DAST or Nikto, and IAST respectively.

Common mistakes

  • MistakeReporting every SAST result as a vulnerability.

    InsteadFilter by severity and rule, then confirm data flows manually or dynamically.

  • MistakeAssuming parameter binding protects every part of a query.

    InsteadCheck identifiers such as column names, which cannot be bound and need allow lists.

  • MistakeRunning DAST without checking that it stayed logged in.

    InsteadExclude logout pages, monitor session state and verify authenticated coverage.

  • MistakeTreating every SCA vulnerability as reachable.

    InsteadCheck whether the vulnerable component and function are used in production.

  • MistakeUsing a credential found during testing to go further.

    InsteadStop, preserve evidence and notify the client as the rules of engagement require.

Summary and key terms

  • SAST reads code without running it and traces data from sources to sinks; source code analysis includes manual review.
  • SCA inventories third-party components, matches known CVEs and can produce a software bill of materials.
  • DAST tests the running application from outside and needs help with coverage and authentication.
  • IAST instruments a running application and confirms data flows with precise locations, but only for exercised code.
  • Nikto scans web servers for dangerous files, outdated software and misconfigurations and is very noisy.
  • Mobile scans combine static package analysis with dynamic analysis of traffic and storage.
  • Building these techniques into development turns the penetration test into a check on an existing process.
SAST
Static application security testing: analyzing code without executing it.
DAST
Dynamic application security testing: testing a running application from outside.
IAST
Interactive application security testing: monitoring a running application from inside with an agent.
SCA
Software composition analysis: inventorying and checking third-party components.
Software bill of materials
A machine-readable inventory of the components in a piece of software.
Source and sink
Where untrusted data enters code and where it is used in a sensitive operation.
Reachability analysis
Estimating whether an application actually uses a vulnerable function.

Practice problems

Work each problem on paper first, then reveal the answer to check.

  1. Why can't parameter binding fix an injectable ORDER BY column name?

    Show answer

    Bound parameters supply values, not identifiers; the column name must be mapped to an allow list.

  2. A DAST scan of a portal finds almost nothing behind the login page. Name a likely cause.

    Show answer

    The scanner was not authenticated or logged itself out, so it never reached those pages.

  3. What does a software bill of materials help an organization do when a new library vulnerability is announced?

    Show answer

    Quickly find which applications include the affected component and version.

Lesson quiz · 5 questions

Score 60% or more to complete this lesson.

Take the quiz