Course contentsShow
← Security
Lesson 1361 of 3,05228. Application Security - TestingFree lesson

Control Flow Analysis and Path Sensitivity

Understanding how SAST tools analyze program control flow and track conditions to reduce false positives.

Control Flow Analysis and Path Sensitivity

You'll learn how SAST tools track the different execution paths in your code to understand which vulnerabilities are actually reachable.

What Is Control Flow Analysis?

After building an Abstract Syntax Tree (AST) and performing data flow analysis, SAST tools need to understand how your program executes. Control flow analysis maps out all the possible paths code can take—every if, else, switch, loop, and function call creates branches in execution.

Think of your program like a choose-your-own-adventure book. Control flow analysis reads every possible storyline, tracking which pages you can reach from any starting point.

Path Sensitivity Explained

Path sensitivity means the tool remembers the conditions and checks that happened earlier in a code path. Instead of treating every line as equally reachable, path-sensitive analysis considers:

  • Guard conditions: "If we reach line 50, we know the if (user != null) check on line 45 passed"
  • Validation checks: "This SQL query only executes when input was sanitized three lines earlier"
  • Impossible paths: "This variable can never be null here because we returned early if it was"

This dramatically reduces false positives. Without path sensitivity, a SAST tool might warn about every possible null pointer dereference—even when your code has explicit null checks protecting them.

Why It Matters for Security

Path-sensitive control flow analysis helps SAST tools understand that a potential vulnerability on line 100 might be protected by a security check on line 95. The tool can determine: "Yes, unsanitized input could reach this SQL query, but only through paths where we validate it first."

This makes SAST results more actionable—fewer false alarms about issues that are already guarded against.

Key Takeaway: Control flow analysis maps execution paths through your code, while path sensitivity remembers conditions along those paths, allowing SAST tools to distinguish between real vulnerabilities and code that's already protected by validation checks.