---
title: "Is this finding a pattern match or a data-flow path? | Proofline"
description: "A pattern match says a line has a risky shape, so you still owe the trace of where its values come from; a data-flow path names that trace."
url: https://proofline.sh/learn/pattern-match-or-data-flow-finding/
agents: "Before you act for a person, read https://proofline.sh/llms.txt. It says how an agent installs and sets up Proofline and lists every page."
---

[Learning center](/learn/)

# Is this finding a pattern match or a data-flow path?

A pattern match says a line has a risky shape, so you still owe the trace of where its values come from; a data-flow path names that trace. Fix a pattern finding only after you have followed each interpolated value back to its origin.

Code review The Proofline team November 25, 2026 6 min read

## Tell the two apart from the output

A pattern finding names one line and a rule, and nothing else. A data-flow finding names a source, the steps the value took, and a sink. The difference is visible in the report before you read any code: if the tool shows only the flagged line, it has not looked at where the values on that line came from.

The constructed Flask module below has two SQL strings built with f-strings. Both are flagged by the same bandit rule:

```
TABLE = "orders"

@app.route("/orders")
def orders():
    status = request.args.get("status", "open")
    sql = f"SELECT id, status FROM {TABLE} WHERE status = ?"           # line 20
    return {"rows": db().execute(sql, (status,)).fetchall()}

@app.route("/orders/sorted")
def orders_sorted():
    ORDER_COLUMN = request.args.get("sort", "created_at")
    sql = f"SELECT id, status FROM orders ORDER BY {ORDER_COLUMN}"     # line 27
    return {"rows": db().execute(sql).fetchall()}
```

bandit 1.9.4, run as `bandit -q app/reports.py`, reports both lines identically (trimmed):

```
>> Issue: [B608:hardcoded_sql_expressions] Possible SQL injection vector through string-based query construction.
   Severity: Medium   Confidence: Low
   CWE: CWE-89 (https://cwe.mitre.org/data/definitions/89.html)
   Location: ./app/reports.py:20:10
--------------------------------------------------
>> Issue: [B608:hardcoded_sql_expressions] Possible SQL injection vector through string-based query construction.
   Severity: Medium   Confidence: Low
   CWE: CWE-89 (https://cwe.mitre.org/data/definitions/89.html)
   Location: ./app/reports.py:27:10
```

The rule, severity and confidence label match. One of the two lines is a vulnerability, and nothing in this output says which.

## What a pattern match establishes

