Skip to main content

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

Project description

Microtaint

Microtaint is a strictly typed Python library for generating and evaluating bit-precise, dynamic Information Flow Tracking (IFT) rules directly from raw instruction bytestrings.

Inspired by the hardware-level methodologies of the CELLIFT paper, Microtaint elevates the concept of mathematical "cell properties" to software ISAs. By combining the static analysis power of Ghidra's P-Code with the concrete execution accuracy of the Unicorn Engine, Microtaint computes perfectly precise taint propagation—including complex edge cases like partial register zero-extensions, bitwise arithmetic ripples, and architecture-specific condition flags (like x86's EFLAGS and ARM64's NZCV).

Microtaint serves as a standalone abstract equation generator and evaluator, capable of seamlessly feeding dynamic taint analysis engines or symbolic execution frameworks without requiring manually written semantics for thousands of instructions.

Features

  • Bit-Precise Taint Rules: Stop relying on rough block-level or byte-level taints. Microtaint tracks dependencies precisely down to the exact bit, handling shifts, partial registers, and individual flag propagation flawlessly.
  • CELLIFT Software Paradigm: Automatically classifies machine instructions into mathematical archetypes (Mapped, Monotonic, Transportable, Translatable, Avalanche, etc.) to apply optimized tracking formulas.
  • Dual-Engine Architecture: - Uses pypcode to lift instructions, compute backwards slices, and extract architectural dependencies statically.
    • Uses unicorn to natively simulate the generated logical differentials, bypassing the need to build massive shadow-logic ASTs.
  • Fast & Stateless ASTs: Pass in instruction bytes and your CPU state format; get back a mathematical AST (LogicCircuit) that can be evaluated against any dynamic concrete state.

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 to see it in action, or evaluate a circuit dynamically:

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)
bytestring = bytes.fromhex("4801D8") # ADD RAX, RBX

# 1. Generate the static Logic Circuit
circuit = generate_static_rule(arch, bytestring, [Register('RAX', 64), Register('RBX', 64)])

# 2. Evaluate dynamically against concrete Values (V) and Taints (T)
ctx = EvalContext(
    input_values={'RAX': 0x0, 'RBX': 0x0},
    input_taint={'RAX': 0x0, 'RBX': 0x10}, # Bit 4 of RBX is tainted
    simulator=simulator
)
output_taint = circuit.evaluate(ctx) 
# output_taint['RAX'] will mathematically evaluate to 0x10

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, you receive an abstract syntax tree representing how taints flow constraint-by-constraint. Because we treat each assembly instruction as a monolithic computational "Cell" ($C$), the formulas rely heavily on mathematical differentials.

An output formula assignment looks like this:

