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.6.5.tar.gz (141.7 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.5-cp313-cp313-win_amd64.whl (750.2 kB view details)

Uploaded CPython 3.13Windows x86-64

microtaint-0.6.5-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl (930.2 kB view details)

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

microtaint-0.6.5-cp313-cp313-macosx_11_0_arm64.whl (779.6 kB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

microtaint-0.6.5-cp312-cp312-win_amd64.whl (750.7 kB view details)

Uploaded CPython 3.12Windows x86-64

microtaint-0.6.5-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl (933.6 kB view details)

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

microtaint-0.6.5-cp312-cp312-macosx_11_0_arm64.whl (783.9 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

File details

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

File metadata

  • Download URL: microtaint-0.6.5.tar.gz
  • Upload date:
  • Size: 141.7 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.6.5.tar.gz
Algorithm Hash digest
SHA256 706aad91b884191cf59a579672eb6186da2752f91ac50c2b240e0b76bf11d59b
MD5 04fa9a085c6aa32bb5b24d4fc60dea09
BLAKE2b-256 395dadf6a8fe4b5a01994577460d637d1a930721aff3a119db4c42f37d0832f6

See more details on using hashes here.

File details

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

File metadata

  • Download URL: microtaint-0.6.5-cp313-cp313-win_amd64.whl
  • Upload date:
  • Size: 750.2 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.6.5-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 d8298fdcb8679a360b2f917d3cecafd577536505d39f26647146462639b66af7
MD5 de22c9a142af40e99aa8159fd4954d85
BLAKE2b-256 f4342ea960bebd31f45b52a1ba2a8d2c049e47fdac7f08210d4934beb2da0150

See more details on using hashes here.

File details

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

File metadata

  • Download URL: microtaint-0.6.5-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
  • Upload date:
  • Size: 930.2 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.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.6.5-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 dc32a296e05ab64c96a81c5a5fe08bababf81d0661088ba1377c8e5ec0e3e6f1
MD5 0a7ece8772dee2067220e3dac0a0a39a
BLAKE2b-256 72eb19bc6ff5df03c71338717ef3f40d75efd95cdbd63814807fc18d6658178e

See more details on using hashes here.

File details

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

File metadata

  • Download URL: microtaint-0.6.5-cp313-cp313-macosx_11_0_arm64.whl
  • Upload date:
  • Size: 779.6 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.6.5-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 726402fabebb25a2e53d81a90927f5f400055b1c95f0c53a167b1b6646a775d3
MD5 87198e52ab7b7548e5a1474b9a7fabd9
BLAKE2b-256 b15a04007ed7dd3fcf12a4a49a53a126b9509dc9591aafafc8976e02b9312508

See more details on using hashes here.

File details

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

File metadata

  • Download URL: microtaint-0.6.5-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 750.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.6.5-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 c8479fe3c688075840b8d3bd50fe949fa70424c0cae10d0fdc945dc6046aca6d
MD5 657447f8af0e5832e0382a5126adcb53
BLAKE2b-256 ccbee38e5d91131d186eb2326fc14deb58c24de987cdd55757d108bb2b145763

See more details on using hashes here.

File details

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

File metadata

  • Download URL: microtaint-0.6.5-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
  • Upload date:
  • Size: 933.6 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.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.6.5-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 f7e06ce63fef45bc029c110c0cd878156f9306de76e37f28c8c86a6a016f3d71
MD5 6f74981d625f3639af477771b8d47873
BLAKE2b-256 f179bda185f2304083c4ef949354318a1be972a67587f7ed9f16bc30121e21e9

See more details on using hashes here.

File details

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

File metadata

  • Download URL: microtaint-0.6.5-cp312-cp312-macosx_11_0_arm64.whl
  • Upload date:
  • Size: 783.9 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.6.5-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 011684d21301c522c7dad07ef899a21af932f4a3d797a63a92e09ebfdc9acad6
MD5 e122f177390b7d59bf7fd845b3809742
BLAKE2b-256 51616b8571d746a7cd51f7f9a0aa19afb46c2942bd2252e1cb5d9332ced01c02

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