Skip to main content

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

Project description

Microtaint

Microtaint is a lightweight, strictly typed Python library for generating bit-precise taint dataflow rules directly from raw instruction bytestrings.

Using pypcode (the Ghidra P-Code lifter under the hood), Microtaint translates machine instructions (x86, AMD64, ARM64, etc.) into intermediate representation and then mathematically simplifies the side-effects into near boolean logic circuits. This creates an exact formula identifying which bits of the output registers/memory depend on which bits of the input state.

The circuits leverage the instruction they want to instrument in order to simulate precise taint propagation.

Microtaint serves purely as a standalone abstract equation generator, capable of seamlessly feeding taint analysis engines or symbolic execution frameworks.

Features

  • Bit-precise Taint Rules: Stop relying on rough block-level taints. Microtaint evaluates partial register uses, bitwise operations, and flags dependencies strictly.
  • Fast & Stateless: Pure functional rule generator. You pass instruction bytes and context; you get back mathematical ASTs (LogicCircuit).
  • Ghidra/angr P-Code Backend: Robust and multi-architecture instruction lifting via pypcode.

Demo

The tool takes raw architecture bytestrings, lifts them, and maps the output back to your provided logical state (a list of tracked registers). Check out the demo.py file.

Development & Testing

# Run type checking
uv run mypy .

# Lint & Format
uv run ruff check .

# Run Tests
uv run pytest

Understanding the Formulas

When you generate rules (as shown in the demo), you receive an abstract representation of how taints flow constraint-by-constraint.

An output formula looks like this:

((SimulateCell(instr=0x4801d8, out=RAX[63:0], RAX=(V_RAX[63:0] OR T_RAX[63:0]), RBX=(V_RBX[63:0] OR T_RBX[63:0])) XOR SimulateCell(instr=0x4801d8, out=RAX[63:0], RAX=(V_RAX[63:0] AND NOT(T_RAX[63:0])), RBX=(V_RBX[63:0] AND NOT(T_RBX[63:0])))) OR (T_RAX[63:0] OR T_RBX[63:0]))

Here's how to read the components:

  • V_RAX[...]: Denotes the actual concrete runtime Value of the register RAX at specific bits.
  • T_RAX[...]: Denotes the Taint label (boolean/bitmask array) of RAX at specific bits.
  • SimulateCell(instr=0x..., out=REG, args...): Defines a computational constraint wrapper. It acts as an evaluation node that simulates the target bits of the output (out=REG) when evaluated through exactly that instruction (instr=0x...). This bridges mathematical abstraction to real architectural execution semantics, feeding exactly into constraint solvers like Z3/Claripy.
  • XOR differential: The formula often evaluates the SimulateCell twice—once with the taint labels masked in (OR T_...), and once with them masked out (AND NOT(T_...)). The XOR of these two simulations is a strict mathematical proof of whether those specific tainted bits modified the final output target. If the XOR is nonzero, the taint successfully propagated!

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.1.0.tar.gz (52.3 kB view details)

Uploaded Source

Built Distribution

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

microtaint-0.1.0-py3-none-any.whl (22.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: microtaint-0.1.0.tar.gz
  • Upload date:
  • Size: 52.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.2 {"installer":{"name":"uv","version":"0.11.2","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.1.0.tar.gz
Algorithm Hash digest
SHA256 1262d93c77f090a38a36f6a0e6d06a39e7f90eb938053eb65bcbf8606c0a9687
MD5 c31f96fd093652dfce3de43469c3ff63
BLAKE2b-256 338e1d7de1e7300da92eede2047992a90db53feba58654b8d376e923639edcc3

See more details on using hashes here.

File details

Details for the file microtaint-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: microtaint-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 22.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.2 {"installer":{"name":"uv","version":"0.11.2","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.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d6b767d20b6144386bb5c9f307b87cf4a33fca8277be09a1e680088774a60cf7
MD5 bf5a8575bfcb187e588d875b8422f3e9
BLAKE2b-256 fd85ad140f72c7c01ac3cb301121e3bff5c4de92bf8a7fe846a4c3faa39ad6ee

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