Docs / design / taint-analysis-design · Edit on GitHub

Taint Analysis — Engineering Design

Source → sink dataflow tracking with sanitizer awareness: HTTP parameters, file reads, and other sources flowing into SQL, shell, render, and other sensitive sinks.

Taint Analysis tab — flows table (gbuilder)

Figure 1: Taint Analysis tab — per-function flow list with severity badges and source→sink paths.


1. Goals

GoalHow
Find risky data pathsIntra-procedural taint on CFG/PDG
Rank severityFlow severity score + vulnerable flag
Dashboard triageFunction sidebar + flows table
CLI verificationslice --taint and exported taint/*.json

Enabled by discover --with-cfg / --with-taint (language-dependent pattern catalogs).


2. Architecture overview

flowchart TB
  subgraph analysis["Per-function analysis"]
    SRC[Source patterns]
    SNK[Sink patterns]
    SAN[Sanitizer patterns]
    PDG[PDG traversal]
    SRC --> PDG
    SNK --> PDG
    SAN --> PDG
  end

  subgraph persist["Persist + export"]
    ARC[cfg_pdg.archive.bin]
    TI[taint_index.json]
    TD[taint/*.json]
    analysis --> ARC
    analysis --> TI
    analysis --> TD
  end

  subgraph ui["Dashboard"]
    TV[TaintView.tsx]
    TI --> TV
    TD --> TV
  end

3. Flow model

Each taint flow records:

  • Source statement / symbol
  • Sink statement / symbol
  • Intermediate path (when available)
  • Severity (0–10) and vulnerable boolean (sanitizer not on path)

Dashboard: filter vulnerable only; click a flow for path detail.


4. Rust implementation map

ComponentPath
Taint enginecrates/rgctl-analysis/src/taint.rs
Language sinks/sourcesPattern tables per rgctl-lang-*
Storagecrates/rgctl-analysis/src/storage.rs
Dashboard exportcrates/rgctl-dashboard/src/taint_export.rs
CLI taint slicesrc/cli/slice.rs (--taint)

5. Dashboard implementation

PiecePath
Tabdashboard/src/TaintView.tsx
Indextaint_index.json (flow_count, vulnerable_count)
Detail bundlestaint/{function_id}.json
LegendsviewLegendData.ts — severity / status badges

6. CLI usage

rgctl discover . --with-cfg --with-security --with-taint
rgctl slice src/Endpoint.java --line 20 --variable request --function handle --taint
# Inspect exported flows under .rgctl/analysis/ or dashboard taint/*.json

7. Testing

LayerLocation
Language taint fixturestests/*_taint.rs
Dashboard harnesstests/dashboard_harness.rs (taint_index.json)

Screenshots: capture-design-screenshots.mjsdocs/images/design/taint-analysis/.


8. Related docs