T_RAX[63:0] = (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 is how to read the components of Microtaint's engine:

  • V_REG and T_REG: Denotes the actual concrete runtime Value ($V$) and the Taint mask ($T$) of the register at specific bits.
  • SimulateCell(...): This node takes the concrete instruction and natively executes it inside the Unicorn Engine using a specialized subset of the state. It acts as a perfect architectural oracle.
  • The Logical Differential (XOR): Instead of guessing how an ADD or IMUL mixes bits, we calculate the differential: $C(V \lor T) \oplus C(V \land \neg T)$. We execute the cell once with all tainted bits forced to 1 (High Replica), and once with all tainted bits forced to 0 (Low Replica). The XOR of these two simulations is a strict mathematical proof: if the output changes between the two replicas, the taint successfully propagated to that specific output bit.
  • Polarity ($p$): Some instructions (like SUB) are bitwise non-increasing—meaning forcing an input bit to 0 actually makes the result higher. Microtaint's Sleigh backend automatically detects operations that invert polarity and flips their replicas ($V \land \neg T$ becomes the High replica) to ensure the differential accurately captures borrows and underflows.
  • Transportability Term (OR (T_RAX ... OR T_RBX)): If Sleigh classifies an instruction as an arithmetic "Transportable" cell (like ADD), the differential is combined with the direct bitwise OR of the input taints, guaranteeing that information flowing perfectly column-by-column isn't masked by identical values.

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.5.0.tar.gz (205.8 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.5.0-cp313-cp313-win_amd64.whl (449.9 kB view details)

Uploaded CPython 3.13Windows x86-64

microtaint-0.5.0-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl (1.9 MB view details)

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

microtaint-0.5.0-cp313-cp313-macosx_11_0_arm64.whl (527.5 kB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

microtaint-0.5.0-cp312-cp312-win_amd64.whl (450.7 kB view details)

Uploaded CPython 3.12Windows x86-64

microtaint-0.5.0-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl (1.9 MB view details)

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

microtaint-0.5.0-cp312-cp312-macosx_11_0_arm64.whl (530.4 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

File details

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

File metadata

  • Download URL: microtaint-0.5.0.tar.gz
  • Upload date:
  • Size: 205.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.8 {"installer":{"name":"uv","version":"0.11.8","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.5.0.tar.gz
Algorithm Hash digest
SHA256 68e97b281360534eec7eeb6a5acf5b6e0b5f784d0465e1388037f90d8c138810
MD5 324448939d673f703ed2e127a9263c9e
BLAKE2b-256 f34665c405e313785196c6dda152cb3f2acbf255d2e92bf87c8b13e4bfa18a70

See more details on using hashes here.

File details

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

File metadata

  • Download URL: microtaint-0.5.0-cp313-cp313-win_amd64.whl
  • Upload date:
  • Size: 449.9 kB
  • Tags: CPython 3.13, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.8 {"installer":{"name":"uv","version":"0.11.8","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.5.0-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 46d0dbc64fc1b1f04efaa60b3d826328cf2bfff0251231d1296b2408f85d489d
MD5 7361578e4d3f20903b80154cf2fef814
BLAKE2b-256 e4f265172a14ab8a5583ea83ee3026f403eb259f7d9c917a2b9b8f46f96e5687

See more details on using hashes here.

File details

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

File metadata

  • Download URL: microtaint-0.5.0-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
  • Upload date:
  • Size: 1.9 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.8 {"installer":{"name":"uv","version":"0.11.8","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.5.0-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 7383d0e9e810d7fa358a013ac704154c6bdd4c2d090abfd09fff236c3e287eb8
MD5 558bbeacf6beb898340079023c3400d2
BLAKE2b-256 ce9ea39ddeeaf49f131d50f15754f4507f7f4328372ca203b33782afbf474dd2

See more details on using hashes here.

File details

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

File metadata

  • Download URL: microtaint-0.5.0-cp313-cp313-macosx_11_0_arm64.whl
  • Upload date:
  • Size: 527.5 kB
  • Tags: CPython 3.13, macOS 11.0+ ARM64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.8 {"installer":{"name":"uv","version":"0.11.8","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.5.0-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 b7adc238a12fab4f73f9dbbb739ee940159e2f4b52b9768c8020337d9ab88854
MD5 2c910585df33b818fc48d8ecafb3ff59
BLAKE2b-256 ad29a49490c67683c0147ac971249a731b22d8f9dfcd4038da38d91f07c95247

See more details on using hashes here.

File details

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

File metadata

  • Download URL: microtaint-0.5.0-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 450.7 kB
  • Tags: CPython 3.12, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.8 {"installer":{"name":"uv","version":"0.11.8","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.5.0-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 c32cba2582c71ba60b0ca6baed00bbe7489024f0673eb3f7df549ee7c5972e84
MD5 074503bdcb21f35270552adb9e8e90ab
BLAKE2b-256 ea1fa2b7d814d53f16ed2d48728c49b2728151f9adb60297e3040fcb407fb090

See more details on using hashes here.

File details

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

File metadata

  • Download URL: microtaint-0.5.0-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
  • Upload date:
  • Size: 1.9 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.8 {"installer":{"name":"uv","version":"0.11.8","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.5.0-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 868fbef4bca05a0b08a7365b7ecb0594c7e3c706465ec767602b69751f4acb07
MD5 f6a11ea4a4d288e4b7ad29c03ee25e94
BLAKE2b-256 586e5170f51728cc0bc71457591d538a7c9c373126fee654e3dee842aa57ec8b

See more details on using hashes here.

File details

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

File metadata

  • Download URL: microtaint-0.5.0-cp312-cp312-macosx_11_0_arm64.whl
  • Upload date:
  • Size: 530.4 kB
  • Tags: CPython 3.12, macOS 11.0+ ARM64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.8 {"installer":{"name":"uv","version":"0.11.8","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.5.0-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 ca3745343ae956a8e6e05c7fed522397822a15a49d51c4f66e20b8c82c0279b8
MD5 0e5d4fcc2ad9f1825f3ad49f0a1f48e1
BLAKE2b-256 789ad9d6a393566ff8578f4380f27c65d9d90f15144e78c4066446e9806b7b36

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