NExT-LFM · Research overview
More research
Applied Research / Research overview

ContractLens: Latent Security Knowledge for Malicious Smart Contract Detection

Probe MLP neurons in a frozen language model to isolate malicious-logic signals and detect malicious smart contracts with a compact representation.

Miao Shuyi

Preprint 3-minute read Read the paper PDF
Concept illustration: ContractLens: Latent Security Knowledge for Malicious Smart Contract Detection
Concept illustration inspired by the study.

The short version

ContractLens uses this pair of requirements to locate malicious-contract detection units inside a frozen language model. It compares the effects of removing malicious logic with behavior-preserving edits such as formatting and comment changes. Critical layers and neurons are selected for their ability to separate malicious behavior, respond to its removal, and resist irrelevant variation.

The selected units feed a lightweight detector. The framework makes feature selection a question about security semantics, connecting internal measurements to an application where shortcuts based on appearance can be particularly costly.

3Pretrained models
MCDUSelected discriminative units
FrozenLanguage-model backbone

A security representation should react to a change in malicious logic and remain stable to a change in surface form.

Figure 2 · A semantic test for detection units. The pipeline combines malicious-logic sensitivity, surface stability, and separability to select layers and units.
Figure 2 / p. 3

A semantic test for detection units

The pipeline combines malicious-logic sensitivity, surface stability, and separability to select layers and units.

View in the paper

Why this matters

Prompt-based auditing exposes model responses but does not directly characterize the representations supporting malicious-logic detection. ContractLens asks which internal signals track the logic rather than incidental surface form.

How it works

  1. Probe candidate layers and test sensitivity to malicious-logic removal and stability under behaviour-preserving changes.
  2. Combine activation contrast, malicious-logic specificity, and probe weights to rank units and select a knee point.
  3. Concatenate selected activations into a compact representation for a lightweight detector.
Figure 3 · Which layers satisfy the criteria?. Layer-wise measurements compare the three localization criteria across several language models.
Figure 3 / p. 4

Which layers satisfy the criteria?

Layer-wise measurements compare the three localization criteria across several language models.

View in the paper

What the study finds

Masking MCDUs produces larger detection drops than random or activation-matched controls. Evaluation across three pretrained models reports higher average accuracy than the compared methods, including tests of unseen malicious intents and few-label classifiers.

Table 1 · Detection across models and intents. The table compares malicious-intent detection across backbones, with AUROC and accuracy reported by intent.
Table 1 / p. 6

Detection across models and intents

The table compares malicious-intent detection across backbones, with AUROC and accuracy reported by intent.

View in the paper

What this means

The insight extends to how security evidence should be built: predictive accuracy becomes more persuasive when a feature changes for the reason the task requires. Controlled logic edits and surface edits turn that expectation into measurable criteria.

This offers a route to detectors whose representations can be audited for task relevance, including in low-label and unseen-intent settings. Real deployment still requires examining the coverage of malicious behaviors and the fidelity of the edits used to test semantic sensitivity.

Paper and resources

Contact the authorMiao Shuyi
shuyimiao@buaa.edu.cn

This is an introduction to the linked paper. Refer to the original for method definitions, evaluation settings, and complete results.

Cite this work
@misc{contractlens,
  title = {ContractLens: Latent Security Knowledge for Malicious Smart Contract Detection},
  author = {Miao, Shuyi and Huang, Xinyi and Qiu, Wangjie and Shen, Fei and He, Jinchun and Zheng, Zhiming and Chua, Tat-Seng},
  year = {2026},
  eprint = {2610.04992},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2610.04992}
}