Skip to main content

A taint analysis engine for identifying source-to-sink vulnerability flows

Project description

๐Ÿ” Tainter

A taint analysis engine for identifying source โ†’ sink vulnerability flows in real-world codebases.

Features

  • Inter-procedural analysis: Track taint across function boundaries and multiple files
  • Multi-language parsing: Parse Python and Java source trees
  • Language auto-selection: Count py/java/js/go files and activate analyzers from project composition
  • Framework-aware: Built-in support for Flask, Django, FastAPI, and CLI applications
  • Extensible models: Define custom sources, sinks, and sanitizers
  • Multiple reporters: Console, JSON, and SARIF output with flow explanations

Current status: Python and Java taint-flow detection are wired. JavaScript and Go are counted for auto-selection but analyzer implementations are not wired yet.

Vulnerability Classes

Tainter detects flows leading to:

Class Description
SQLi SQL Injection via unsanitized database queries
RCE Remote Code Execution via eval, exec, os.system, etc.
SSTI Server-Side Template Injection
SSRF Server-Side Request Forgery
Deserialization Unsafe deserialization via pickle, yaml.load, etc.
Path Traversal Unvalidated file path operations

Installation

pip install tainter

Or for development:

git clone https://github.com/your-org/tainter.git
cd tainter
pip install -e ".[dev]"

Quick Start

# Scan a Python project
tainter scan /path/to/project

# Scan with specific vulnerability focus
tainter scan /path/to/project --vuln-class sqli --vuln-class rce

# Scan only Java files
tainter scan /path/to/project --language java

# Scan only JavaScript/Go inventory (will report no active analyzer yet)
tainter scan /path/to/project --language js --language go

# Output in SARIF format
tainter scan /path/to/project --format sarif -o results.sarif

How It Works

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚ Sources โ”‚โ”€โ”€โ”€โ–ถโ”‚ Taint   โ”‚โ”€โ”€โ”€โ–ถโ”‚ Flow    โ”‚โ”€โ”€โ”€โ–ถโ”‚ Report  โ”‚
โ”‚ (input) โ”‚    โ”‚ Tracker โ”‚    โ”‚ Finder  โ”‚    โ”‚ Builder โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜    โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜    โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜    โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
     โ”‚              โ”‚              โ”‚              โ”‚
     โ–ผ              โ–ผ              โ–ผ              โ–ผ
  request.args   propagate    find paths    JSON/SARIF
  input()        across       to sinks      with context
  os.environ     functions

Example Output

{
  "flows": [
    {
      "id": "FLOW-001",
      "vulnerability_class": "sqli",
      "confidence": 0.95,
      "source": {
        "file": "app/routes.py",
        "line": 15,
        "code": "user_id = request.args.get('id')"
      },
      "sink": {
        "file": "app/db.py",
        "line": 42,
        "code": "cursor.execute(f\"SELECT * FROM users WHERE id = {user_id}\")"
      },
      "call_chain": [
        "routes.get_user()",
        "db.fetch_user(user_id)"
      ],
      "variable_path": ["user_id", "id_param", "query"]
    }
  ]
}

Architecture

Tainter is built with separation of concerns:

  • Parser: AST-based Python parsing
  • Graph Builder: Call graph and data flow graph construction
  • Models: Extensible source/sink/sanitizer definitions
  • Analyzer: Taint propagation with inter-procedural flow tracking and basic branch handling
  • Reporter: Multiple output formats

Configuration

Built-in sources, sinks, and sanitizers are available by default. Project-local model configuration is not implemented yet.

License

MIT License

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

tainter-1.0.2.tar.gz (100.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

tainter-1.0.2-py3-none-any.whl (80.4 kB view details)

Uploaded Python 3

File details

Details for the file tainter-1.0.2.tar.gz.

File metadata

  • Download URL: tainter-1.0.2.tar.gz
  • Upload date:
  • Size: 100.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for tainter-1.0.2.tar.gz
Algorithm Hash digest
SHA256 a9f772228b0367137441b54cbd2b7da5ae5b0682c98fa3f2ea7c269c902bae04
MD5 10dbfd0c40d79bd6679756f29f104228
BLAKE2b-256 9bc595b03c0ddfedaf1b57162c8ffa5f9079280f6677031f5681e23e8af82056

See more details on using hashes here.

Provenance

The following attestation bundles were made for tainter-1.0.2.tar.gz:

Publisher: python-publish.yml on ihrishikesh0896/tainter

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file tainter-1.0.2-py3-none-any.whl.

File metadata

  • Download URL: tainter-1.0.2-py3-none-any.whl
  • Upload date:
  • Size: 80.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for tainter-1.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 adcaa71a749d9383a5bf8dd892b948328d17ddf184907a91938f8fbe3f1509d5
MD5 022cd63fdee9dc48828e8de23df0a2d8
BLAKE2b-256 ebc1dbc20e57c596b82a4f8ebf53722b46f32cf8ffb4589970886a20f6ed320b

See more details on using hashes here.

Provenance

The following attestation bundles were made for tainter-1.0.2-py3-none-any.whl:

Publisher: python-publish.yml on ihrishikesh0896/tainter

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page