Pruning Attention Heads Based on Semantic and Code Structure for Smart Contract Vulnerability Detection
Along with the sustained occurrence of black swan events in the decentralized application ecosystem, smart contract security is a growing concern. Traditional solutions mainly rely on predefined rules, while highly accurate, require intensive manual code analysis. Machine learning methods (mainly based on BERT) leverage semantic and contextual information, but overlook crucial code structure features, which are critical for identifying vulnerability. Furthermore, the presence of useless or harmful attention heads in the BERT model leads to less robust predictions and slows down processing speeds. We propose a novel method named Pruning attention Heads based on Semantic and Code Structure (PHSCS) for Smart Contract Vulnerability Detection. Specifically, we introduce a new structure-aware pre-training programming language task, Variable Edge Prediction, which bypasses the use of data flow nodes as input and directly predicts data flow edges between variables, aiming to efficiently learn code structure while ensuring the ability to process extensive code. Additionally, we present a pruning strategy to optimize BERT, tailored to the semantic and structural peculiarities of code. By employing Taylor Expansion for evaluating attention heads' significance and guiding their pruning, iteratively refined the BERT model. Experiment results on 8 vulnerability types illustrate that the PHSCS method surpasses state-of-the-art methods.
Authors
- Teng Ouyang (ORCID: https://orcid.org/0009-0000-3306-5618)
- Shen Su (ORCID: https://orcid.org/0000-0003-2744-3584)
- Siyu Jiang (ORCID: https://orcid.org/0000-0002-1969-807X)
- Yuwen Chen (ORCID: https://orcid.org/0009-0003-7437-2886)
- Xue Zhang (ORCID: https://orcid.org/0009-0001-9537-6363)
Institutions
- Guangdong University of Foreign Studies (CN)
- Guangzhou University (CN)
Publication Details
- Journal
- IEEE Transactions on Dependable and Secure Computing
- Published
- 2025-09-09
- DOI
- https://doi.org/10.1109/tdsc.2025.3607471
- Primary Topic
- Cybercrime and Law Enforcement Studies
- Type
- article
- Field-Weighted Citation Impact
- 0.00