[ Close ]
Enter something in the search box to see results



Issues:[ 1 ][ 2 ][ 3 ][ 4 ][ 5 ][ 6 ][ 7 ][ 8 ][ 9 ][ 10 ][ 11 ][ 12 ][ 13 ][ 14 ][ 15 ][ 16 ][ 17 ][ 18 ][ 19 ][ 20 ][ 21 ][ 22 ][ 23 ][ 24 ][ 25 ][ 26 ][ 27 ][ 28 ][ 29 ][ 30 ][ 31 ][ 32 ][ 33 ][ 34 ][ 35 ][ 36 ][ 37 ][ 38 ][ 39 ][ 40 ][ 41 ][ 42 ][ 43 ][ 44 ][ 45 ][ 46 ][ 47 ][ 48 ][ 49 ][ 50 ][ 51 ][ 52 ][ 53 ][ 54 ][ 55 ][ 56 ][ 57 ][ 58 ][ 59 ][ 60 ][ 61 ][ 62 ][ 63 ][ 64 ][ 65 ][ 66 ][ 67 ][ 68 ][ 69 ][ 70 ][ 71 ][ 72 ][ 73 ]
Current issue : #73 | Release date : 2026-11-17 | Editor : Phrack Staff
IntroductionPhrack Staff
Phrack Prophile on Halvar FlakePhrack Staff
LinenoisePhrack Staff
Escaping from a Docker container through vDSOandersonc0d3
Owning the Truth: Undecidability, unsound kernels, and the forging of proofendrazine, veorq
Cryptographic Ideas for TCC BypassesJonathan Bar Or
Word Machines for Weird Machinesnoperator
Beyond the Facade :: Exposing Smart GiantsLiquidWorm
The Art of Staying HiddenMatheuZSecurity
Reflections on Trusting AI: A Virus Inside an LLMmarver
QNX Userland Shellcode ComponentsClaes M Sjoberg
UAF Exploitation in the Sheaves Eraw1sdom
From PhrackCTF to Two WinFsp 0-daysLucas Tay
fortify-headers: standalone portable header-based implementation of FORTIFY_SOURCE=3jvoisin, sin
Poor Little ChunksAx
The Silent Fleet: AUVs -- Autonomous Underwater VehiclesAmitay Dan
MOLE - A Binary Ninja Plugin for Static Taint AnalysisDamian Pfammatter
Backdoor attacks against Machine Learning IRLG. Cherubin
A Journey Into Kernel Exploit Development in the LLM EraJuefei Pu, Yifan Wu, Kareem Shehada, Zhiyun Qian
Abusing the Windows Smart Card Minidriver ArchitectureMarc Barrantes
Painting Out of the Box: Escaping the Chromium Renderer Sandbox via SkiaQuang Luong
Semantic Abuse of the Linux IIO SubsystemSalah Triki
Disassembly, Flux, and Runtime Hijinksfoosc
Mystique - An x86 Metamorphic CompilerwK
Security is failure: Every Patch Is a GuessTedsig42
The Moon vs The Shield: A Study of Heap Feng Shui Using Lua3nso
HISTORY: Phrack World HistoryPhrack Staff
HISTORY: The 2000 SSH1 exploit that broke the Internetlcamtuf, scut, dvorak, scrippie, portal, gera, skyper
HISTORY: The 2003 Linux Kernel BackdoorAnonymous
HISTORY: BlueBoxing - Myths and Feelingsgamma, skyper
HISTORY: The Proxy That Made No SenseMikko Hypponen

Title : MOLE - A Binary Ninja Plugin for Static Taint Analysis

Author : Damian Pfammatter
|=-----------------------------------------------------------------------=|
|=-----=[ MOLE - A Binary Ninja Plugin for Static Taint Analysis ]=------=|
|=-----------------------------------------------------------------------=|
|=--------=[ Or How I Started Dreaming About Inter-Procedural ]=---------=|
|=--------------=[ Variable Slicing and Pointer Analysis ]=--------------=|
|=-----------------------------------------------------------------------=|
|=------------------------=[ Damian Pfammatter ]=------------------------=|
|=-----------------------------------------------------------------------=|

                                   █████
                                ██▓▒▓▓▓████
                              █▓░░▒▓▓▓▓▓▓▓████
                           █▓▒░▒▓▓▓▓▓▓▓▓▓▓▓█████
                          █▒░░▒▓▓▓▓▓▓▓▓▓▓▓▓▓██████
                         ▓░░░▒▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓██████
                        ▓▒░░▒▓▓▓▓▓▒▒▒▒▒▓▓▓▓▓▓▓██████
                       █▒░░▓▓▒░░░▓███████▓▒▒▓▓▓▓█████
                      █▒░▒▒░▒▓████████████████▓▓▓████
                     █▓░░▒▓██████████████████████▓████
                    █▓░░▓██████████████████████████████
                   █▓░▒█████▓░░█████████████▒░▓█████████
                  █▓░▓███████████████████████████████████
                  █░▓████████▓▓▒░░░░░░░░░░░░▒▓▓███████████
                 █▒▓██████▓▒▒░░░░░░░░░░░░░░░░░░▒▒▓████████
                 ▓▒█████████▓▒▒▒▒░░░░░░░░░░▒▒▒▒▓██████████
                █▓▒█████████████▓▓▒░░░░░░▒▓▓███████████████
                 █▒▓██████████████▓▒░░░░▒▓████████████████
                  █▓▒██████████████▓▒░░▒▓████████████████
                    █▓▒█████████████▓░░▓████████████████
                    █▓█▓▒████████████▓▓████████████████
                   ██░▓▓█▓▒█████████████████████████████
                  █▓░░░▓▓█████████▒▒▒▓▒▒░▓████████████████
                    ██▒▒▓▓▓█████▓░░░░█▒░░░▒█████████████
                      ███▓█████▓░░░▒▓██▒░░░▒█████████
                        ███████░░░▒█████▓░░░▓██████
                            ███▓▒█████████▓▒████
                               █████████████
                                    ███

