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_REGandT_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 anADDorIMULmixes 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 to1(High Replica), and once with all tainted bits forced to0(Low Replica). TheXORof 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 to0actually 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 (likeADD), 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
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 Distributions
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.6.6.tar.gz.
File metadata
- Download URL: microtaint-0.6.6.tar.gz
- Upload date:
- Size: 147.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.11.11 {"installer":{"name":"uv","version":"0.11.11","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 |
b5eefd608c5a1a84954c58e8cdc006c2154451be4da8d2ad4588c39cf2fd6147
|
|
| MD5 |
749b1498a8b782082c7f4604224bf409
|
|
| BLAKE2b-256 |
ec2ced18d7bd67cd9f9e7092746988f813d2a3b21ed09e82694d56d69b70089d
|
File details
Details for the file microtaint-0.6.6-cp313-cp313-win_amd64.whl.
File metadata
- Download URL: microtaint-0.6.6-cp313-cp313-win_amd64.whl
- Upload date:
- Size: 768.3 kB
- Tags: CPython 3.13, Windows x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.11.11 {"installer":{"name":"uv","version":"0.11.11","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 |
8f26dfb2d698ea76dab911ce7efe622ea64159a4131f53412aeb21f336dbd5a8
|
|
| MD5 |
f4c1b0996211106bc5196683c1056756
|
|
| BLAKE2b-256 |
290ac386919dcd2d36e23e421edafc1f2456411248e40bfcf66ffd829c48a7aa
|
File details
Details for the file microtaint-0.6.6-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl.
File metadata
- Download URL: microtaint-0.6.6-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
- Upload date:
- Size: 948.1 kB
- 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.11 {"installer":{"name":"uv","version":"0.11.11","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 |
20a29d01404abf222424da7875d36915c8d3654f0c68d9bf12c93e6b456f8179
|
|
| MD5 |
420bc9c0a0b1aa1ffd6ca84ab72f377f
|
|
| BLAKE2b-256 |
88b67473608fb7934345805e46b4362b2d88986e0a5c5ec803c768a80f073609
|
File details
Details for the file microtaint-0.6.6-cp313-cp313-macosx_11_0_arm64.whl.
File metadata
- Download URL: microtaint-0.6.6-cp313-cp313-macosx_11_0_arm64.whl
- Upload date:
- Size: 796.4 kB
- Tags: CPython 3.13, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.11.11 {"installer":{"name":"uv","version":"0.11.11","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 |
3fb6da874cf076574068672282b7fda449dcb9975a34dbb0727d4795a7da1bb8
|
|
| MD5 |
c66c1257dbb917f19606b6eb1ed8116a
|
|
| BLAKE2b-256 |
a0a5ac167eb4cabd30e306c7eed122befb61d3bcf316a10d7e5cd1b793027bbe
|
File details
Details for the file microtaint-0.6.6-cp312-cp312-win_amd64.whl.
File metadata
- Download URL: microtaint-0.6.6-cp312-cp312-win_amd64.whl
- Upload date:
- Size: 768.7 kB
- Tags: CPython 3.12, Windows x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.11.11 {"installer":{"name":"uv","version":"0.11.11","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 |
9249d4549beb590c4f42488276bf91984f076e7eb42b7a42337a7a67421e1f46
|
|
| MD5 |
462bb4cd0dda90818fb065294ea025e5
|
|
| BLAKE2b-256 |
33d827684eeed2ac4747c60966c21179944f32b35b177d0b829cd7e69269ab1e
|
File details
Details for the file microtaint-0.6.6-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl.
File metadata
- Download URL: microtaint-0.6.6-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
- Upload date:
- Size: 951.4 kB
- 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.11 {"installer":{"name":"uv","version":"0.11.11","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 |
c3290cd14db41bbfbf98d21613c7a6884ec305cf859c0486f3c9a2c4d7ebdfd2
|
|
| MD5 |
0140b7837b6240d63ebf1f8b7ce642a7
|
|
| BLAKE2b-256 |
5084c7458f3ecce695050e8cbb041b63dddf7300f2f71b6986f87275985d9eb4
|
File details
Details for the file microtaint-0.6.6-cp312-cp312-macosx_11_0_arm64.whl.
File metadata
- Download URL: microtaint-0.6.6-cp312-cp312-macosx_11_0_arm64.whl
- Upload date:
- Size: 800.5 kB
- Tags: CPython 3.12, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.11.11 {"installer":{"name":"uv","version":"0.11.11","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 |
d093cfb6628483099fcae5d44351187931b16abf13f440aaa8b6efe98fe9393e
|
|
| MD5 |
b878f7fa586b8e3ec341adc86cd90c62
|
|
| BLAKE2b-256 |
f096fadf8d8fa8f3eaebb347071b05eb5bcfeefbe2a30ecf062106a20fd237b5
|