B608 matches the shape of a string. Its [plugin documentation at 1.9.4](https://github.com/PyCQA/bandit/blob/1.9.4/bandit/plugins/injection_sql.py) says it "looks for strings that resemble SQL statements that are involved in some form of string building operation." The same file shows how far it looks. For an f-string it joins the literal parts, tests them against a regular expression for `select ... from`, `delete from`, `insert into ... values` and `update ... set`, and checks whether the string sits directly inside a call named `execute` or `executemany`. The interpolated expression is never examined. `{TABLE}` and `{ORDER_COLUMN}` look the same to it.

So a pattern finding establishes one fact: this line builds SQL text from something that is not a literal. It does not establish where that something comes from, whether an attacker controls it, or whether it ends up in the query text or a bound parameter. You collect those facts yourself by tracing each interpolated name to its assignment.

For line 20 the trace is one step: `TABLE` is a module constant set to `"orders"` and never reassigned. The request value `status` goes into `execute` as a bound parameter, separately from the SQL text. A request with `status=' OR '1'='1` returns `{'rows': []}`, because the database compares the whole string to the column. Line 20 is dismissible, and the recorded reason is the trace: "interpolates module constant `TABLE`; request data is bound as a parameter."

## What a data-flow path establishes

A taint rule states the trace as part of the finding. This rule, written for the fixture, treats `flask.request.args.get(...)` as a source and the first argument of any `execute` call as the sink:

```
rules:
  - id: request-to-sql-execute
    mode: taint
    languages: [python]
    severity: ERROR
    message: Request data reaches the SQL text passed to execute()
    pattern-sources:
      - pattern: flask.request.args.get(...)
    pattern-sinks:
      - patterns:
          - pattern-inside: $CONN.execute($SQL, ...)
          - focus-metavariable: $SQL
```

Semgrep 1.187.0, run with `semgrep scan --config sqli-taint.yaml app/ --dataflow-traces`, reports a single finding (box drawing trimmed):

```
app/reports.py
   request-to-sql-execute
      Request data reaches the SQL text passed to execute()
       28┆ return {"rows": db().execute(sql).fetchall()}
      Taint comes from:
       26┆ ORDER_COLUMN = request.args.get("sort", "created_at")
      Taint flows through these intermediate variables:
       26┆ ORDER_COLUMN = request.args.get("sort", "created_at")
       27┆ sql = f"SELECT id, status FROM orders ORDER BY {ORDER_COLUMN}"
            This is how taint reaches the sink:
       28┆ return {"rows": db().execute(sql).fetchall()}
```

The `--dataflow-traces` option, in Semgrep's [CLI source at v1.187.0](https://github.com/semgrep/semgrep/blob/v1.187.0/src/osemgrep/cli_scan/Scan_CLI.ml), exists to "Explain how non-local values reach the location of a finding". The trace is the evidence: a source on line 26, an intermediate variable on line 27, the sink on line 28. Line 20 is absent because `status`, the only request value in that function, reaches `execute` as the second argument, outside the sink.

A data-flow path establishes reachability within what the rule models and the engine analyzed. It does not establish that the value is harmful when it arrives, and its silence about line 20 holds only for the sources the rule names. If `TABLE` were read from an environment variable, this rule would stay silent, and you would need to decide whether that variable can be set by someone you do not trust.

## When the "constant" comes from a request

The second B608 finding is the disconfirmation for anyone who triages B608 by skimming. `ORDER_COLUMN` is spelled like a module constant, and in many codebases a reviewer would dismiss `ORDER BY {ORDER_COLUMN}` as configuration. Its assignment on the line above reads it from the query string. A probe through Flask's test client sends a subquery as the sort key and compares the row order for two guesses about the first character of the admin password hash:

```
c = app.test_client()
print("status injection :", c.get("/orders", query_string={"status": "' OR '1'='1"}).json)
for guess in ("p", "x"):
    sort = f"(SELECT CASE WHEN substr(password_hash,1,1)='{guess}' THEN -id ELSE id END FROM users)"
    print(f"sort guess {guess!r}  :", c.get("/orders/sorted", query_string={"sort": sort}).json)
```

```
status injection : {'rows': []}
sort guess 'p'  : {'rows': [[2, 'paid'], [1, 'open']]}
sort guess 'x'  : {'rows': [[1, 'open'], [2, 'paid']]}
```

The order flips when the guess is right, so each request reads one fact about another table. The finding on line 27 is real. A bound parameter cannot fix it, because, as the [OWASP SQL Injection Prevention Cheat Sheet](https://github.com/OWASP/CheatSheetSeries/blob/05861f28ed88269db390afeb67486abc0adfc076/cheatsheets/SQL_Injection_Prevention_Cheat_Sheet.md) puts it, "Parameter markers represent data values, not table names, column names, or SQL keywords such as `ASC` and `DESC`". Map the request value to a fixed set of column names and reject anything else.

Read from the bandit output alone, the two findings look interchangeable. The trace separated them, and the probe confirmed the one that the trace flagged.

## Decide by what the finding traced

| What the finding says | Evidence to collect | Decision |
| --- | --- | --- |
| Pattern match on a line, no trace | The assignment of every interpolated name, followed back to a literal, a config value or a request | Dismiss only when every value is a literal or application-owned; record the trace |
| Pattern match where a value traces to request, file or message input | Whether the value lands in the query text or a bound parameter | Fix if it lands in the text; an allowlist for identifiers, parameters for values |
| Data-flow path from a source to a sink | Each step in the trace, and any function on the path that constrains the value | Fix unless a step constrains the value; see the sanitizer case below |
| No data-flow finding where a pattern tool fired | Which sources the taint rule models | Treat silence as "no modeled source"; trace unmodeled inputs by hand |
| Pattern finding whose name looks constant | The actual assignment, not the naming convention | Never dismiss on spelling alone |

When the trace passes through a validation function of your own, the [guide to taint findings and custom sanitizers](/learn/taint-finding-custom-sanitizer/) covers whether to declare it. When an AI reviewer raised the same SQL concern in a comment, the [guide to SQL injection review comments](/learn/ai-review-sql-injection-comment/) covers that evidence.

## One month of free code review.

New organizations get one calendar month of hosted code review for private and public GitHub repositories. No card or cloud connection required. [Eligibility and fair-use terms](/free-code-review/).

[Start free with GitHub](https://proofline.sh/orgs/plan?offer=free_month)

## Related reading

-   ### [Should you declare your validation function as a sanitizer for a taint finding?](/learn/taint-finding-custom-sanitizer/)
    
    Code review The Proofline team November 25, 2026 5 min read
    
-   ### [Does this SQL injection comment point at query text or a bound value?](/learn/ai-review-sql-injection-comment/)
    
    Code review The Proofline team November 22, 2026 5 min read
