AI & ML
ContractLens: Latent Security Knowledge for Malicious Smart Contract Detection
arXiv cs.CR0 views
arXiv:2610.04992v2 Announce Type: replace Abstract: Detecting malicious smart contracts is essential to safeguarding the Web3.0 ecosystem. However, existing auditing methods based on large language models (LLMs) largely rely on prompt engineering or attack-specific fine-tuning, while the internal representations that support malicious logic detection remain poorly characterized. To address this gap, we propose ContractLens, a framework that localizes and uses latent security knowledge in pretrained LLMs for interpretable malicious smart contract detection. Specifically, we first use layerwise linear probes to identify candidate layers that distinguish malicious from benign contracts, then select critical layers based on their sensitivity to malicious logic removal and stability under behaviour-preserving surface modifications. Next, within these critical layers, we combine activation contrast, malicious-logic specificity, and probe weights into a tri-factor importance score and adaptively select malicious contract-discriminative units (MCDUs) using the knee point of the ranked score curve. Finally, we concatenate the selected units' activations into a compact representation and train a lightweight classifier for detection, keeping the pretrained model frozen throughout. Neuron masking experiments show that masking MCDUs causes larger drops in detection performance than masking randomly selected neurons or neurons matched in activation magnitude. ContractLens achieves higher average detection accuracy than the evaluated methods on all three pretrained models. Further evaluations demonstrate generalization to unseen malicious intents and show that, with the identified MCDUs fixed, a classifier trained on few labelled samples can still achieve strong detection performance.
Source:https://arxiv.org/abs/2610.04992PreviousSEABench: Benchmarking Endogenous Misalignment In Self-Evolving AgentsNextImplicit Regularization via Spectral Neural Networks and Non-linear Matrix Sensing
Related posts
Are LLM Safety Judges Policy-Invariant? A Three-Principle Stress-Test
0arXiv cs.SE
Vibe Coding in Software Development: A Multivocal Literature Review
0arXiv cs.SE
Large Language Models for Multi-Lingual Equivalent Mutant Detection: An Extended Empirical Study
0arXiv cs.SE
Characterizing Robustness in Semantic Code Clone Detection
0arXiv cs.SE
AI Slop and the Software Commons
0arXiv cs.SE
Detecting Silent Faults at the Environment-Trainer Boundary in Reinforcement Learning
0arXiv cs.SE