--[ Table of Contents

- 1. Introduction
- 2. Background
  - 2.1. Binary Ninja
  - 2.2. Intermediate Languages
  - 2.3. Static Single Assignment Form
  - 2.4. Program and Backward Slices
- 3. Backward Slicing as an Engine for Static Taint Analysis
  - 3.1. Running Example
  - 3.2. Intra-Procedural Variable Slicing
    - 3.2.1. Use-Def Chains
    - 3.2.2. Instruction Graph
  - 3.3. Inter-Procedural Variable Slicing
    - 3.3.1. Execution Stack
  - 3.4. Pointer Analysis
    - 3.4.1. Memory Versions
    - 3.4.2. Slicing Pseudo-Algorithm
    - 3.4.3. Variable Merging
  - 3.5. Finding Paths
- 4. Path Triage
  - 4.1. Path Grouping
  - 4.2. Path Prioritisation Using LLMs
- 5. Scalability and Automation
  - 5.1. Fixing Function Type Signatures
  - 5.2. Headless Mode
  - 5.3. AI-Assisted Analysis Workflows
- 6. Evaluation
  - 6.1. Vulnerability Discoveries
  - 6.2. Discussion
- 7. Conclusion
- 8. References

--[ 1. Introduction

In many vulnerability research scenarios, source code is unavailable,
requiring analysis to be performed directly on binaries. As in source-code
available settings, dynamic techniques such as fuzzing typically remain
among the most effective approaches for discovering vulnerabilities in
binaries. However, these techniques often involve substantial setup effort.
This challenge is further amplified in constrained environments such as
embedded systems, where firmware is tightly coupled to hardware, lacks
standard input interfaces, and often requires emulation for execution and
monitoring. In such contexts, static binary analysis provides an efficient
initial approach, enabling rapid target assessment, identification of
potential attack surfaces, and prioritisation of candidates for deeper
dynamic analysis.

Motivated by such scenarios, we were drawn to the Trail of Bits blog post
"Vulnerability Modeling with Binary Ninja" [1], which illustrates how
Binary Ninja [2] can be used to statically identify vulnerabilities in
binary executables. The concept of automatically tracking how values
propagate through a program and detecting conditions that may lead to
exploitable behaviour was particularly compelling.

Inspired by this idea, we began experimenting with these techniques on
increasingly complex binaries. While early results were promising, we soon
discovered that the constraint-based reasoning central to this approach
does not scale as easily as it first appears. Building accurate models of
real binaries and generating constraints that remain tractable for
Satisfiability Modulo Theories (SMT) solvers becomes increasingly
challenging as code complexity grows. Nevertheless, one concept
consistently proved valuable: tracing how data propagates through a
program. This observation motivated us to build a framework capable of
handling all instruction types supported by Binary Ninja.

As our exploration progressed, we encountered another fundamental
challenge. Although tracking data flow within a single function is
relatively straightforward, vulnerabilities are rarely confined to a single
function. Instead, they often emerge from chains of function calls that
propagate data across multiple components of a program. Accurately
following data across these function boundaries is significantly more
difficult, requiring the analysis to account for calling conventions,
parameter passing, return values, and indirect interactions. These factors
introduce additional complexity and make inter-procedural analysis
substantially more challenging than reasoning within a single function.

In this article, we describe our approach to address these challenges. We
explain why Binary Ninja provides a strong foundation for binary analysis,
highlighting features such as its multiple intermediate representations,
Static Single Assignment (SSA) forms, and rich API. Further, we introduce
Mole [4], our free and open-source Binary Ninja plugin, which serves as the
practical implementation of the ideas discussed throughout this work.

With respect to our primary focus - vulnerability discovery - we discuss
how identified execution paths can be efficiently investigated and
prioritised, including the potential use of large language models (LLMs) to
assist with this. We also describe how Mole can be executed in headless
mode to analyse large collections of binaries and how it can be integrated
into AI-assisted analysis workflows.

Finally, we present our experiences applying Mole to real-world targets.
This iterative process helped improve the tool's capabilities, validated
its effectiveness in practice, and ultimately contributed to the discovery
of several vulnerabilities that were responsibly disclosed to affected
vendors.

--[ 2. Background

Before diving into the core concepts, this section introduces some
background necessary to understand the remainder of this article, including
Binary Ninja and its intermediate languages, as well as the notion of
program slicing.

--[ 2.1. Binary Ninja

Binary Ninja (BN) [2] is a commercial reverse engineering platform for
analysing native binaries. It supports standard executable formats such as
ELF, PE, and Mach-O, as well as raw binary blobs, and provides, among other
features, functionality for disassembly and lifting machine code into
multiple intermediate representations. A comprehensive API enables
automation and custom analysis via plugins and scripts.

--[ 2.2. Intermediate Languages

Binary Ninja Intermediate Languages (BNILs) [3] are a family of
intermediate representations that model a program at different abstraction
levels. During analysis, machine instructions are successively lifted into
increasingly abstract forms. For the purposes of this work, the BNIL
hierarchy can be viewed as:

`Machine Code → LLIL → MLIL → HLIL`

Low Level IL (LLIL) closely models machine instruction semantics and
preserves low-level details such as register operations and memory
accesses. While useful for analyses requiring precise execution semantics,
its verbosity increases analysis complexity.

High Level IL (HLIL) reconstructs source-code-like constructs such as
loops, conditionals, and structured expressions. Its higher level of
abstraction improves readability but may hide details relevant for precise
data-flow analysis.

Medium Level IL (MLIL) operates at a mid-level abstraction, reducing
architecture-specific details by transforming registers and memory accesses
into typed variables. This balance between abstraction and precision makes
MLIL particularly well suited for data-flow analysis, motivating its use as
the primary intermediate representation throughout this work.

--[ 2.3. Static Single Assignment Form

Each Binary Ninja IL can be represented in Static Single Assignment (SSA)
form. SSA is an intermediate representation in which each variable version
is assigned exactly once. Whenever a variable is modified, a new version
(indicated by a `#`) is created.

For example:
x = 1
x = x + 2

becomes:
x#0 = 1       ◀─┐ Definition of variable x version 0
x#1 = x#0 + 2 ──┘ Use of variable x version 0

The assignment to `x#0` defines the value used by `x#1`, forming a
use-definition (use-def) relationship. By making such dependencies
explicit, SSA enables efficient data-flow analyses and simplifies reasoning
about how values propagate through a program.

--[ 2.4. Program and Backward Slices

A program slice is the subset of program statements relevant to a slicing
criterion (a program point and one or more variables), i.e., statements
that may influence the values of those variables at that point.

A backward slice is the subset of program statements that may influence a
slicing criterion, obtained by traversing dependencies in reverse direction
from the criterion. In this work, backward slices are computed on MLIL in
SSA form by recursively following use-definition chains, starting from the
target variable at the given program point.

--[ 3. Backward Slicing as an Engine for Static Taint Analysis

Mole's core functionality is a static taint-tracking engine that performs
backward slicing over MLIL SSA variables. To explain its operation, we
introduce a running example (Section 3.1) that is used to illustrate key
concepts, including intra-procedural (Section 3.2) and inter-procedural
(Section 3.3) slicing, as well as taint propagation through pointers
(Section 3.4). The example is intentionally kept simple; however, it serves
to highlight the core analysis challenges, demonstrate the strengths of the
current approach, and reveal its limitations.

--[ 3.1. Running Example

To illustrate Mole's static taint analysis workflow, we use the example
shown in Figure 1. In this example, `getenv` serves as the source function,
representing untrusted external input, while `system` serves as the sink
function, representing a security-sensitive operation. The goal of the
analysis is to determine whether data originating from the source can
propagate through the program and ultimately influence the sink.

C Source Code               Binary Ninja MLIL SSA (Simplified)
─────────────               ──────────────────────────────────

                                    ┌────────────────────────────┐
                                    │0 cmd#0=arg1                │
                                    │1 if(cmd#0==0) then 2 else 4│
                                    └────── ↙ ────────── ↘ ──────┘
char* validate(char* cmd){    ┌──────────┐ true       false ┌──────────┐
 if(cmd==NULL) cmd="";        │2 cmd#1=""│                  │4 goto 5  │
 return cmd;                  │3 goto 5  │                  │          │
}                             └──────────┘                  └──────────┘
                                       ┌─── ↘ ────────── ↙ ───┐
                                       │5 cmd#2=ϕ(cmd#0,cmd#1)│
                                       │6 return cmd#2        │
                                       └──────────────────────┘
                                ┌─────────────────────────────────────┐
int execute(char* cmd){         │ 7 cmd#0=arg1                        │
 cmd=validate(cmd);             │ 8 cmd#1,mem#1=validate(cmd#0) @mem#0│
 return system(cmd);            │ 9 cmd#2=cmd#1                       │
}                               │10 return system(cmd#2)              │
                                └─────────────────────────────────────┘

                            ┌─────────────────────────────────────────────┐
int main(){                 │11 env#0,mem#1=getenv("CMD") @mem#0          │
  char cmd[64];             │12 cmd#0=&cmd                                │
  char* env=getenv("CMD");  │13 mem#2=snprintf(cmd#0,64,"%s",env#0) @mem#1│
  snprintf(cmd,64,"%s",env);│14 cmd#1=&cmd                                │
  return execute(cmd);      │15 res#0,mem#3=execute(cmd#1) @mem#2         │
}                           │16 return res#0                              │
                            └─────────────────────────────────────────────┘

[Figure 1: Running Example]

The left side of Figure 1 shows the original C source code, which consists
of three functions. The `main` function reads the `CMD` environment
variable into a 64-byte stack buffer and passes a pointer to this buffer to
`execute`. The `execute` function forwards the pointer to `validate` and
subsequently to `system`. The `validate` function ensures that the pointer
is not `NULL` by replacing a `NULL` value with an empty string.

The right side of Figure 1 shows the corresponding representation in Binary
Ninja's MLIL SSA form, slightly simplified for clarity. Each box represents
a basic block, i.e., a straight-line sequence of instructions executed
sequentially without any control-flow transfer. Directed edges between
basic blocks denote possible control-flow transitions within the program.
Each instruction is prefixed with an index to facilitate reference. The
semantics of individual MLIL instructions are discussed in the following
sections, where we describe Mole's backward-slicing algorithm in detail.

--[ 3.2. Intra-Procedural Variable Slicing

We first describe how backward slicing is performed within a single function
(i.e., intra-procedurally). This process relies on following variable
use-def chains (Section 3.2.1) to trace data dependencies between
instructions. As these dependencies are discovered, they are incrementally
incorporated into an instruction-level dependency graph (Section 3.2.2),
which ultimately enables the identification of paths from sources to sinks.
Section 3.3 later on extends this methodology to the inter-procedural
setting, where additional challenges arise from the need to track data flow
across function boundaries.

---[ 3.2.1. Use-Def Chains

Mole starts backward slicing at the call site of the sink function, i.e.,
the instruction `return system(cmd#2)` in function `execute` (Figure 2).

┌─C Source Code───────────────────────────┐
│ int execute(char* cmd){                 │
│  cmd=validate(cmd);                     │
│  return system(cmd);                    │
│ }                                       │
└─────────────────────────────────────────┘

┌─Binary Ninja MLIL SSA (Simplified)──────┐
│    7 cmd#0=arg1                         │
│    8 cmd#1,mem#1=validate(cmd#0) @mem#0 │
│    9 cmd#2=cmd#1          ◀─┐ Def       │
│-> 10 return system(cmd#2) ──┘ Use       │◀─ Sink function
└─────────────────────────────────────────┘

[Figure 2: Function `execute` of the Running Example]

Mole iterates over all sink arguments of interest (configurable within the
tool) and computes a separate slice for each. In the running example, the
sink function exposes a single relevant argument, `cmd#2`. To extend the
slice, we exploit the SSA form, which enforces single assignment for each
variable instance. This property enables direct traversal of the use-def
chain from `cmd#2` to its unique definition, `cmd#2=cmd#1`. We record this
dependency in the instruction graph (a data structure described in the next
section) and continue the backward traversal with `cmd#1` as the new focus
of analysis.

---[ 3.2.2. Instruction Graph

As mentioned above, the instruction graph is constructed incrementally
during backward slicing, where nodes represent MLIL SSA instructions and
directed edges capture the flow of taint between instructions. To construct
the instruction graph, Mole implements dedicated handlers for each MLIL SSA
instruction type (slightly more than 100 in total). Each handler specifies
how backward slicing proceeds when a corresponding instruction is
encountered. For instance, the handler for `cmd#2=cmd#1 [MLIL_SET_VAR]`
propagates the analysis from the destination operand `cmd#2` to its source
operand `cmd#1`. The resulting operand `cmd#1` is then treated as the next
use site, for which the corresponding definition site is resolved via SSA.
In our case, SSA resolution yields `cmd#1,mem#1=validate(cmd#0) @mem#0`,
indicating that `cmd#1` represents the return value of a call to the
function `validate`.

For reference, Figure 3 illustrates the complete instruction graph of our
running example. In the following discussion, we walk through how this
graph is constructed step by step. Since the current slicing target is a
call instruction, we now extend the discussion to inter-procedural slicing.

┌─execute──────────────────────────────────────────────┐
│                 return system(cmd#2)                 │
│                           ↓                          │
│                      cmd#2=cmd#1                     │
│                           ↓                          │
│           cmd#1,mem#1=validate(cmd#0) @mem#0         │
│────────── ↙ ─────────┐                        ↘      │
│     return cmd#2     │                    cmd#0=arg1 │
│          ↓           |──────────────────────── ↓ ───────────────────────┐
│ cmd#2=ϕ(cmd#0,cmd#1) |         res#0,mem#3=execute(cmd#1) @mem#2        │
│      ↙        ↘      |                         ↓                        │
│ cmd#0=arg1   cmd#1   |                    cmd#1=&cmd                    │
└─validate─────────────┘                         ↓                        │
                       │    mem#2=snprintf(cmd#0,64,"%s",env#0) @mem#1    │
                       │      ↙                        ↘                  │
                       │ cmd#0=&cmd       env#0,mem#1=getenv("CMD") @mem#0│
                       └─main─────────────────────────────────────────────┘

[Figure 3: Complete Instruction Graph of the Running Example]

--[ 3.3. Inter-Procedural Variable Slicing

The previous section described how MLIL SSA variables can be sliced within
the scope of a single function. In practical applications, such as
identifying vulnerability paths where untrusted input propagates to
sensitive operations, function-local slicing is (almost always)
insufficient. To address this limitation, slicing must be extended to an
inter-procedural setting, which introduces additional complexity. To
support this capability, Mole introduces a new data structure, which is
presented next.

---[ 3.3.1. Execution Stack

To preserve analysis context across function boundaries, Mole maintains an
inter-procedural execution stack. This data structure consists of a stack
of call frames, where each frame encapsulates a local instruction stack
representing intra-procedural traversal state. In the running example, the
current execution stack (growing downwards), as discussed so far, is shown
in Figure 4:

┌─Call Stack─────────────────────────────────────────────┐
││ ┌─[execute] Instruction Stack────────────────────────┐│◀─ Call Stack Top
││ │- return system(cmd#2)               [MLIL_TAILCALL]││
││ │- cmd#2=cmd#1                        [MLIL_SET_VAR] ││
││ │- cmd#1,mem#1=validate(cmd#0) @mem#0 [MLIL_CALL]    ││◀─ Local Inst.
│▼ └────────────────────────────────────────────────────┘│   Stack Top
└────────────────────────────────────────────────────────┘

[Figure 4: Execution Stack of the Running Example]

As mentioned before, our backward slice reached the return value of a
function invocation. At this point, Mole descends into the callee and
continues the analysis from all the callee's possible exit points. This
step may introduce imprecision, as Binary Ninja may not statically recover
all return sites, and not all identified exits necessarily correspond to
feasible dynamic control-flow paths.

In the running example, the function `validate` (Figure 6) contains a
single return instruction, `return cmd#2`, which is therefore selected as
the next propagation point. The resulting inter-procedural execution stack
is shown in Figure 5.

┌─Call Stack─────────────────────────────────────────────┐
││ ┌─[execute] Instruction Stack────────────────────────┐│
││ │- return system(cmd#2)               [MLIL_TAILCALL]││
││ │- cmd#2=cmd#1                        [MLIL_SET_VAR] ││
││ │- cmd#1,mem#1=validate(cmd#0) @mem#0 [MLIL_CALL]    ││
││ └────────────────────────────────────────────────────┘│
││ ┌─[validate] Instruction Stack───────────────────────┐│◀─ Call Stack Top
││ │- return cmd#2                       [MLIL_RET]     ││◀─ Local Inst.
│▼ └────────────────────────────────────────────────────┘│   Stack Top
└────────────────────────────────────────────────────────┘
[Figure 5: Execution Stack of the Running Example]

┌─C Source Code──────────────────────────────┐
│ char* validate(char* cmd){                 │
│  if(cmd==NULL) cmd="";                     │
│  return cmd;                               │
│ }                                          │
└────────────────────────────────────────────┘

    ┌─Binary Ninja MLIL SSA (Simplified)──┐
    │   0 cmd#0=arg1                      │
    │   1 if(cmd#0==0) then 2 else 4      │
    └────────── ↙ ─────────── ↘ ──────────┘
┌──────────────┐ true    false ┌──────────────┐
│   2 cmd#1="" │               │   4 goto 5   │
│   3 goto 5   │               │              │
└──────────────┘               └──────────────┘
          ┌──── ↘ ─────────── ↙ ─────┐
          │   5 cmd#2=ϕ(cmd#0,cmd#1) │
          │-> 6 return cmd#2         │◀─ Return
          └──────────────────────────┘

[Figure 6: Function `validate` of the Running Example]

Continuing the backward slice from the use site `cmd#2` to its definition
leads to another interesting instruction: `cmd#2=ϕ(cmd#0,cmd#1)`. The PHI
instruction indicates that the value of `cmd#2` may originate from either
`cmd#0` or `cmd#1`, depending on the control-flow path taken. In the
running example, this PHI node is introduced by the if statement, where
execution may proceed through either the true or the false branch before
the control-flow paths merge again.

From a slicing perspective, a PHI instruction introduces multiple
successors and therefore causes the instruction graph to branch. PHI nodes
are one of the primary sources of path divergence in the instruction graph,
as Mole must explore each operand as a possible origin of the value being
traced.

Following operand `cmd#1` quickly reaches a dead end for the slicer, as it
resolves to the constant assignment `cmd#1=""`. Since this value is not
derived from any further program state, the corresponding path terminates.
Following operand `cmd#0`, however, yields a more interesting result: the
instruction `cmd#0=arg1`, which corresponds to the first argument of the
function `validate`. Mole records this information so that, once the
analysis leaves `validate` and pops its call frame from the execution
stack, it knows that the first argument of the callee was reached and
should be followed along in the caller.

Returning to `execute`, the analysis therefore follows `cmd#0` and reaches
`cmd#0=arg1`, i.e., the first argument of `execute` (recall that function
`execute` includes our sink).

The next step is to continue the analysis into the caller(s) of `execute`.
Unlike the earlier transition from caller to callee (and back), there is no
unique call site to return to because the analysis originated at the sink.
Consequently, Mole must consider all call sites of `execute` identified by
Binary Ninja and propagate the slice into each corresponding caller.

This transition can introduce additional imprecision. As an inherent
limitation of static analysis, Binary Ninja's call graph may contain edges
that are not dynamically feasible, causing the analysis to explore
execution paths that cannot occur at runtime. Consequently, the resulting
instruction graph may include infeasible paths that do not correspond to
any concrete program execution. Conversely, the call graph may also omit
valid edges, causing corresponding execution paths to be missed by the
analysis.

In the running example, only a single call site for `execute` exists:
`res#0,mem#3=execute(cmd#1) @mem#2` in `main` (Figure 7). Because the slice
currently targets the first argument of `execute`, the analysis continues
through `cmd#1`, eventually reaching the assignment `cmd#1=&cmd`. At this
point, the slice encounters a pointer, requiring Mole to explicitly model
memory indirection in order to continue tracing the data flow.

--[ 3.4. Pointer Analysis

So far, the slicing algorithm has operated exclusively on variable use-def
chains. For example, it follows the variable `cmd#1` in instruction 15 to
its defining instruction, `cmd#1=&cmd` (instruction 14), and then attempts
to continue by following the source operand `&cmd` (Figure 7). However,
`&cmd` is an instruction of type `MLIL_ADDRESS_OF`, meaning that it
represents the address of the variable `cmd` rather than its value. At this
point, the analysis can no longer proceed by relying on variable
definitions alone. Instead, it must explicitly account for memory
indirection in order to determine how data flows through the memory
location denoted by the address.

┌─C Source Code───────────────────────────────────┐
│ int main(){                                     │
│   char cmd[64];                                 │
│   char* env=getenv("CMD");                      │
│   snprintf(cmd,64,"%s",env);                    │
│   return execute(cmd);                          │
│ }                                               │
└─────────────────────────────────────────────────┘

┌─Binary Ninja MLIL SSA (Simplified)──────────────┐
│   11 env#0,mem#1=getenv("CMD") @mem#0           │◀─ Defines mem#1
│   12 cmd#0=&cmd                                 │
│   13 mem#2=snprintf(cmd#0,64,"%s",env#0) @mem#1 │◀─ Defines mem#2
│-> 14 cmd#1=&cmd                                 │◀─ Current mem#2
│   15 res#0,mem#3=execute(cmd#1) @mem#2          │
│   16 return res#0                               │
└─────────────────────────────────────────────────┘

[Figure 7: Function `main` of the Running Example]

---[ 3.4.1. Memory Versions

The expression `&cmd` identifies the memory object of interest, namely the
stack variable `cmd` (64-byte buffer). To continue the backward slice, the
analysis must determine where the contents of this memory object were last
defined. In other words, it must find the memory write that most recently
affected `cmd` before the current program point.

At first glance, this might appear as simple as scanning backwards through
the instruction stream. However, such an approach is generally unsound
because instructions are not necessarily executed in their linear order.
Branches, loops, and other control-flow constructs invalidate the
assumption of a linear instruction order. Consequently, the notion of
"last" must be defined in terms of program semantics rather than
instruction order.

To address this problem, we leverage Binary Ninja's SSA representation of
memory. Every instruction that may modify memory produces a new memory
version, and each memory version is linked to the instruction that defines
it. At instruction 14 in Figure 7, the current memory version is `mem#2`.
By following the memory SSA chain, the analysis can determine that `mem#2`
is defined by instruction 13, while `mem#1` is defined by instruction 11.
Thus, instead of searching linearly through preceding instructions, the
slicer directly follows memory-version definitions to identify the writes
that influenced the current memory state.

---[ 3.4.2. Slicing Pseudo-Algorithm

The introduction of memory SSA extends the slicing algorithm by augmenting
the SSA use-def traversal with memory-defining dependencies. Previously,
the analysis followed only variable-defining instructions along SSA use-def
chains. With memory SSA, it additionally traverses memory-defining
instructions to account for potential memory-side effects. For example,
when the slice encounters a pointer expression such as `&cmd`, it
identifies memory definitions that may affect the referenced memory object.
More specifically, it follows the nearest memory definition whose operation
may access that object.

Mole's slicing procedure can therefore be summarised as follows:

For the current SSA variable `var#X`:

  ┌──Scope: Current Function──────────────────────────────────────────────┐
  │- If a variable-defining instruction for `var#X` exists, follow it.    │
  │- If a memory-defining instruction, reached by back traversing the     │
  │  memory chain from the current memory version, may access the memory  │
  │  object referenced by `var#X`, follow it.                             │
  └───────────────────────────────────────────────────────────────────────┘

  If neither applies and `var#X` corresponds to a function argument,
  propagate the slice to the corresponding argument in the caller(s).

[Figure 8: Pseudo-Algorithm for Slicing the SSA Variable `var#X`]

---[ 3.4.3. Variable Merging

In the running example, the slicer continues with instruction 13,
`mem#2=snprintf(cmd#0,64,"%s",env#0) @mem#1` (Figure 7). This instruction
defines the current memory version `mem#2` and uses the memory object
referenced by `cmd#0`. It therefore corresponds to the most recent
operation that may have modified the memory object denoted by `&cmd`.

To reach this conclusion, the analysis must first establish that `cmd#0`
and `cmd#1` refer to the same memory object. Although represented as
distinct SSA variables, both ultimately originate from the address
expression `&cmd` and thus correspond to the same stack variable. Mole
establishes such relationships by leveraging Binary Ninja's HLIL, which
performs variable merging [3]. This highlights the benefit of
Binary Ninja's layered intermediate representations exposed via its API:
slicing is performed at the MLIL level for precision and control, while
higher-level HLIL analysis can be leveraged when semantic recovery - such
as variable equivalence - is required. This combination allows Mole to
reason in terms of memory objects rather than treating SSA variables as
independent values.

Once this relationship has been established, the handler for `MLIL_CALL`
instructions determines whether the call may write to the referenced memory
object via one of its arguments. In the case of `snprintf`, the first
argument is an output buffer populated by the callee; consequently, the
call instruction constitutes a definition of the memory object referenced
by `cmd#0` and is included in the backward slice.

This discussion covers only a small subset of the pointer-reasoning
capabilities implemented in Mole. In practice, statically determining which
memory operations correspond to a given pointer is a long-standing and
challenging problem that remains an active area of research. A complete
treatment is therefore beyond the scope of this article; the goal here is
merely to illustrate the core ideas and mechanisms employed by Mole rather
than to provide an exhaustive overview of static pointer analysis.

To handle pointers, other instruction handlers must also be enhanced. For
instance, when the slicer encounters an `MLIL_LOAD` instruction, it
attempts to identify the corresponding memory definition by reasoning about
the accessed address. Depending on the expression, this may involve
resolving constant addresses, tracking pointer dereferences, or evaluating
array indexing to locate the corresponding `MLIL_STORE` instruction.
Similar logic is required for many other forms of memory access and pointer
manipulation.

Readers interested in the precise behaviour of these analyses, including
supported patterns and known edge cases, are encouraged to consult Mole's
unit tests [5], which effectively serve as an executable
specification of the current implementation.

Despite these mechanisms, pointer analysis remains one of the primary
sources of imprecision and limitation. A notable example is the handling of
global pointers and global memory objects. When the relevant memory
definition originates outside the current function - or cannot be resolved
to a sufficiently precise set of write locations - the slicer may fail to
reconstruct the full data-flow chain. Such cases remain an important
direction for future improvement.

--[ 3.5. Finding Paths

As discussed in the previous section, the slicer encounters the instruction
`mem#2=snprintf(cmd#0,64,"%s",env#0) @mem#1` in the running example (Figure
9). Since `snprintf` is an external library function without an available
internal representation, the analysis cannot descend into its
implementation. Instead, Mole approximates its behaviour using a
conservative summary: it assumes that the function may read from all input
arguments and may write to arguments known to act as output buffers.

This abstraction is necessary to keep the analysis tractable, but it may
introduce additional imprecision, as it ignores any internal semantics of
the callee beyond its observable interface.

┌─C Source Code──────────────────────────────────┐
│ int main(){                                    │
│   char cmd[64];                                │
│   char* env=getenv("CMD");                     │
│   snprintf(cmd,64,"%s",env);                   │
│   return execute(cmd);                         │
│ }                                              │
└────────────────────────────────────────────────┘

┌─Binary Ninja MLIL SSA (Simplified)─────────────┐
│   11 env#0,mem#1=getenv("CMD") @mem#0          │◀─ Source function
│   12 cmd#0=&cmd                                │
│-> 13 mem#2=snprintf(cmd#0,64,"%s",env#0) @mem#1│
│   14 cmd#1=&cmd                                │
│   15 res#0,mem#3=execute(cmd#1) @mem#2         │
│   16 return res#0                              │
└────────────────────────────────────────────────┘

[Figure 9: Function `main` of the Running Example]

Under this model, the slicer propagates the analysis through the relevant
call arguments. The pointer argument `cmd#0` is retained in the slice,
leading to its definition `cmd#0=&cmd`. In contrast, the constant arguments
`64` and `"%s"` are discarded, as they do not contribute to the data flow.
The remaining argument `env#0` is followed backward to its definition
`env#0,mem#1=getenv("CMD") @mem#0`, which finally corresponds to the
invocation of the source function.

At this stage, the instruction graph (Figure 3) for the running example has
been fully constructed. The graph can now be traversed to identify paths
between source and sink functions through the encoded data-flow
dependencies. For the running example, this traversal yields the following
backward slice:

┌─execute─────────────────────────────────────┐
│- return system(cmd#2)                       │◀─ Sink function
│- cmd#2=cmd#1                                │
│- cmd#1,mem#1=validate(cmd#0) @mem#0         │
│- cmd#0=arg1                                 │
└───────────────────── ↓ ─────────────────────┘
┌─main────────────────────────────────────────┐
│- res#0,mem#3=execute(cmd#1) @mem#2          │
│- cmd#1=&cmd                                 │
│- mem#2=snprintf(cmd#0,64,"%s",env#0) @mem#1 │
│- env#0,mem#1=getenv("CMD") @mem#0           │◀─ Source function
└─────────────────────────────────────────────┘

[Figure 10: Path in the Running Example]

By examining the execution path, it is evident that the value of an
environment variable is passed directly to the operating system for command
execution. As a result, an attacker who can control this environment
variable may inject arbitrary commands, leading to a command injection
vulnerability.

--[ 4. Path Triage

Often, in practice, analysis of real-world binaries yields a large number
of execution paths. A full treatment of this topic would warrant a
dedicated discussion; here, however, we briefly highlight two mechanisms in
Mole designed to address this challenge.

--[ 4.1. Path Grouping

A common observation is that many discovered execution paths ultimately
correspond to the same underlying vulnerability or behavioural condition,
differing only in minor control-flow variations. Such divergence, often
amplified by analysis imprecision, produces redundant or near-duplicate
paths that increase the effort required for downstream reasoning and
analysis.

To address this, Mole introduces configurable grouping strategies that
cluster related paths into equivalence classes based on shared semantic or
structural properties. For example, paths may be grouped by equivalent
sequences of function calls or other user-defined features. The design is
intentionally extensible, allowing analysts to implement custom grouping
heuristics tailored to specific binary analysis scenarios.

--[ 4.2. Path Prioritisation Using LLMs

Beyond redundancy, the sheer volume of generated paths often introduces a
significant usability challenge. Manual inspection is time-consuming and
relies heavily on expert judgement to distinguish benign behaviour from
potentially exploitable execution flows.

To assist with this process, Mole can integrate with local or remote large
language models (LLMs) to rank execution paths according to their
likelihood of corresponding to exploitable vulnerabilities, enabling
analysts to focus on the most relevant candidates first.

An in-depth evaluation of different models and prompting strategies for
this task is provided in [6].

--[ 5. Scalability and Automation

Next, we briefly present Mole's scalability and automation capabilities.
These include practical techniques for improving analysis precision,
support for large-scale headless execution, and integration with
AI-assisted workflows for automated vulnerability discovery.

Together, these components form a unified workflow for efficiently
isolating high-value targets in firmware and binary analysis scenarios
where dynamic verification is costly or impractical.

--[ 5.1. Fixing Function Type Signatures

The effectiveness of Mole's inter-procedural slicing is fundamentally
constrained by the quality of the underlying analysis performed by Binary
Ninja. In particular, accurate slicing depends on the correct recovery of
function boundaries, control-flow and call graphs, as well as other
higher-level structural information. While Binary Ninja provides a strong
analysis foundation, it is not infallible; like all static analysis tools,
it may produce incomplete or imprecise results in certain cases.

A recurring issue in this context is the inaccuracy of function type
signatures. These may manifest as missing or extraneous arguments, or as
incorrectly inferred argument types. Such errors are particularly harmful
to data-flow analysis, since Mole relies on well-defined function
signatures to propagate taint across their boundaries. When signatures are
incorrect, taint may fail to enter a callee, be dropped prematurely, or be
associated with incorrect variables, ultimately degrading or breaking the
precision of inter-procedural slicing.

To mitigate this limitation, Mole provides an explicit mechanism for
overriding and correcting function type signatures via configuration files.
Users can specify accurate prototypes for selected functions, including
sources, sinks, and intermediate library or application-specific routines.
During preprocessing, these user-defined signatures are applied before
slicing begins, ensuring that the inter-procedural analysis operates on a
consistent and semantically meaningful set of function interfaces.

This design allows Mole to partially decouple slicing precision from Binary
Ninja's inference quality, while still benefiting from its broader analysis
capabilities. As a result, critical data-flow paths, especially those
involving external APIs or poorly analysed functions, can be recovered more
reliably.

--[ 5.2. Headless Mode

Mole can be executed either within the Binary Ninja GUI or in headless
mode. The UI-integrated mode is well suited for interactive analysis and
detailed inspection of individual slicing results, whereas headless mode
targets automated, large-scale processing of binaries. This makes it
particularly useful for scripted workflows, such as identifying high-value
targets in firmware or analysing large binary corpora where dynamic
analysis would be too costly or impractical.

Since Mole is implemented in Python, scalability within a single process is
constrained by the global interpreter lock (GIL), which limits true
parallel execution in multi-threaded contexts. Headless mode helps address
this limitation by enabling multiple independent Mole instances to run as
separate processes. This allows effective horizontal scaling of analysis
workloads and improves throughput when operating on large sets of binaries.

--[ 5.3. AI-Assisted Analysis Workflows

We recently experimented with exposing Mole as a tool to AI coding agents
(such as Claude Code). To enable this integration, we developed a dedicated
capability that instructs the agent on how to automatically generate taint
models for Mole, i.e., configuration files specifying relevant source and
sink functions. This process incorporates a dedicated Binary Ninja MCP
server to assist the agent in analysing the target binary and identifying
meaningful attack vectors and function interfaces.

Once the taint model is generated, the agent can invoke Mole to perform
large-scale path discovery. In a second step, we introduced an additional
capability that guides the agent in analysing the resulting paths and
assessing their potential for exploitable vulnerabilities.

Early experiments indicate that this hybrid workflow, combining
deterministic path discovery with LLM-based reasoning, significantly
improves results. By reducing the search space and steering the model
towards semantically relevant program regions, it avoids a common failure
mode of LLMs: becoming lost in low-level complexity when tasked with
identifying vulnerabilities directly.

Overall, these initial findings suggest a promising direction for future
work, particularly when combined with dynamic analysis techniques that
allow models to validate and refine their hypotheses against runtime
behaviour.

--[ 6. Evaluation

To continuously evaluate our slicing approach, comprehensive unit tests [5]
have proven invaluable. These tests cover both functionality that is
expected to work correctly and remain stable over time, as well as cases
that are currently unsupported. The latter helps document known limitations
and ensures that future changes do not introduce unintended behaviour.

Beyond unit testing, we regularly evaluate our tool on real-world targets
in its primary application domain: vulnerability discovery. This allows us
to assess its practical effectiveness, identify areas for improvement, and
validate its usefulness in realistic analysis scenarios.

--[ 6.1. Vulnerability Discoveries

The table below summarises the vulnerabilities identified with the aid of
Mole that had been publicly disclosed at the time of writing. These
findings demonstrate the tool's effectiveness in identifying
security-critical data flows across a range of embedded and industrial
systems.

| Product Category          | Vulnerability Type                    | Severity | CVE                                                               |
|---------------------------|---------------------------------------|----------|-------------------------------------------------------------------|
| Industrial Managed Switch | Stack-Based Buffer Overflow           | Critical | [CVE-2025-41730](https://www.cve.org/CVERecord?id=CVE-2025-41730) |
| Industrial Managed Switch | Stack-Based Buffer Overflow           | Critical | [CVE-2025-41732](https://www.cve.org/CVERecord?id=CVE-2025-41732) |
| Industrial Managed Switch | Multiple Stack-Based Buffer Overflows | Critical | Fixed; no CVEs assigned yet.                                      |
| BACnet Router             | Stack-Based Buffer Overflow           | High     | [CVE-2025-41766](https://www.cve.org/CVERecord?id=CVE-2025-41766) |
| Domotics Gateway          | Multiple OS Command Injections        | High     | Fixed; no CVEs assigned yet.                                      |
| Domotics Gateway          | Arbitrary File Deletion               | High     | [CVE-2026-35076](https://www.cve.org/CVERecord?id=CVE-2026-35076) |
| Domotics Gateway          | Arbitrary File Deletion               | High     | [CVE-2026-35077](https://www.cve.org/CVERecord?id=CVE-2026-35077) |
| Domotics Gateway          | Arbitrary File Deletion               | High     | [CVE-2026-35078](https://www.cve.org/CVERecord?id=CVE-2026-35078) |
| Domotics Gateway          | Arbitrary File Deletion               | High     | [CVE-2026-35079](https://www.cve.org/CVERecord?id=CVE-2026-35079) |
| Domotics Gateway          | Arbitrary File Deletion               | High     | [CVE-2026-35080](https://www.cve.org/CVERecord?id=CVE-2026-35080) |
| Domotics Gateway          | Arbitrary Process Termination         | High     | [CVE-2026-35081](https://www.cve.org/CVERecord?id=CVE-2026-35081) |
| Domotics Gateway          | Local File Inclusion                  | High     | [CVE-2026-35082](https://www.cve.org/CVERecord?id=CVE-2026-35082) |
| Domotics Gateway          | Stack-Based Buffer Overflow           | High     | [CVE-2026-35083](https://www.cve.org/CVERecord?id=CVE-2026-35083) |
| Domotics Gateway          | Stack-Based Buffer Overflow           | High     | [CVE-2026-35084](https://www.cve.org/CVERecord?id=CVE-2026-35084) |
| Domotics Gateway          | Stack-Based Buffer Overflow           | High     | [CVE-2026-35085](https://www.cve.org/CVERecord?id=CVE-2026-35085) |

--[ 6.2. Discussion

As shown in the table above, our evaluation primarily resulted in the
discovery of high-severity vulnerabilities. However, it is important to
note that the static taint analysis approach employed by Mole cannot detect
all classes of vulnerabilities. Its effectiveness is inherently limited by
the extent to which a vulnerability can be modelled as a data-flow problem.

In general, the approach is applicable to vulnerability classes for which
meaningful source-to-sink relationships can be defined. Consequently, it is
particularly well suited for identifying vulnerabilities that arise from
the propagation of attacker-controlled data, including memory-safety
violations, injection flaws, and path traversal vulnerabilities. In
contrast, it is less effective at detecting vulnerabilities that do not
manifest through explicit data flows, such as authentication and
authorisation flaws, business-logic errors, race conditions, cryptographic
weaknesses, or insecure configurations.

--[ 7. Conclusion

In this article, we presented the design and implementation of a static
taint analysis engine built on top of Binary Ninja. We showed how MLIL in
SSA form enables precise backward slicing of variables to track taint flow
through a program, forming the core of our analysis pipeline.

While intra-procedural taint tracking is relatively straightforward in this
model, extending the analysis across function boundaries introduces
significant complexity. However, such inter-procedural reasoning is
essential for real-world vulnerability discovery, where taint sources and
sinks are rarely confined to a single function.

We further demonstrated how Binary Ninja's less commonly used features, in
particular memory versioning, provide a powerful abstraction for reasoning
about pointer-induced state changes. Combined with its multi-layered
intermediate language architecture, this allowed us to strategically apply
MLIL for precise variable and memory-level slicing, while leveraging HLIL
for higher-level variable merging and pointer reasoning.

Finally, we validated our approach through real-world findings, where
several vulnerabilities were uncovered during iterative improvements of our
tool, Mole, highlighting the practical effectiveness of the presented
techniques.

--[ 8. References

- [1] [Vulnerability Modeling with Binary Ninja](https://blog.trailofbits.com/2018/04/04/vulnerability-modeling-with-binary-ninja/)
- [2] [Binary Ninja](https://binary.ninja/)
- [3] [Binary Ninja Intermediate Languages](https://docs.binary.ninja/dev/bnil-overview.html)
- [4] [Mole Binary Ninja Plugin](https://github.com/cyber-defence-campus/mole)
- [5] [Mole Unit Tests](https://github.com/cyber-defence-campus/mole/tree/main/tests)
- [6] [Evaluating and Enhancing LLM-Assisted Path Vulnerability Analysis in Binary Code](https://raw.githubusercontent.com/cyber-defence-campus/mole_resources/main/reports/Evaluating_and_Enhancing_LLM_Assisted_Path_Vulnerability_Analysis_in_Binary_Code.pdf)

|=[ EOF ]=---------------------------------------------------------------=|