Skip to main content

Bit-precise taint rules generation using Ghidra's P-Code.

Project description

Microtaint

Benchmarks and evaluation

The benchmark and evaluation scripts used for the submission are present in the benchmark sub directory. To know how to run each script a dedicated README is present in the subdir.

Introduction

Microtaint is a strictly typed Python library and command-line engine for performing bit-precise, dynamic Information Flow Tracking (IFT) on compiled binaries.

Originally an abstract rule generator based on the CELLIFT paradigm, Microtaint has evolved into a complete, out-of-the-box dynamic taint analysis emulator. Built on top of Qiling and Unicorn, it dynamically monitors program execution, identifies complex exploitation primitives (Buffer Overflows, Use-After-Frees, Side Channels, and Arbitrary Indexed Writes) and logs them in real-time.

It retains its foundational mathematical precision: behind the scenes, Microtaint still lifts executed instructions using Ghidra's P-Code (pypcode) and models them as logical ASTs, computing taint propagation rigorously down to individual carry/zero flags and partial register mutations.

Features

  • Out-of-the-box Vulnerability Hunting: Pre-built command-line flags to instantaneously trace standard input flows and check for vulnerabilities:
    • BOF (Buffer Overflow): Detects when the instruction pointer (RIP/PC) becomes tainted.
    • UAF (Use After Free): Monitors heap operations via a built-in HeapTracker and alarms on poisoned mapping accesses.
    • AIW (Arbitrary Indexed Write): Detects store operations executing with tainted pointer addresses.
    • SC (Side Channels): Emits findings when critical conditional branching decisions depend on tainted input.
  • Qiling-Powered Emulation Wrapper: Fully integrates with the Qiling Framework. Drop your ELF/PE/Mach-O binaries in with a custom rootfs, and Microtaint wraps the CPU states gracefully.
  • High-Performance Tracing: Built-in Cython BitPreciseShadowMemory, direct Unicorn state hooks, and custom JIT caching ensure fast execution capabilities.
  • Bit-Precise Rule Generation: Still capable of generating mathematical formulas statically (via generate_static_rule), treating raw assembly instructions as monolithic logical circuits evaluated using simulated differentials.

Installation

Microtaint is available on the pypi, so you can use uv/pip/your_favorite_tool to install it.

If you want to build it locally then once you cloned the repo you can use uv to build it.

uv sync --reinstall-package=microtaint

For performance optimized builds of the leftover python code... (I am not so sure this makes any difference since the Cython and C migration of the hotpath. But before this enabled quite a good improvement)

HATCH_BUILD_HOOKS_ENABLE=1 MYPYC_OPT_LEVEL=3 uv sync --reinstall-package=microtaint

Command Line Usage

Use the provided microtaint command to execute and dynamically analyze a binary. Provide flags before the -- separator. Any arguments after -- represent the execution format for your compiled target.

# Detect everything, feed stdin automatically from the terminal
uv run microtaint --check-all -- ./binary arg1 arg2

# Read binary taint source from a specific file instead of stdin
uv run microtaint --check-bof --input payload.bin -- ./binary

# Pipe raw data directly to the binary while applying the UAF trace
python -c "print('A'*64)" | uv run microtaint --check-uaf -- ./binary

# Execute quietly and emit structured JSON findings (useful for CI/fuzzers)
uv run microtaint --check-all --quiet --json -- ./binary 2>/dev/null

Python API Integration

1. Qiling Emulator Integration (High-Level)

The MicrotaintWrapper can be integrated manually onto any existing Qiling instance. This provides fine-grained control to programmatically trace or assert bitwise taints seamlessly during full-system/binary emulation.

from qiling import Qiling
from microtaint.emulator.wrapper import MicrotaintWrapper

# Setup standard Qiling Environment
ql = Qiling(["path/to/binary"], rootfs="/custom/rootfs")

# Mount Bit-Precise Taint Engine on top
wrapper = MicrotaintWrapper(ql)

# Enable active security modules
wrapper.check_bof = True  # Track instruction pointers
wrapper.check_aiw = True  # Track memory addresses
wrapper.check_uaf = True  # Monitor frees

# Taint specific memory regions (e.g. 12 bytes at 0x1000)
wrapper.taint_region(0x1000, 12, "my_custom_tag")

# Run Emulator
ql.run()

# Review findings identified by the Reporter
for finding in wrapper.reporter.findings:
    print(finding)

2. Stateless AST Generation (Low-Level)

For cases where you don't need full emulation but want to analyze the math and formulas of taint propagation for a specific instruction byte string, you can directly interface with the static generator and native evaluator:

from microtaint.sleigh.engine import generate_static_rule
from microtaint.simulator import CellSimulator
from microtaint.instrumentation.ast import EvalContext
from microtaint.types import Architecture, Register

arch = Architecture.AMD64
simulator = CellSimulator(arch)

# 1. Provide an instruction (AND EAX, 0x0F0F)
bytestring = bytes.fromhex('250f0f0000')

# 2. Lift it into a stateless logical circuit (AST)
circuit = generate_static_rule(arch, bytestring, [Register('RAX', 64)])

# 3. Form a concrete runtime execution context
ctx = EvalContext(
    input_values={'RAX': 0xFFFF},
    input_taint={'RAX': 0xFFFF},
    simulator=simulator
)

# 4. Mathematically evaluate how the taint propagates bit-by-bit
output_taint = circuit.evaluate(ctx)
# output_taint['RAX'] bitmask mathematically evaluates to 0x0F0F

Development & Testing

Run tests and check typings/formatting with:

uv run mypy .
uv run ruff check .
uv run pytest

If a C/Cython file has been modified it is necessary to force a rebuild of the .so shared libraries with a

