NullSec TaintTrack

February 27, 2026 Β· View on GitHub

Taint Analysis Engine

A static taint analysis tool written in OCaml, demonstrating functional programming with strong static typing for vulnerability detection through data flow analysis.

OCaml Security Version License

🎯 Overview

NullSec TaintTrack performs static taint analysis to trace data flow from untrusted sources (user input, network data) to security-sensitive sinks (SQL queries, command execution), identifying injection vulnerabilities.

✨ Features

  • Source Tracking - Monitor user input, network data, file reads
  • Sink Detection - SQL queries, command execution, file writes
  • Flow Analysis - Trace data through program paths
  • Sanitizer Recognition - Detect when data is properly sanitized
  • CWE Mapping - Common Weakness Enumeration references
  • MITRE ATT&CK - Technique identification

πŸ” Vulnerability Detection

VulnerabilitySource β†’ SinkCWEMITRE
SQL InjectionUserInput β†’ SQLQueryCWE-89T1190
Command InjectionUserInput β†’ CommandExecCWE-78T1059
XSSUserInput β†’ HTMLOutputCWE-79T1189
Path TraversalUserInput β†’ FileWriteCWE-22T1083
SSRFUserInput β†’ NetworkSendCWE-918T1090
Log InjectionUserInput β†’ LogOutputCWE-117T1070
Code InjectionUserInput β†’ EvalCWE-94T1059

πŸ“¦ Installation

# Clone the repository
git clone https://github.com/bad-antics/nullsec-tainttrack
cd nullsec-tainttrack

# Compile with ocamlfind
ocamlfind ocamlopt -o tainttrack tainttrack.ml

# Or compile with ocamlopt directly
ocamlopt -o tainttrack tainttrack.ml

# Run without compilation
ocaml tainttrack.ml

πŸš€ Usage

# Analyze source directory
./tainttrack src/

# JSON output
./tainttrack -j project/

# Verbose mode
./tainttrack -v app/

# List sources and sinks
./tainttrack --sources
./tainttrack --sinks

# Run demo mode
./tainttrack

πŸ’» Example Output

╔══════════════════════════════════════════════════════════════════╗
β•‘            NullSec TaintTrack - Taint Analysis Engine            β•‘
β•šβ•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•

[Demo Mode]

Analyzing sample taint flows...

Analyzed 7 flows, found 6 vulnerabilities

  [CRITICAL] SQL Injection
    Source:  USER_INPUT
    Sink:    SQL_QUERY
    CWE:     CWE-89
    MITRE:   T1190

    Data Flow:
      β†’ request.params['id'] (app.py:45)
      β†’ user_id (app.py:46)
      β†’ db.execute(query) (app.py:50)

  [CRITICAL] Command Injection
    Source:  NETWORK_DATA
    Sink:    COMMAND_EXEC
    CWE:     CWE-78
    MITRE:   T1059

    Data Flow:
      β†’ socket.recv() (server.py:100)
      β†’ cmd_data (server.py:101)
      β†’ os.system(cmd) (server.py:105)

  [HIGH] Cross-Site Scripting
    Source:  USER_INPUT
    Sink:    HTML_OUTPUT
    CWE:     CWE-79
    MITRE:   T1189

    Data Flow:
      β†’ request.args['name'] (views.py:20)
      β†’ username (views.py:21)
      β†’ render_template() (views.py:25)

═══════════════════════════════════════════

  Summary:
    Total Findings: 6
    Critical:       2
    High:           3
    Medium:         1
    Low:            0

πŸ—οΈ Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                    Source Code Parser                        β”‚
β”‚              Python | JavaScript | Java | PHP               β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                           β”‚
                           β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                  Data Flow Graph Builder                     β”‚
β”‚         Track variable assignments and propagation          β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                           β”‚
           β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
           β–Ό               β–Ό               β–Ό
     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”   β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”   β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
     β”‚  Source  β”‚   β”‚Propagate β”‚   β”‚   Sink   β”‚
     β”‚  Finder  β”‚   β”‚  Taint   β”‚   β”‚  Finder  β”‚
     β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜   β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜   β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
           β”‚               β”‚               β”‚
           β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                           β–Ό
                   β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                   β”‚Vulnerability β”‚
                   β”‚Classificationβ”‚
                   β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Ξ» OCaml Features Demonstrated

  • Variant Types - taint_source, taint_sink, vulnerability
  • Pattern Matching - Exhaustive case analysis
  • Option Types - vulnerability option for maybe values
  • Records - flow_node, taint_flow, finding
  • Higher-Order Functions - List.filter_map, List.iter
  • Modules - Color module for ANSI codes
  • Type Inference - Automatic type deduction
  • Immutability - Default immutable data structures

πŸ”§ Type Definitions

(* Taint flow record *)
type taint_flow = {
  source: taint_source;
  sink: taint_sink;
  nodes: flow_node list;
  vulnerability: vulnerability option;
}

(* Analysis finding *)
type finding = {
  severity: severity;
  flow: taint_flow;
  description: string;
  cwe: string;
}

πŸ“Š Taint Sources

SourceDescription
UserInputHTTP parameters, form data
NetworkDataSocket recv, API responses
FileReadFile contents
EnvironmentVarEnvironment variables
DatabaseQueryDatabase results
ExternalAPIThird-party API data
CommandLineCLI arguments

πŸ›‘οΈ Security Use Cases

  • SAST - Static Application Security Testing
  • Code Review - Automated vulnerability detection
  • CI/CD Integration - Pre-commit security checks
  • Compliance - OWASP Top 10 detection
  • Training - Security awareness examples

This tool is intended for:

  • βœ… Authorized code review
  • βœ… Security testing of owned applications
  • βœ… Educational purposes
  • βœ… Research and development

Only analyze code you're authorized to review.

πŸ“„ License

MIT License - See LICENSE file for details.

🏷️ Version History

  • v1.0.0 - Initial release with taint analysis and vulnerability classification

Part of the NullSec Security Toolkit