CKG-LLM: LLM-Assisted Detection of Smart Contract Access Control Vulnerabilities Based on Knowledge Graphs
Xiaoqi Li, Hailu Kuang, Wenkai Li, Zongwei Li, Shipeng Ye
TL;DR
The paper tackles the detection of access-control vulnerabilities in smart contracts by overcoming AST-era limitations through a contract knowledge graph built from Slither IR. It leverages large language models to translate natural-language vulnerability patterns into executable graph queries (NL2GQL) and introduces RLAF to iteratively refine query generation. Key contributions include the first LLM-driven NL2GQL pipeline over a contract KG, a Slither-based KG construction with a two-layer ontology, and a domain-adaptive RL framework that improves detection accuracy (F1 = 74.9%) and efficiency. Results on the FORGE dataset show that CKG-LLM outperforms existing tools in both effectiveness and speed, suggesting a promising direction for scalable, semantically rich contract security analysis.
Abstract
Traditional approaches for smart contract analysis often rely on intermediate representations such as abstract syntax trees, control-flow graphs, or static single assignment form. However, these methods face limitations in capturing both semantic structures and control logic. Knowledge graphs, by contrast, offer a structured representation of entities and relations, enabling richer intermediate abstractions of contract code and supporting the use of graph query languages to identify rule-violating elements. This paper presents CKG-LLM, a framework for detecting access-control vulnerabilities in smart contracts. Leveraging the reasoning and code generation capabilities of large language models, CKG-LLM translates natural-language vulnerability patterns into executable queries over contract knowledge graphs to automatically locate vulnerable code elements. Experimental evaluation demonstrates that CKG-LLM achieves superior performance in detecting access-control vulnerabilities compared to existing tools. Finally, we discuss potential extensions of CKG-LLM as part of future research directions.
