Skip to content
Crypto.world

Research

Function Name Is All You Need to Detect Blockchain Application Attacks

Blockchain application attacks exploit business-logic bugs in decentralized applications and have caused billions of dollars in losses, but existing detectors either depend on handcrafted attack…

Function Name Is All You Need to Detect Blockchain Application Attacks
arXiv
2609.12315
Published
2026-09-11
Authors
Rui Xi, Zehua Wang, Karthik Pattabiraman

AI summary

Overview

Research area: Blockchain security — detection of application-level attacks (business-logic exploits) on decentralized applications (dApps) running on EVM-compatible blockchains.

Technical level: Intermediate. The paper assumes familiarity with Ethereum transactions, smart contracts, function selectors, and call traces, but its core idea is explained through a worked example (the C.R.E.A.M. Finance incident) and is accessible to readers with basic blockchain background.

Scope: The paper argues and empirically demonstrates that sequences of function names extracted from transaction call traces are sufficient to detect blockchain application attacks without smart contract source code or handcrafted detection rules, and presents a Transformer-based detector called TxLucent.

What This Paper Is About

Blockchain application attacks exploit business-logic bugs in decentralized applications and have caused billions of dollars in losses, but existing detectors either depend on handcrafted attack patterns or require smart contract source code that is often unavailable. The authors show that function names recovered from call traces cover far more transactions than source code does, and that the order in which those functions are invoked captures the high-level business semantics needed to distinguish attacks from normal use. Their goal is an accurate, real-time detector that needs neither manual rules nor source code.

Key Contributions

  1. An empirical observation about feature availability: The authors measure, over 5,632,984 call traces, that 98.46% can be resolved to function names via a selector-to-name database, while only 74.78% invoke a contract whose source code is available — a 23.68-percentage-point gap.

  2. TxLucent, a two-stage detector: A Sequence builder reconstructs the call trace tree from raw traces and maps 4-byte selectors to function names (unmapped selectors become [UNK_SELECTOR]); a Classifier encodes the resulting function name sequence and uses a Transformer encoder with a linear head to label transactions attack or benign.

  3. A realistic evaluation workflow: The authors build an incident-level benchmark from DeFiHackLab (424 in-scope incidents, 14,611 attack transactions) plus a benign set of 537,069,442 Ethereum transactions, and use category-stratified, incident-level five-fold cross-validation so that no incident leaks between training and evaluation folds.

  4. Detection without rules or source code: The paper positions TxLucent as the first technique to extract transaction semantics from function name sequences for blockchain application attack detection, arguing its contribution lies in the representation rather than the choice of classifier.

Main Findings

  • Function names are more available than source code: Across 5,632,984 call traces from 149,276 transactions, the selector-to-name database resolved 5,546,485 traces (98.46%), versus 4,212,186 (74.78%) with source code available in the Sourcify dataset. Function names were available for 1,352,905 of the 1,420,798 traces (95.22%) whose source code was not available.

  • Attackers mostly cannot rename the functions that matter: Of 3,451,926 call traces in the attack dataset, only 44,716 (1.30%) invoke attacker-controlled functions; the remaining 3,407,210 (98.70%) invoke victim contracts, whose function names are immutable once deployed.

  • Low false negatives: Across the five cross-validation checkpoints, TxLucent achieves a false negative rate of 1.56% on the DeFiHackLab incidents. On the same incidents, CLUE obtains an FNR of 70.77% and Hunting obtains 83.17%.

  • Very low false positives: TxLucent has an estimated false positive rate of 0.0017% on the Ethereum benign dataset (537,069,442 transactions from 2024-01-01 through 2025-12-31).

  • Fast enough for real time: Average analysis time is 24.90 milliseconds per transaction, which the authors state supports real-time detection on popular blockchains.

  • Results align with human incident reports: TxLucent's detection outputs agree with the official incident reports with a median alignment score of 74.86% (RQ3, explainability).

  • Limited evasion headroom: When attackers proactively try to evade TxLucent, its false negative rate increases only marginally, from 1.56% to 2.26% (RQ6).

  • Simple length is a weak baseline: A call-trace-length heuristic, with the threshold set to 22 chosen to give the best FNR under a 1% FPR budget on these datasets, is included as a comparison point, underscoring that sequence semantics rather than trace size carry the signal.

Methodology in Plain English

The approach rests on one structural fact about Ethereum: every call into a smart contract carries a 4-byte function selector, which is the beginning of a hash of the function's signature. A transaction's call traces therefore record which functions were called, in what order, and nested under what. The selectors are not readable names, but names can be recovered by looking them up.

The authors build a one-time lookup table from the Sourcify smart contract dataset: extract function signatures, compute their selectors, and for each selector pick the most likely signature — ranked by how frequently that signature occurs in Sourcify, with canonical ordering as a tie-breaker. Parameter lists are stripped so only the function name remains. Selectors not in the table are replaced by a special unknown token.

