At a glance
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.
- Pretrained models
- 3
- Selected discriminative units
- MCDU
- Language-model backbone
- Frozen
Research question
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.
Method
- Probe candidate layers and test sensitivity to malicious-logic removal and stability under behaviour-preserving changes.
- Combine activation contrast, malicious-logic specificity, and probe weights to rank units and select a knee point.
- Concatenate selected activations into a compact representation for a lightweight detector.
Enlarge ↗
The pipeline combines malicious-logic sensitivity, surface stability, and separability to select layers and units.
Paper, p. 3Evidence
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.
Enlarge ↗
Layer-wise measurements compare the three localization criteria across several language models.
Paper, p. 4
Enlarge ↗
The table compares malicious-intent detection across backbones, with AUROC and accuracy reported by intent.
Paper, p. 6Takeaways
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.
A security representation should react to a change in malicious logic and remain stable to a change in surface form.
Paper and resources
ContractLens: Latent Security Knowledge for Malicious Smart Contract Detection
Paper contact · shuyimiao@buaa.edu.cn