GeezerVison is showing github.com — taint(): sanitizer calls do not cut flows assigned at the call site (cross-language) · Issue #103 · codellm-devkit/.github
taint(): sanitizer calls do not cut flows assigned at the call site (cross-language) #103DescriptionSummary
taint() in python-sdk only stops a flow at a sanitizer when the path goes through the sanitizer's body. When the sanitizer's result is assigned at the call site (n = sanitize(x), n, err := strconv.Atoi(id)), the flow continues through the call statement, so a sanitized flow is still reported. This affects every language, because the analyzers' dataflow and the SDK walk share the same model.
Why
- The analyzers emit reaching-definitions data flow, not taint. A call statement uses its arguments and defines its left-hand side, so the data graph has a direct
x → n edge at the statement.
- codeanalyzer-python:
access_paths.py:350-356, :500-501
- codeanalyzer-go: the L3 call rule
- Call-site ports are wired coarsely: host statement → every
actual_in, and every actual_out → host. In codeanalyzer-python this is dataflow/sdg.py:36; Go's L4 does the same.
- That output is correct for data flow. The value of
n does depend on x.
- The SDK cuts too little. A sanitizer named as a callable resolves to that callable's id (
commons/resolve.py:490-491). The walk then excludes nodes under that id: commons/graphs.py:377-378 for Neo4j and python/codeanalyzer/codeanalyzer.py:1507 for local. The caller's call statement lives under the caller's id, so its x → n edge is never cut.
- Only a variable cut works.
("n", within=<caller>) severs the flow (commons/graphs.py:380-383).
Reproduction (Go)
codeanalyzer-go testdata/dataflow/httpsql, sqlRepo.SanitizedFind:
n, err := strconv.Atoi(id)
rows, err := r.db.Query("… " + strconv.Itoa(n))
- With
strconv.Atoi as a sanitizer, or with --library-models strconv/Atoi: [], the handler's request parameter still reaches database/sql.DB.Query's query.
- A variable cut on
n within SanitizedFind blocks it.
Expected
Naming a callable as a sanitizer cuts flows that pass through a call to it. That includes the caller-side flow from the call's arguments to the value it defines at the call site.
Possible approaches
-
SDK-side (no analyzer change). When a sanitizer callable S is named, find every call site of S (call_graph / body callee), then cut:
- the host statement's data edges whose
var is a base the call defines from S's results;
- or more simply, all data edges out of the host statement on the variables S's
actual_outs define.
This needs the call-site → result-variable mapping, which the actual_out of/parent and the host's defs provide.
-
Analyzer-side. Port-matched wiring at call sites: a call's results reach the host's defs only through its actual_outs. The statement-level edge stays for L3 monotonicity and is marked (e.g. a prov or edge property) so the taint walk can skip it at sanitized sites. That is a shared schema decision across analyzers.
-
Both. Approach 2 as the long-term model, approach 1 as the immediate fix.
Scope
Activitysinha108 commented on Oct 27, 2026 Additional finding: a variable cut on the sanitized value does not sever the flow either.
On the codeanalyzer-go httpsql fixture (-a 4), cutting var n within sqlRepo.SanitizedFind (the SDK's pair cut, commons/graphs.py:380-383) still leaves the handler's request parameter reaching DB.Query's query. There are three bypasses, and all three are correct data/control dependence at the reaching-definitions level:
- Implicit flow through the error check.
n, err := strconv.Atoi(id) also defines err. The edge chain is →[err] if err != nil →cdg→ the Query statement.
- The error return.
return nil, err → formal_out <return>:0 → param_out → the caller → back into SanitizedFind through the receiver actual_in → s.db → Query.
- Coarse host wiring at the caller. In
repo.SanitizedFind(id), the host statement feeds every use, including id, into every actual_in, including the receiver's. The flow then reaches Query through s.db without touching n.
Even with n, _ := strconv.Atoi(id), bypass 3 remains, and so does the control dependence from the Atoi statement (a possible panic) to the next statement.
Implication for the fix. A correct sanitizer model in taint() needs to decide all three of these:
- whether control dependence and implicit flow count as taint at all, or are excluded;
- how values derived from the sanitizer's other results, such as
err, are treated;
- whether coarse host wiring should be refined at the call site, i.e. port-matched wiring, approach 2 above.
Rewriting the program does not fix this. The analyzers' output is correct data flow.
MetadataMetadataDevelopmentNo branches or pull requestsIssue actions
|