For each transaction, TxLucent rebuilds the call trace tree by linking traces to their parents, sorts the calls into a deterministic pre-order sequence, and replaces each selector with its name. The resulting sequence of function names is tokenized with a frozen 8,192-token ByteLevel-BPE tokenizer, with each name terminated by a separator token.

A Transformer encoder — four layers, eight heads, hidden width 256, SwiGLU feed-forward width 768, dropout 0.05 — processes the sequence, and a linear head on the [CLS] representation makes a two-class prediction. Training uses cross-entropy loss with a balanced weighted sampler. The intuition is that normal operations follow expected business lifecycles (borrow, then repay, then reclaim collateral) while attacks produce anomalous orderings — for example, a second borrow occurring without an intervening repay, as in the C.R.E.A.M. Finance reentrancy case the paper uses as its running example.

The evaluation is deliberately conservative: incidents, not transactions, are split across folds, so the model is never evaluated on an incident whose transactions it was trained on. Five checkpoints are trained, each on four folds and evaluated on the fifth, and metrics are averaged across the checkpoints.

Why This Matters

Impact on research. The paper reframes a feature-engineering problem as a representation problem: instead of building execution property graphs or hand-coding attack signatures, it shows that the naming conventions developers already follow (ERC20's transfer, Uniswap's swapExactTokensForTokens, lending platforms' supply/borrow/repay/liquidate) leak enough semantics to classify transactions. This suggests a general direction for blockchain security — using interface standards as a semantic layer over low-level on-chain data — and it removes the practical obstacle that source code is unavailable for a substantial fraction of calls.

Real-world applications:

  • Live transaction monitoring by dApps and protocols: Because detection takes 24.90 ms per transaction, a deployment could flag a malicious transaction before it is mined or before follow-on damage occurs.
  • Blockchain explorers and node providers: Call traces are already retrieved from infrastructure like QuickNode; adding a function-name sequence classifier turns that existing data into a security signal with no source code dependency.
  • Incident response and post-mortems: The 74.86% median alignment with official incident reports means outputs can be reconciled with published analyses, helping investigators localize the anomalous step in an attack transaction.
  • DeFi risk dashboards and audit triage: Detectors that work on unverified contracts extend coverage to newly deployed, unaudited, or attacker-deployed contracts where source code is missing.

Industry relevance. The paper targets a category that it says constituted 42% of all incidents on popular blockchains since 2022, with losses in the billions of dollars. Since TxLucent needs only a 4-byte-selector lookup table built once from public data plus call traces, it fits the data-access reality of exchanges, custodians, wallets, and monitoring vendors — all of whom have trace access but generally cannot require source code from every contract on chain.

Future Directions

  1. Extend beyond EVM compatibility: The whole pipeline depends on EVM call traces and 4-byte selectors. Porting the idea to non-EVM chains requires a different mapping from invocation identifiers to semantic names, and it is not established that naming conventions there are as consistent.

  2. Broaden attack coverage and scope: The authors explicitly exclude bridge attacks, governance attacks, misconfiguration, overflow, precision loss, private-key compromise, signature verification, social engineering, storage collision, and weak randomness. Whether function name sequences carry signal for those excluded categories is an open question.

  3. Harden selector collisions and unknown selectors: Selector collisions are resolved heuristically by frequency ranking over Sourcify, and unmapped selectors collapse into a single [UNK_SELECTOR] token. The paper reports high coverage but does not establish how much residual discrimination is lost when many distinct functions share that one symbol.

  4. Adversarial and multi-transaction settings: The evasion study reports only a small degradation (FNR 1.56% to 2.26%), but attackers who deliberately structure operations across many transactions, use generic proxy patterns, or rename their own functions differently than in the studied attacks remain a natural stress test.

Target Audience

Security researchers working on blockchain and smart contract attack detection; practitioners building transaction-monitoring or risk systems at exchanges, node providers, and wallet vendors; dApp developers and auditors interested in lightweight runtime defenses; and machine-learning researchers interested in how far simple symbolic representations (names plus ordering) can go in a domain where heavier feature reconstruction is the norm. Readers without blockchain background will need the paper's background sections, particularly the explanation of selectors, ABIs, ERCs, and call traces.

Authors’ abstract

Blockchain application attacks, targeting business logic bugs in decentralized applications (dApps), have been an increasing concern to their developers and users, causing significant financial loss. Existing attack detectors either rely on handcrafted rules for detection, or need difficult-to-obtain smart contract source code to analyze attack transactions. This makes them brittle and inapplicable in practice. In this paper, we argue that function name sequences suffice to…

The full abstract on arXiv
Read the original paper