uv sync --reinstall-package=microtaint

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

microtaint-0.6.9.tar.gz (161.4 kB view details)

Uploaded Source

Built Distributions

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

microtaint-0.6.9-cp313-cp313-win_amd64.whl (810.3 kB view details)

Uploaded CPython 3.13Windows x86-64

microtaint-0.6.9-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl (1.0 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ x86-64manylinux: glibc 2.28+ x86-64

microtaint-0.6.9-cp313-cp313-macosx_11_0_arm64.whl (846.4 kB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

microtaint-0.6.9-cp312-cp312-win_amd64.whl (810.7 kB view details)

Uploaded CPython 3.12Windows x86-64

microtaint-0.6.9-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl (1.0 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64manylinux: glibc 2.28+ x86-64

microtaint-0.6.9-cp312-cp312-macosx_11_0_arm64.whl (850.9 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

File details

Details for the file microtaint-0.6.9.tar.gz.

File metadata

  • Download URL: microtaint-0.6.9.tar.gz
  • Upload date:
  • Size: 161.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.13 {"installer":{"name":"uv","version":"0.11.13","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for microtaint-0.6.9.tar.gz
Algorithm Hash digest
SHA256 14e61cdac64e6f56eda7228393ee63c40e7f03c76897c1d3b660c2938334cfa5
MD5 6968e815e84b7d35b4e9d37c806bd502
BLAKE2b-256 c5369d968117a4643420c773123bd3a9869af22a917566a537775bea51ddd939

See more details on using hashes here.

File details

Details for the file microtaint-0.6.9-cp313-cp313-win_amd64.whl.

File metadata

  • Download URL: microtaint-0.6.9-cp313-cp313-win_amd64.whl
  • Upload date:
  • Size: 810.3 kB
  • Tags: CPython 3.13, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.13 {"installer":{"name":"uv","version":"0.11.13","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for microtaint-0.6.9-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 e950605348c0bffcdb8b1276419af93df190ec44128cd1b46457f67251520f47
MD5 51505f79ab9034f038225a7b33fdd7e8
BLAKE2b-256 b924eb563c510a589f10d1231a875a71ff58d290f4ec235deac3c1cc41faf7fc

See more details on using hashes here.

File details

Details for the file microtaint-0.6.9-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl.

File metadata

  • Download URL: microtaint-0.6.9-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
  • Upload date:
  • Size: 1.0 MB
  • Tags: CPython 3.13, manylinux: glibc 2.17+ x86-64, manylinux: glibc 2.28+ x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.13 {"installer":{"name":"uv","version":"0.11.13","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for microtaint-0.6.9-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 0fd4ec2660cd37619179848b54d3002c3fd7c9122349216a4c564d0e2e66313b
MD5 5eb4af66d100224121408fedcd10a5d1
BLAKE2b-256 5ed26f932f6e338112e567926cd0a9414a4397427187be40ec7b2884b83cc2c0

See more details on using hashes here.

File details

Details for the file microtaint-0.6.9-cp313-cp313-macosx_11_0_arm64.whl.

File metadata

  • Download URL: microtaint-0.6.9-cp313-cp313-macosx_11_0_arm64.whl
  • Upload date:
  • Size: 846.4 kB
  • Tags: CPython 3.13, macOS 11.0+ ARM64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.13 {"installer":{"name":"uv","version":"0.11.13","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for microtaint-0.6.9-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 43e69d85c5dd820e439cba5706d86cea17e837934f7413b08d741b1292855421
MD5 869238a8dafc21e1e4adc81920bed20a
BLAKE2b-256 c2e422a6e9a52ff0f09a7afb05d61890eba8af49a5bac1938d65ab026a92b60b

See more details on using hashes here.

File details

Details for the file microtaint-0.6.9-cp312-cp312-win_amd64.whl.

File metadata

  • Download URL: microtaint-0.6.9-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 810.7 kB
  • Tags: CPython 3.12, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.13 {"installer":{"name":"uv","version":"0.11.13","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for microtaint-0.6.9-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 4abdc1d7062ffb06ef64102130d3f21d946a9ec34aa709c1f220d891f339cc60
MD5 f6472bc883bdf619d4c243b55009ac67
BLAKE2b-256 2ecdc9f5459cd680b977387602b8219ceaa5da26be70aae940b43a4f8cc2e67a

See more details on using hashes here.

File details

Details for the file microtaint-0.6.9-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl.

File metadata

  • Download URL: microtaint-0.6.9-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
  • Upload date:
  • Size: 1.0 MB
  • Tags: CPython 3.12, manylinux: glibc 2.17+ x86-64, manylinux: glibc 2.28+ x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.13 {"installer":{"name":"uv","version":"0.11.13","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for microtaint-0.6.9-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 8d019e100a8664ed4f27612b7233d7500474964a1c31bcf4c6f300496e809a43
MD5 cc9d76be8994fce2d139da22c78b4953
BLAKE2b-256 114a7a246bb518520a8d6b1551377b63e217afcc4e54780172e952e62acdd746

See more details on using hashes here.

File details

Details for the file microtaint-0.6.9-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

  • Download URL: microtaint-0.6.9-cp312-cp312-macosx_11_0_arm64.whl
  • Upload date:
  • Size: 850.9 kB
  • Tags: CPython 3.12, macOS 11.0+ ARM64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.13 {"installer":{"name":"uv","version":"0.11.13","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for microtaint-0.6.9-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 076b6373d25acf3e61b05db92e38278481d743eed749400e6180aa5551570463
MD5 71e57cb98fd7ab431944760922d69e2d
BLAKE2b-256 20e42da46b5e2b374b0bc806ea3b8f1203a1b4eaf8dfcf08e5cc407e56ff078d

See more details on using hashes here.

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