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 registerRAXat specific bits.T_RAX[...]: Denotes the Taint label (boolean/bitmask array) ofRAXat 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.XORdifferential: The formula often evaluates theSimulateCelltwice—once with the taint labels masked in (OR T_...), and once with them masked out (AND NOT(T_...)). TheXORof these two simulations is a strict mathematical proof of whether those specific tainted bits modified the final output target. If theXORis nonzero, the taint successfully propagated!
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file microtaint-0.2.0.tar.gz.
File metadata
- Download URL: microtaint-0.2.0.tar.gz
- Upload date:
- Size: 69.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.11.7 {"installer":{"name":"uv","version":"0.11.7","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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1bf9b888061e6eee22bc70bf50c72017442c70f23f9fe7ae88c6d259380b81b5
|
|
| MD5 |
4ec14610ee119a64f6ccd212d5521f64
|
|
| BLAKE2b-256 |
3f29d4bdac803e5819bc29e12074579e04e6678d9d1e553c7356c21535d9debb
|
File details
Details for the file microtaint-0.2.0-py3-none-any.whl.
File metadata
- Download URL: microtaint-0.2.0-py3-none-any.whl
- Upload date:
- Size: 29.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.11.7 {"installer":{"name":"uv","version":"0.11.7","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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
93ecad46f39d7cdbfb6e1cef2cb6939055bc586c5bcaf55a856a84bca299f13f
|
|
| MD5 |
e5f6d76d2744002ac1cce2d975860d90
|
|
| BLAKE2b-256 |
19bdf39f2ba303fa68a32df9a32d63c02068e7005a3bdd2c1bfcde58e20f5aa6
|