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.1.tar.gz (77.6 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.1-py3-none-any.whl (65.4 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for tainter-1.0.1.tar.gz
Algorithm Hash digest
SHA256 aff3f159cf3d6a7cfc0a09a9fec2a9963ce988585cfc6203d2f752ad8ff80199
MD5 15063a3d4a280b3962a342735bf9cf13
BLAKE2b-256 754ea5c376e2b73b661383bb3f013e0100641a6aba4104efa21a5305b250f7b1

See more details on using hashes here.

Provenance

The following attestation bundles were made for tainter-1.0.1.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.1-py3-none-any.whl.

File metadata

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

File hashes

Hashes for tainter-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 89b8415aea6838ae8ddc47d80816aa35bbd020e16b5131ef240f5786115f0b3b
MD5 6bc98cc8578b41beee2e34b4668e8d22
BLAKE2b-256 9a69078d7f8055fcb936dfd77bf5418dfca05e0e4fd69d699d293557f0135b25

See more details on using hashes here.

Provenance

The following attestation bundles were made for tainter-1.0.1-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