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.3.1.tar.gz (93.1 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.3.1-cp313-cp313-win_amd64.whl (239.7 kB view details)

Uploaded CPython 3.13Windows x86-64

microtaint-0.3.1-cp313-cp313-win32.whl (211.2 kB view details)

Uploaded CPython 3.13Windows x86

microtaint-0.3.1-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (863.4 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ x86-64

microtaint-0.3.1-cp313-cp313-macosx_11_0_arm64.whl (293.2 kB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

microtaint-0.3.1-cp312-cp312-win_amd64.whl (240.4 kB view details)

Uploaded CPython 3.12Windows x86-64

microtaint-0.3.1-cp312-cp312-win32.whl (211.9 kB view details)

Uploaded CPython 3.12Windows x86

microtaint-0.3.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (870.7 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64

microtaint-0.3.1-cp312-cp312-macosx_11_0_arm64.whl (294.6 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

File details

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

File metadata

  • Download URL: microtaint-0.3.1.tar.gz
  • Upload date:
  • Size: 93.1 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

Hashes for microtaint-0.3.1.tar.gz
Algorithm Hash digest
SHA256 537263a53996194ab6cfc272ab517456f83a4da68e809e53e42cfe6291428fb0
MD5 2e73342f35b0664a6f6fce04be4d0509
BLAKE2b-256 fa8728ac67b456853cb29e55b29e6a6f9abceb791daf13890002d1188fe4dbbf

See more details on using hashes here.

File details

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

File metadata

  • Download URL: microtaint-0.3.1-cp313-cp313-win_amd64.whl
  • Upload date:
  • Size: 239.7 kB
  • Tags: CPython 3.13, Windows x86-64
  • 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

Hashes for microtaint-0.3.1-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 79312f443053f9540cf2ffa33fa7d6d1059d98e3580b252cfb7edf95ae9fd7ee
MD5 6852e2bfb010808130b9f848c327241f
BLAKE2b-256 7acdd650cece3d08f8559b17aa70ff22e539530878a2efea11aa17bf1c065f87

See more details on using hashes here.

File details

Details for the file microtaint-0.3.1-cp313-cp313-win32.whl.

File metadata

  • Download URL: microtaint-0.3.1-cp313-cp313-win32.whl
  • Upload date:
  • Size: 211.2 kB
  • Tags: CPython 3.13, Windows x86
  • 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

Hashes for microtaint-0.3.1-cp313-cp313-win32.whl
Algorithm Hash digest
SHA256 846033990e1f52c40f79d8588df5b56e5f621707f8ac9aa190c72b39e7b5405c
MD5 25914c26a9940223efcc8b61031e5096
BLAKE2b-256 c568a9cb18c36585bf65b73b0fd8ec3a9dd5a639bb1de67ae6b03c757b80d5c2

See more details on using hashes here.

File details

Details for the file microtaint-0.3.1-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

  • Download URL: microtaint-0.3.1-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
  • Upload date:
  • Size: 863.4 kB
  • Tags: CPython 3.13, manylinux: glibc 2.17+ x86-64
  • 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

Hashes for microtaint-0.3.1-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 4ee8e723b9bc7602b7146625cedc9946b03638205e4a5ff0c58cae280d055609
MD5 cebacb8a6b2bced307e1149fcdb0eab2
BLAKE2b-256 338d3ec4aadfcac7908448e9973880bf20301ce24b8897f0fa67b9d9d1ae9612

See more details on using hashes here.

File details

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

File metadata

  • Download URL: microtaint-0.3.1-cp313-cp313-macosx_11_0_arm64.whl
  • Upload date:
  • Size: 293.2 kB
  • Tags: CPython 3.13, macOS 11.0+ ARM64
  • 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

Hashes for microtaint-0.3.1-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 a8a26f473e6b23eacd714df26cd8ae0a2829bc4cb6487b12188ec6af4992593e
MD5 49de64bd0ffc2ca80b0f635bb426dbaa
BLAKE2b-256 04f9a9fc1f972c58f501e3a0fe21a42d9aa46a5e213f3d2df5bbbc1ae9c11d7c

See more details on using hashes here.

File details

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

File metadata

  • Download URL: microtaint-0.3.1-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 240.4 kB
  • Tags: CPython 3.12, Windows x86-64
  • 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

Hashes for microtaint-0.3.1-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 4cf54e9f46ffa628eb2258cb07d00641679427007d3a11889071a15b7fd6084c
MD5 35a10a9c41da2ffabad14a2d572ef183
BLAKE2b-256 e88700860d15c5992b97809baebb7ab2f4a3e7b5513f21a842c6de6de6e817b7

See more details on using hashes here.

File details

Details for the file microtaint-0.3.1-cp312-cp312-win32.whl.

File metadata

  • Download URL: microtaint-0.3.1-cp312-cp312-win32.whl
  • Upload date:
  • Size: 211.9 kB
  • Tags: CPython 3.12, Windows x86
  • 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

Hashes for microtaint-0.3.1-cp312-cp312-win32.whl
Algorithm Hash digest
SHA256 9e181a97d418ff7fefe6a808f1653612660062bf6e82c1631893a285d16d64b1
MD5 95e62de678153f62b0d1909ab7802739
BLAKE2b-256 0fe47382a56ea7d4db0bde7d83684441801cc6201a5e2afdde0d1c38bf886144

See more details on using hashes here.

File details

Details for the file microtaint-0.3.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

  • Download URL: microtaint-0.3.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
  • Upload date:
  • Size: 870.7 kB
  • Tags: CPython 3.12, manylinux: glibc 2.17+ x86-64
  • 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

Hashes for microtaint-0.3.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 cc9a749553ac0218627f89af468389f2705f21b67506f8893c0c218c9ee31427
MD5 2ea3d7acdfcb605d2eea214d7ffad9e8
BLAKE2b-256 9a2ddbe63845eb3712edc8fdaa631b22a733a838e36fb9aee4d14a84c02990be

See more details on using hashes here.

File details

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

File metadata

  • Download URL: microtaint-0.3.1-cp312-cp312-macosx_11_0_arm64.whl
  • Upload date:
  • Size: 294.6 kB
  • Tags: CPython 3.12, macOS 11.0+ ARM64
  • 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

Hashes for microtaint-0.3.1-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 3cecc1b5ce0543a6bf92479da3b49459f4974061d62fb3f68889e09a07f342db
MD5 d235a64ee55c8b0ad47c1937bb2b77f3
BLAKE2b-256 cdbf9d82971c299bfdf203918ffe6294c2dbafafd75923d3740af89cffeb325a

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