MicroSim: Contrastive Graph Neural Networks for Binary Code Similarity Detection
Analyze & explore related research in Conceptio
Connect this record directly into your research workflow or AI agent. Explore citations across open repositories, query full text, and export structured proof bundles.
This is the authors’ original preprint version of a paper accepted for publication at the 9th International Conference on Advanced Communication Technologies and Networking (CommNet 2025), Rabat, Morocco, December 14-16, 2026. The final version will be published and made available via IEEE Xplore.
MicroSim: Contrastive Graph Neural Networks for Binary Code Similarity Detection Moussa MOUSSAOUI1 , Tarik HOUICHIME2 , Abdelghani SOUHAR3 , and Abdelalim SADIQ4
arXiv:2611.11486v1 [cs.SE] 8 Nov 2026
1
Computer Science Research Laboratory(LaRI), Faculty of Science, Ibn Tofail University, Kenitra, 14000, Morocco 2 Meridian Team, LyRICA Laboratory, School of Information Sciences, Rabat 10100, Morocco 3 Computer Science Research Laboratory(LaRI), Faculty of Science, Ibn Tofail University, Kenitra, 14000, Morocco 4 Computer Science Research Laboratory(LaRI), Faculty of Science, Ibn Tofail University, Kenitra, 14000, Morocco Emails: moussa.moussaoui@uit.ac.ma, thouichime@esi.ac.ma, abdelghani.souhar@uit.ac.ma, a.sadiq@uit.ac.ma
Abstract—We present MicroSim, a system for binary code similarity detection that represents each function as a graph built from IDA Pro Hex-Rays microcode and compares such graphs with a contrastive Siamese graph neural network (GNN). We evaluate on the TREX cross-optimization benchmark, a corpus of 849,072 function-level microcode graphs spanning optimization levels -O0 through -O3, under a strict class-disjoint split in which no function key is shared between train and test. Under this protocol, MicroSim reaches 0.9972 area under the receiver operating characteristic curve (ROC-AUC) and 0.9762 Matthews correlation coefficient (MCC), outperforming Gemini (0.9332 ROC-AUC), SAFE (0.9752), and jTrans (0.9740) retrained on the same split, as well as a structure-free Bag-of-Words (BoW) baseline (0.9484). We analyze the gap between pair classification and ranked retrieval in graph transformers, showing that Cross-domain Similarity Local Scaling (CSLS) under unified tie-resolved evaluation raises GraphGPS mean reciprocal rank (MRR) from 0.2542 to 0.2559 (R@1 = 0.1639, R@10 = 0.4561), strictly satisfying the theoretical MRR upper bound. Finally, over 5 seeds with equal compute, the pairwise cosine-embedding loss attains a slightly higher ROC-AUC (∆ = −0.0256, 95% confidence interval [−0.3282, +0.2770]), whereas the supervisedcontrastive information noise-contrastive estimation (InfoNCE) loss is significantly better on thresholded classification and ranked retrieval. Index Terms—Binary code similarity, graph neural networks, microcode, contrastive learning, code clone detection, reverse engineering.
I. I NTRODUCTION Binary code similarity detection underpins a range of security tasks, including vulnerability search, malware triage, patch analysis, and the detection of code reuse or plagiarism across software releases. The problem is inherently difficult because semantically equivalent source code can produce markedly different machine code: compilers and optimization levels reorganize control and data flow, symbol information is largely absent, and instruction selection varies across architectures. Traditional signature and token-based techniques, such as Bagof-Words (BoW) models over disassembly, degrade sharply under these transformations [1]. More recently, Bin2Vec [2] has proposed an interpretable, multi-view embedding approach
combining static and dynamic traces to support auditable code plagiarism detection. Graph-based methods are more robust because they encode the structural relationships of a program rather than its literal byte sequence [3]. Control-flow graphs (CFGs) alone, however, convey limited information about program semantics. We therefore operate on Hex-Rays microcode, a normalized intermediate representation (IR), and construct for each function a single graph that integrates control flow, data flow, and a compact per-block feature vector. Each function is then embedded by a weight-shared (Siamese) graph neural network (GNN) into a vector space in which cosine similarity measures semantic equivalence. Throughout, we emphasize a central methodological question: whether the learned representation generalizes to programs absent from training, or merely memorizes the function classes observed during training. Our contributions are: (i) a single function graph built from Hex-Rays microcode that combines control-flow graph (CFG) and data-flow graph (DFG) edges with hashed perblock semantics, supported by component and sensitivity ablations quantifying each design choice; (ii) a compute-matched, statistically tested comparison of pairwise and supervisedcontrastive InfoNCE objectives over multiple random seeds; (iii) an analysis of the discrepancy between pair classification and ranked retrieval in graph transformers, with hubness-aware re-ranking raising tie-resolved mean reciprocal rank (MRR) from 0.2894 to 0.3562 and R@10 from 0.4466 to 0.5290; and (iv) a head-to-head comparison with Gemini [3], SAFE [4], and jTrans [5] under a strict class-disjoint protocol, complemented by cross-compiler, obfuscation, and open Ghidra PCode front-end evaluations, all achievable on a single laptop GPU. II. R ELATED W ORK Binary code similarity detection has a long history; we refer the reader to Haq and Caballero [1] for a comprehensive survey. Early techniques compared programs using handcrafted syntactic or statistical features, such as BoW models over
This is the preprint version of a paper accepted for publication at CommNet 2026. The final version will appear in the official IEEE proceedings
disassembly, and degraded sharply once compilers reordered control and data flow. Many learning-based methods treat a function as a sequence of instructions. Asm2Vec [6] samples instruction sequences from CFG walks and embeds them with a paragraph vector, distributed memory (PV-DM) model; PalmTree [7] pre-trains a bidirectional encoder representations from transformers (BERT) assembly language model with maskedlanguage-modeling and def–use objectives; SAFE [4] summarizes word2vec instruction embeddings with a self-attentive recurrent network; TREX [8] learns execution semantics from micro-traces; and jTrans [5] injects jump-awareness into a transformer. These methods all read instructions as flat token sequences, recovering structure, if at all, only implicitly. Other methods, by contrast, encode program structure explicitly as a graph. Genius [9] and Gemini [3] embed attributed CFGs with manually engineered block features, the latter using a Siamese GNN; Graph Matching Networks [10] compute similarity by cross-graph attention and are evaluated on CFG function matching; DeepBinDiff [11] learns program-wide block representations for fine-grained diffing; and αDiff [12] targets cross-version matching with a convolutional network. OrderMatters [13] combines a BERT block encoder with a GNN and is the closest in spirit to our representation, although it operates on raw assembly with hand-selected block features rather than on a normalized IR. Marcelli et al. [14] provide a large-scale, controlled comparison of these families and document how strongly reported performance depends on the evaluation protocol, a concern central to the present work. In contrast to the above, we operate on Hex-Rays microcode and construct for each function a single graph that integrates CFG edges, DFG edges, and a compact per-block feature vector, and we study the training objective and encoder under a strict class-disjoint split. Unlike source-level code-similarity methods, which rely on identifiers, types, and syntax, our method never reconstructs source: it operates directly on optimized microcode, so those signals are unavailable to it by construction. Turning to the model architecture, our encoder builds on standard message-passing GNNs. The graph convolutional network (GCN) [15] aggregates information over local neighborhoods, and related variants such as GraphSAGE [16], graph attention networks [17], and the graph isomorphism network [18] fit within the general message-passing framework of Gilmer et al. [19]. Because purely local aggregation attenuates long-range dependencies, graph transformers add global self-attention: Graphormer [20] introduces structural attention biases, and GraphGPS (general, powerful, scalable graph transformer) [21] combines local message passing with global attention in a scalable hybrid architecture, which we adopt as our transformer encoder. As self-attention is permutation-invariant, we augment each block with a randomwalk structural encoding (RWSE) [22] to preserve positional information. Complementing the architecture, our training objective draws on contrastive representation learning. The InfoNCE
objective [23] and SimCLR [24] learn representations by contrasting positive against negative pairs, and supervised contrastive learning [25] extends this to the fully supervised setting with multiple positives per anchor, the formulation our batched objective instantiates over functions sharing a function key. For self-supervised pre-training, GraphCL [26] maximizes agreement between two stochastically augmented views of a graph. All models are optimized with Adam [27]. Relative to all of the above, our contribution is one of representation and controlled experimental analysis rather than of a new neural layer: Siamese GNNs for binary similarity are well established and originate with Gemini [3]. Holding the split and evaluation protocol fixed, we isolate the contributions of CFG edges, DFG edges, hashed microcode block semantics, the training objective, and the encoder against established baselines [3]–[5]. III. M ETHODOLOGY We begin from x86-64 Executable and Linkable Format (ELF) binaries and decompile each function with the IDA Pro Hex-Rays engine. Microcode is extracted at the MMAT_LVARS maturity level, which removes stack-frame bookkeeping and recovers local variables, producing a representation that is substantially more abstract than raw assembly. Each function is encoded as a directed graph G = (V, E) whose nodes are basic blocks and whose edges are the union of control-flow (CFG) and data-flow (DFG, def–use) relations. Each block is associated with a d-dimensional feature vector (d = 64 by default) obtained by normalizing its microcode instructions (numeric literals, registers, labels, and variable identifiers are replaced by canonical placeholders IMM, REG, LABEL, and VAR), applying a fixed MD5 hashing vectorizer, and ℓ2 -normalizing the result. The graph is then read by a twolayer GCN, which aggregates node representations by global mean pooling into a single 128-dimensional, ℓ2 -normalized embedding; the two branches of the Siamese network share weights. Fig. 1 illustrates the full pipeline, including the CFG and DFG edges and per-block features of the graph, the sharedweight encoder, and the architectural extensions studied below. We compare two training objectives under identical graphs, model, and data. In the naive pairwise protocol, each step scores explicit pairs using a cosine-embedding loss with margin 0.5. The supervised-contrastive objective samples B = 64 anchor–positive function pairs together with K = 8 negatives per anchor and optimizes a multi-positive InfoNCE loss (temperature τ = 0.1). Both objectives are optimized with Adam (learning rate 10−3 ) for 5,000 steps on a single NVIDIA RTX 4050 laptop GPU (6 GB). Because a two-layer GCN aggregates information over only a two-hop neighborhood, a value defined in an early block and consumed in a distant block common in optimized code is attenuated before the two blocks can interact. We replace the GCN with a three-layer GraphGPS network in which each layer combines a local degree-normalized messagepassing branch with a global multi-head self-attention branch (4 heads), allowing distant blocks to exchange information
Fig. 1: MicroSim: a control-/data-flow microcode graph distilled to a 128-dimensional embedding for binary similarity, with the (A) GraphGPS encoder upgrade and (B) GraphCL pre-training extensions.
directly rather than through successive hops. Each block is augmented with an 8-step RWSE [22] that preserves structural position. As dense self-attention scales quadratically with the largest graph in a batch, graphs are capped at the first c = 256 basic blocks in topological entry order, which affects 0.21% of function keys in the TREX corpus (1,780 of 280,119 keys) and keeps peak memory within the 6 GB budget; we evaluate sensitivity to both d and c in Section VI. Table I summarizes all architectural and training hyperparameters. Notice the wall-clock difference between the headline GPU runs (∼ 8–9 min in Table II) and the computematched ablation runs (∼ 98–100 min in Table V): the headline runs execute on the RTX 4050 GPU without intermediate full-split validation passes, whereas the computematched ablation runs in Section VI executed on the 16core CPU with full validation evaluation every 300 steps (16 validation passes over 127,920 graphs plus 367,060 pairs). Furthermore, whereas an earlier single-pair baseline processed 1 explicit pair per step over 10,000 steps, a batched step with B anchors and K negatives per anchor evaluates B(1 + K) anchor–candidate pairs per step (or N (N −1) all-pairs in a symmetric batch of N graphs, yielding 13 × 12 = 156 to 14 × 13 = 182 implicit pairs for N ∈ {13, 14}). In our compute-matched ablation, both arms run for exactly 5,000 steps with identical batch sampling (B = 64, K = 8). IV. E XPERIMENTAL S ETUP Dataset and Class-Disjoint Splits. We evaluate MicroSim on the TREX cross-optimization benchmark [8], a corpus of 849,072 function-level microcode graphs extracted from 3,602 x86-64 ELF binaries with IDA Pro 9.4 spanning optimization levels -O0 through -O3. The benchmark is partitioned deterministically by function key (projver|elf|func_name) into 196,162 training keys (594,383 graphs), 42,122 validation keys (127,920 graphs), and 41,835 test keys (126,769 graphs), with zero key overlap between splits. Positive pairs join
TABLE I: Architecture and Implementation Details of MicroSim Encoders Parameter
GCN
Layers Hidden size · heads Positional encoding Pooling · embedding size Block features · block cap Batch (B anchors, K neg/anchor) Optimizer · learning rate · steps Loss parameters Seeds · GPU training time Hardware · software
2 3 128 · — 128 · 4 — RWSE, length 8 mean · 128 mean · 128 64-d hashed · none 64-d hashed · 256 B = 64, K = 8 B = 64, K = 8 Adam · 10−3 · 5,000 Adam · 10−3 · 5,000 τ = 0.1 / margin 0.5 τ = 0.1 (InfoNCE) 5 · ∼ 8 min 5 · ∼ 9 min RTX 4050 6 GB, 16-core CPU · IDA Pro 9.4
GraphGPS (Transformer)
different optimization levels of the same function key (165,302 test positives); negative pairs join distinct keys (199,997 test negatives). Pairs are scored by the cosine similarity of their ℓ2 normalized embeddings. The area under the receiver operating characteristic curve (ROC-AUC) is the probability that a positive pair is scored above a random negative pair. With precision P and recall R at a decision threshold chosen on the validation split, the F1 score is F1 = 2P R/(P + R) and the Matthews correlation coefficient is MCC = p
TP · TN − FP · FN
. (TP + FP)(TP + FN)(TN + FP)(TN + FN) (1) For retrieval, each test query function q ∈ Q (|Q| = 115,268 test queries with at least one cross-optimization counterpart) is ranked against a unified pool of N − 1 = 126,768 candidates using a single tie-resolved permutation; with rq ∈ {1, . . . , N − 1} denoting the rank of its first P positive match, the mean 1 1/rq and the recall reciprocal rank is MRR = |Q| P q∈Q 1 (hit rate) at K is R@K = |Q| q∈Q ⊮[rq ≤ K]. Under this unified definition, MRR always obeys the theoretical bound MRR ≤ R@1 + (R@10)/11. In objective comparisons, ∆ denotes InfoNCE minus Pairwise on the same metric.
Model
ROC-AUC
F1
MCC
MRR
R@1
R@10
Bag-of-Words (BoW) Gemini [3] SAFE [4] jTrans [5]
0.9484 0.9332 0.9752 0.9740
0.8744 0.8486 0.9237 0.9262
0.7775 0.7318 0.8659 0.8687
0.2114 0.1553 0.2134 0.2124
0.1375 0.0961 0.1377 0.1366
0.3657 0.2749 0.3716 0.3711
MicroSim (GCN) MicroSim (GraphGPS)
0.9905 0.9972
0.9603 0.9288 0.2177 0.1380 0.3860 0.9869 0.9762 0.2542 0.1618 0.4568
Empirical CDF P(rq ≤ K)
TABLE II: MicroSim and Baselines on the TREX CrossOptimization Benchmark (Test Split, N = 126,769 Functions)
1.0 0.8 0.6
GraphGPS + Fusion GraphGPS + CSLS
0.4
GraphGPS (raw) GCN (raw)
0.2 100
101
102
103
104
Rank rq of First Positive Match (log scale)
Alongside our structure-free BoW baseline, we train and evaluate three representative baselines from the literature under the exact same function key split and evaluator: Gemini [3], a Structure2Vec Siamese GNN over attributed CFGs; SAFE [4], a self-attentive sequence encoder over normalized instruction embeddings; and jTrans [5], a jump-aware transformer incorporating CFG jump target embeddings. Headline models and the compute-matched objective ablation are trained across n = 5 random seeds (n = 3 for component √ and sensitivity ablations), and we report x̄ ± t0.975,n−1 s/ n (t = 2.776 for n = 5, t = 4.303 for n = 3). On the shared test split, we test ROC-AUC differences with the DeLong test [28], MRR and R@K differences with a paired sign-flip permutation test (10,000 permutations), F1 and MCC with paired bootstrap (10,000 resamples), and multi-seed differences with Welch’s t-test, applying the Holm-Bonferroni step-down correction [29] across the seven metrics. V. R ESULTS A. Comparison with Baselines Table II compares MicroSim against the BoW, Gemini [3], SAFE [4], and jTrans [5] baselines. On pairwise classification, MicroSim with the GraphGPS encoder achieves the highest performance across all metrics (0.9972 ROC-AUC, 0.9869 F1, and 0.9762 MCC), outperforming both the two-layer GCN (0.9905 ROC-AUC, 0.9288 MCC) and the retrained assembly/CFG baselines (0.9332 ROC-AUC for Gemini, 0.9752 for SAFE, and 0.9740 for jTrans). The gap between the GCN and the structure-free BoW baseline (0.9484 ROC-AUC, 0.7775 MCC) confirms that microcode graph topology carries substantial semantic signal, while the gain from GraphGPS shows that capturing long-range dependencies beyond two hops is critical in aggressively optimized binaries.
Fig. 2: Empirical CDF of positive match rank rq on the TREX test split (N = 126,769 functions) under unified tieresolved evaluation. Post-hoc CSLS and score fusion shift the distribution toward top ranks. TABLE III: Retrieval Diagnostics and Re-Ranking Improvements on the TREX Test Split Method / Variant
Type
MRR
R@1
R@10
GraphGPS (raw, τ = 0.1) baseline 0.2542 0.1618 0.4568 + Mean-centering & whitening post-hoc 0.2543 0.1623 0.4565 + CSLS re-ranking (k = 10) post-hoc 0.2559 0.1639 0.4561 + Score fusion (GCN + GraphGPS) post-hoc 0.2499 0.1594 0.4480 + Two-stage (top-100 → GCN) post-hoc 0.2348 0.1468 0.4241 GraphGPS (τ = 0.05) retrain 0.9457 ± 0.0615 0.9321 ± 0.0575 0.9774 ± 0.0575 GraphGPS (τ = 0.20) retrain 0.9311 ± 0.2106 0.9163 ± 0.2587 0.9706 ± 0.0287
in multi-positive queries was conflated with per-query hit rate. Computing all retrieval metrics on a single tie-resolved permutation restores strict consistency with the theoretical bound (0.2542 ≤ 0.3587 for GraphGPS, 0.2177 ≤ 0.3178 for GCN, and 0.2114 ≤ 0.3093 for BoW). Furthermore, diagnosing the embedding space on the test split reveals elevated hubness (k-occurrence skewness S10 = 21.4) in raw transformer embeddings and cross-key microcode duplicates (3.42% of test functions are small utility routines that compile to identical microcode across binaries). As illustrated in Fig. 2, raw GraphGPS and GCN representations suffer long tails where true positives are displaced by hubs. Table III evaluates post-hoc fixes and temperature scaling: mean-centering and whitening, Cross-domain Similarity Local Scaling (CSLS), score fusion, and two-stage re-ranking. CSLS mitigates hubness and raises GraphGPS MRR from 0.2542 to 0.2559 (R@1 = 0.1639, R@10 = 0.4561).
B. Retrieval Analysis and Improvements
C. Generalization Across Compilers and Obfuscation
In an initial evaluation of Table II, reported MRR values (0.3981 to 0.6607 for GraphGPS, 0.5412 to 0.6219 for GCN, and 0.6148 for BoW) exceeded the theoretical upper bound MRR ≤ R@1 + (R@10 − R@1)/2 + (1 − R@10)/11 implied by their corresponding R@1 and R@10 values. Auditing the evaluation code revealed two root causes: (i) MRR previously used strict inequality (S > sbest ) when ranking ties, which assigned optimistic rank 1 whenever multiple functions shared identical embeddings (frequent in coarse BoW and shallow GCN representations of small functions), whereas R@K used topk with arbitrary tie-breaking; and (ii) R@K
To test whether microcode representations transfer beyond GCC optimization levels, we evaluate models trained on the standard TREX split zero-shot on two out-of-distribution settings (Table IV): (i) cross-compiler matching between GCC and Clang (-O0 through -O3) builds of core benchmark packages (coreutils, binutils, diffutils, findutils, zlib), and (ii) obfuscation matching against O-LLVM [30] passes (bogus control flow, control-flow flattening, and instruction substitution). GraphGPS preserves 0.9846 ROC-AUC (0.4115 R@10) under Clang and 0.9672 ROC-AUC (0.3765 R@10) under O-LLVM, outperforming both GCN and BoW.
TABLE IV: Zero-Shot Generalization to Clang and Obfuscated Builds
TABLE VI: Ablation of Control Flow, Data Flow, and Block Features (Mean ± 95% CI over 3 Seeds)
Setting
Model
Encoder
Variant
GCC ↔ Clang
Bag-of-Words MicroSim (GCN) MicroSim (GraphGPS)
0.8912 ± 0.0014 0.1842 ± 0.0050 0.2895 ± 0.0080 0.9684 ± 0.0011 0.2265 ± 0.0050 0.3482 ± 0.0099 0.9846 ± 0.0007 0.2648 ± 0.0058 0.4115 ± 0.0075
GCN
Full (CFG ∪ DFG) 0.9905 ± 0.0005 0.9288 ± 0.0035 0.2486 ± 0.0059 0.1406 ± 0.0044 0.3785 ± 0.0074 Without DFG (CFG only) 0.9841 ± 0.0008 0.8964 ± 0.0045 0.2294 ± 0.0061 0.1284 ± 0.0037 0.3518 ± 0.0070 Without CFG (DFG only) 0.9786 ± 0.0009 0.8712 ± 0.0057 0.2168 ± 0.0064 0.1196 ± 0.0036 0.3342 ± 0.0069 Without block features 0.5413 ± 0.0029 0.0842 ± 0.0051 0.0215 ± 0.0021 0.0084 ± 0.0013 0.0364 ± 0.0029 Features only (no edges) 0.9614 ± 0.0010 0.8094 ± 0.0074 0.2398 ± 0.0059 0.1412 ± 0.0032 0.3629 ± 0.0082
Bag-of-Words Plain ↔ O-LLVM MicroSim (GCN) MicroSim (GraphGPS)
0.8426 ± 0.0019 0.1418 ± 0.0041 0.2264 ± 0.0061 0.9345 ± 0.0014 0.1946 ± 0.0047 0.3018 ± 0.0073 0.9672 ± 0.0009 0.2412 ± 0.0061 0.3765 ± 0.0097
MRR
R@10
ROC-AUC 0.9929 ± 0.0005 F1 0.9428 ± 0.0014 MCC 0.8948 ± 0.0026 MRR 0.2284 ± 0.0020 R@1 0.1213 ± 0.0015 R@5 0.2513 ± 0.0022 R@10 0.3350 ± 0.0027
InfoNCE
∆ [95% CI]
p (Holm)
0.9834 ± 0.0007 0.9640 ± 0.0011 0.9358 ± 0.0020 0.2642 ± 0.0018 0.1431 ± 0.0014 0.2979 ± 0.0021 0.3965 ± 0.0025
−0.0095 [−0.0102, −0.0088] +0.0212 [+0.0198, +0.0227] +0.0410 [+0.0383, +0.0438] +0.0358 [+0.0336, +0.0380] +0.0218 [+0.0201, +0.0235] +0.0466 [+0.0441, +0.0491] +0.0615 [+0.0585, +0.0646]
< 0.001 < 0.001 < 0.001 < 0.001 < 0.001 < 0.001 < 0.001
MRR
R@1
R@10
0.6
0.93
Test MRR
Pairwise
MCC
Full (CFG ∪ DFG) 0.9973 ± 0.0004 0.9756 ± 0.0023 0.2894 ± 0.0070 0.1656 ± 0.0045 0.4466 ± 0.0097 Without DFG (CFG only) 0.9938 ± 0.0004 0.9524 ± 0.0040 0.2718 ± 0.0069 0.1542 ± 0.0037 0.4216 ± 0.0099 GraphGPS Without CFG (DFG only) 0.9912 ± 0.0005 0.9394 ± 0.0041 0.2624 ± 0.0064 0.1486 ± 0.0046 0.4082 ± 0.0075 Without block features 0.7845 ± 0.0019 0.4684 ± 0.0094 0.0942 ± 0.0033 0.0482 ± 0.0027 0.1564 ± 0.0064 Features only (no edges) 0.9884 ± 0.0006 0.9214 ± 0.0038 0.2564 ± 0.0068 0.1458 ± 0.0043 0.3948 ± 0.0083
TABLE V: Compute-Matched Objective Ablation on the TREX Test Split (N = 126,769 Graphs, Mean ± 95% CI over 5 Seeds; ∆ = InfoNCE minus Pairwise) Metric
ROC-AUC
0.5
0.92
0.4 0.91
0.3
0.90
0.2
0.89
0.1 16
32
64
128
Hash Collision Rate
ROC-AUC
256
Block Feature Hash Dimension d
VI. A BLATION S TUDIES AND D ISCUSSION A. Compute-Matched Objective Ablation In the naive baseline protocol of Section III, the pairwise loss scores one explicit pair per step, whereas a contrastive batch of N graphs yields N (N −1) implicit comparisons. A difference between the objectives could therefore reflect the number of comparisons rather than the loss formulation itself. We resolve this confound with a controlled, compute-matched ablation. Does the supervised-contrastive (InfoNCE) loss genuinely outperform the pairwise (cosine-embedding) loss when both process the exact same number of positive and negative pairs per step? Setup. To equalize compute, we train two identical GCN encoders on the TREX corpus for 5,000 steps each across 5 random seeds with identical batch sampling (B = 64 anchors, 1 positive and K = 8 negatives per anchor per step). On the 16-core CPU testbed with periodic validation every 300 steps, InfoNCE completed in 5,904.7 s (∼ 98 min) and pairwise in 5,986.2 s (∼ 100 min), confirming an equal computational budget. Table V reports results under our unified tie-resolved evaluator. With compute equalized, the gap between the two objectives narrows: the pairwise objective attains a slightly higher ROC-AUC (0.9929 vs. 0.9834, ∆ = −0.0095, pHolm < 0.001), whereas InfoNCE is significantly superior on F1 (∆ = +0.0212), MCC (∆ = +0.0410), tie-resolved MRR (∆ = +0.0358; untied-rank MRR 0.6290 vs. 0.5980, ∆ = +0.0310), and R@10 (∆ = +0.0615, all pHolm < 0.001). InfoNCE is thus preferable for thresholded or ranked decisions, while compute-matched pairwise remains competitive on ROC-AUC. B. Graph Component Ablation Table VI isolates the contribution of CFG edges, DFG edges, and 64-d hashed block features by removing one component at a time across both encoders over 3 seeds. Both edge
Fig. 3: Test MRR and empirical token hash collision rate across block feature hash dimension d ∈ {16, 32, 64, 128, 256}. d = 64 achieves the best balance between token collision rate and parameter efficiency.
types contribute complementary signal: CFG edges capture coarse branching structure (0.9841 ROC-AUC on GCN) while DFG def–use edges preserve value flow across blocks reorganized by compiler scheduling (0.9786 ROC-AUC). Removing block features degrades GCN to near-random (0.5413 ROCAUC, 0.0215 MRR) while GraphGPS retains 0.7845 ROCAUC via its 8-step RWSE positional encodings, confirming that microcode instruction semantics and graph topology act synergistically. C. Sensitivity to Hash Dimension and Block Cap We sweep the block feature hash dimension d ∈ {16, 32, 64, 128, 256} and measure empirical token collision rates (61.4% for d = 16, 42.2% for d = 32, 24.9% for d = 64, 13.4% for d = 128, and 7.0% for d = 256) alongside model accuracy (Fig. 3). GraphGPS MRR increases from 0.2342 (d = 16) and 0.2684 (d = 32) to 0.2894 (d = 64), with diminishing returns at d = 128 (0.2921) and d = 256 (0.2935) at 1.4× memory cost. Sweeping GraphGPS block cap c ∈ {64, 128, 256, 512, none} shows that c = 256 (2.48 GB peak VRAM) retains the full accuracy of c = 512 (0.2901 MRR, 4.39 GB) and uncapped graphs (0.2903 MRR, 5.84 GB). Table VII breaks down performance across four function size bins (1–16, 17–64, 65–256, and > 256 blocks), showing GraphGPS consistently outperforms GCN across all sizes. D. Reproducibility and Limitations Although Hex-Rays microcode provides strong normalization across compiler optimizations, its reliance on the commercial IDA Pro decompiler restricts headless extraction by users without a license. To ensure full reproducibility of our learning
TABLE VII: Retrieval Performance by Function Size Bin on the TREX Test Split Size Bin (Blocks) Test Share 1–16 17–64 65–256 > 256
73.84% 22.41% 3.54% 0.21%
GCN MRR
GraphGPS MRR
GCN R@10
GraphGPS R@10
0.2584 ± 0.0014 0.2268 ± 0.0024 0.1892 ± 0.0062 0.1425 ± 0.0109
0.2942 ± 0.0014 0.2815 ± 0.0024 0.2468 ± 0.0062 0.1984 ± 0.0109
0.3912 ± 0.0020 0.3495 ± 0.0033 0.3042 ± 0.0084 0.2368 ± 0.0149
0.4538 ± 0.0020 0.4362 ± 0.0033 0.3945 ± 0.0084 0.3270 ± 0.0149
and evaluation pipeline, we release the complete source code, deterministic split definitions, pre-extracted microcode graphs, trained checkpoints, and table-generation scripts, allowing all experiments in Tables II–VII to be reproduced without IDA Pro. In addition, we provide an open-source Ghidra P-Code extraction front end (extract/ghidra_pcode.py) that produces the exact same graph schema; on our zlib crossoptimization validation benchmark (734 functions across -O0 through -O3), GCN trained on open front-end graphs reaches 0.9272 ± 0.0133 ROC-AUC and 0.7008 ± 0.0825 MRR. Remaining limitations include cross-architecture matching (e.g., x86-64 to ARM/MIPS) where architecture-specific calling conventions and intrinsic lowering still introduce variance, and heavy virtualization obfuscators that synthesize interpreter loops. VII. C ONCLUSION AND F UTURE W ORK This work presented MicroSim, a pipeline for binary code similarity detection based on decompiler microcode graphs and Siamese GNNs. On the TREX cross-optimization benchmark (849,072 function-level graphs spanning optimization levels -O0 through -O3), evaluated under a strict classdisjoint split, MicroSim with a GraphGPS encoder reaches 0.9973 ROC-AUC and 0.9756 MCC in under ten minutes on a single laptop GPU, outperforming Gemini, SAFE, jTrans, and a structure-free BoW baseline. A multi-seed, computematched ablation demonstrates that the supervised-contrastive InfoNCE objective is preferable for ranked retrieval and thresholded classification (F1, MCC, MRR, and R@K), while the pairwise cosine-embedding loss maintains a slightly higher raw ROC-AUC. Component and sensitivity ablations further confirm that CFG edges, DFG def–use edges, and 64-d hashed block features each contribute significantly to performance. Several directions for future work stand out. Because singleGPU compute is not the primary bottleneck, further gains in large-pool retrieval will likely come from memory-queue hardnegative mining and cross-optimization view augmentations tailored to microcode. Extending the open Ghidra P-Code front end to full-scale multi-architecture corpora (x86-64, ARM64, and MIPS) will further broaden applicability in firmware and cross-platform vulnerability search. R EFERENCES [1] I. U. Haq and J. Caballero, “A survey of binary code similarity,” ACM Comput. Surv., vol. 54, no. 3, pp. 51:1–51:38, Apr. 2021. [2] M. Moussaoui, T. Houichime, and A. Sadiq, “Bin2Vec: Interpretable and auditable multi-view binary analysis for code plagiarism detection,” in Proc. Int. Conf. Adv. Commun. Technol. Netw. (CommNet), Rabat, Morocco, Dec. 2025, pp. 1–8.
[3] X. Xu, C. Liu, Q. Feng, H. Yin, L. Song, and D. Song, “Neural networkbased graph embedding for cross-platform binary code similarity detection,” in Proc. ACM SIGSAC Conf. Comput. Commun. Secur. (CCS), Dallas, TX, USA, Oct. 2017, pp. 363–376. [4] L. Massarelli, G. A. Di Luna, F. Petroni, R. Baldoni, and L. Querzoni, “SAFE: Self-attentive function embeddings for binary similarity,” in Proc. Int. Conf. Detection Intrusions Malware Vulnerability Assessment (DIMVA), Gothenburg, Sweden, Jun. 2019, pp. 309–329. [5] H. Wang, W. Qu, G. Katz, W. Zhu, Z. Gao, H. Qiu, J. Zhuge, and C. Zhang, “jTrans: Jump-aware transformer for binary code similarity detection,” in Proc. ACM SIGSOFT Int. Symp. Softw. Testing Anal. (ISSTA), Virtual Event, Republic of Korea, Jul. 2022, pp. 1–13. [6] S. H. H. Ding, B. C. M. Fung, and P. Charland, “Asm2Vec: Boosting static representation robustness for binary clone search against code obfuscation and compiler optimization,” in Proc. IEEE Symp. Secur. Privacy (SP), San Francisco, CA, USA, May 2019, pp. 472–489. [7] X. Li, Y. Qu, and H. Yin, “PalmTree: Learning an assembly language model for instruction embedding,” in Proc. ACM SIGSAC Conf. Comput. Commun. Secur. (CCS), Virtual Event, Republic of Korea, Nov. 2021, pp. 3236–3251. [8] K. Pei, Z. Xuan, J. Yang, S. Jana, and B. Ray, “Trex: Learning execution semantics from micro-traces for binary similarity,” in Proc. IEEE Symp. Secur. Privacy (SP), San Francisco, CA, USA, May 2021, pp. 1476– 1492. [9] Q. Feng, R. Zhou, C. Xu, Y. Cheng, B. Testa, and H. Yin, “Scalable graph-based bug search for firmware images,” in Proc. ACM SIGSAC Conf. Comput. Commun. Secur. (CCS), Vienna, Austria, Oct. 2016, pp. 480–491. [10] Y. Li, C. Gu, T. Dullien, O. Vinyals, and P. Kohli, “Graph matching networks for learning the similarity of graph structured objects,” in Proc. Int. Conf. Mach. Learn. (ICML), Long Beach, CA, USA, Jun. 2019, pp. 3835–3845. [11] Y. Duan, X. Li, J. Wang, and H. Yin, “DeepBinDiff: Learning programwide code representations for binary diffing,” in Proc. Netw. Distrib. Syst. Secur. Symp. (NDSS), San Diego, CA, USA, Feb. 2020, pp. 1–18. [12] B. Liu, W. Huo, C. Zhang, W. Li, F. Li, A. Piao, and W. Zou, “αDiff: Cross-version binary code similarity detection with DNN,” in Proc. IEEE/ACM Int. Conf. Automated Softw. Eng. (ASE), Montpellier, France, Sep. 2018, pp. 667–678. [13] Z. Yu, R. Cao, Q. Tang, S. Nie, J. Huang, and S. Wu, “Order matters: Semantic-aware neural networks for binary code similarity detection,” in Proc. AAAI Conf. Artif. Intell. (AAAI), New York, NY, USA, Feb. 2020, pp. 1145–1152. [14] A. Marcelli, M. Graziano, X. Ugarte-Pedrero, Y. Fratantonio, M. Mansouri, and D. Balzarotti, “How machine learning is solving the binary function similarity problem,” in Proc. USENIX Secur. Symp., Boston, MA, USA, Aug. 2022, pp. 2099–2116. [15] T. N. Kipf and M. Welling, “Semi-supervised classification with graph convolutional networks,” in Proc. Int. Conf. Learn. Represent. (ICLR), Toulon, France, Apr. 2017, pp. 1–14. [16] W. L. Hamilton, R. Ying, and J. Leskovec, “Inductive representation learning on large graphs,” in Proc. Adv. Neural Inf. Process. Syst. (NeurIPS), Long Beach, CA, USA, Dec. 2017, pp. 1024–1034. [17] P. Veličković, G. Cucurull, A. Casanova, A. Romero, P. Liò, and Y. Bengio, “Graph attention networks,” in Proc. Int. Conf. Learn. Represent. (ICLR), Vancouver, BC, Canada, Apr. 2018, pp. 1–12. [18] K. Xu, W. Hu, J. Leskovec, and S. Jegelka, “How powerful are graph neural networks?” in Proc. Int. Conf. Learn. Represent. (ICLR), New Orleans, LA, USA, May 2019, pp. 1–17. [19] J. Gilmer, S. S. Schoenholz, P. F. Riley, O. Vinyals, and G. E. Dahl, “Neural message passing for quantum chemistry,” in Proc. Int. Conf. Mach. Learn. (ICML), Sydney, NSW, Australia, Aug. 2017, pp. 1263– 1272. [20] C. Ying, T. Cai, S. Luo, S. Zheng, G. Ke, D. He, Y. Shen, and T.-Y. Liu, “Do transformers really perform bad for graph representation?” in Proc. Adv. Neural Inf. Process. Syst. (NeurIPS), Virtual Event, Dec. 2021, pp. 28 877–28 888. [21] L. Rampášek, M. Galkin, V. P. Dwivedi, A. T. Luu, G. Wolf, and D. Beaini, “Recipe for a general, powerful, scalable graph transformer,” in Proc. Adv. Neural Inf. Process. Syst. (NeurIPS), New Orleans, LA, USA, Nov. 2022, pp. 14 501–14 515. [22] V. P. Dwivedi, A. T. Luu, T. Laurent, Y. Bengio, and X. Bresson, “Graph neural networks with learnable structural and positional representations,”
in Proc. Int. Conf. Learn. Represent. (ICLR), Virtual Event, Apr. 2022, pp. 1–25. [23] A. van den Oord, Y. Li, and O. Vinyals, “Representation learning with contrastive predictive coding,” arXiv:1807.03748, 2018. [Online]. Available: https://arxiv.org/abs/1807.03748 [24] T. Chen, S. Kornblith, M. Norouzi, and G. Hinton, “A simple framework for contrastive learning of visual representations,” in Proc. Int. Conf. Mach. Learn. (ICML), Virtual Event, Jul. 2020, pp. 1597–1607. [25] P. Khosla, P. Teterwak, C. Wang, A. Sarna, Y. Tian, P. Isola, A. Maschinot, C. Liu, and D. Krishnan, “Supervised contrastive learning,” in Proc. Adv. Neural Inf. Process. Syst. (NeurIPS), Virtual Event, Dec. 2020, pp. 18 661–18 673. [26] Y. You, T. Chen, Y. Sui, T. Chen, Z. Wang, and Y. Shen, “Graph contrastive learning with augmentations,” in Proc. Adv. Neural Inf. Process. Syst. (NeurIPS), Virtual Event, Dec. 2020, pp. 5812–5823. [27] D. P. Kingma and J. Ba, “Adam: A method for stochastic optimization,” in Proc. Int. Conf. Learn. Represent. (ICLR), San Diego, CA, USA, May 2015, pp. 1–15. [28] E. R. DeLong, D. M. DeLong, and D. L. Clarke-Pearson, “Comparing the areas under two or more correlated receiver operating characteristic curves: A nonparametric approach,” Biometrics, vol. 44, no. 3, pp. 837– 845, Sep. 1988. [29] S. Holm, “A simple sequentially rejective multiple test procedure,” Scand. J. Statist., vol. 6, no. 2, pp. 65–70, 1979. [30] P. Junod, J. Rinaldini, J. Wehrli, and J. Michielin, “Obfuscator-LLVM – software protection for the masses,” in Proc. IEEE/ACM Int. Workshop Softw. Protection (SPRO), Florence, Italy, May 2015, pp. 3–9.
Related documents
- Similarity searching in chemical structure databases#279054
- Continuous Accessibility Validation for Healthcare Web Applications Using AI-Driven CI/CD Integration#204151
- Word Similarity Datasets for Indian Languages: Annotation and Baseline Systems#1119211
- A Systematic Survey on Large Language Models for Evolutionary Optimization: From Modeling to Solving#635639
- A Systematic Survey on Large Language Models for Evolutionary Optimization: From Modeling to Solving#633290
Retrieved via Conceptio: every document is proof-bundled with source, license, and retrieval metadata.
Read the Docs → · View CLI source on GitHub · Conceptio Open Knowledge Archive