Towards Secure Program Partitioning for Smart Contracts with LLM's In-Context Learning
Ye Liu, Yuqing Niu, Chengyan Ma, Ruidong Han, Wei Ma, Yi Li, Debin Gao, David Lo
TL;DR
PartitionGPT introduces an automated, LLM-driven framework for secure program partitioning of smart contracts to prevent sensitive data leakage. By combining taint analysis, program slicing, and in-context learning with a formal equivalence checker, it generates compilable and verifiably partitioned contracts that run privileged code in secure environments. Empirical evaluation across 18 annotated contracts and nine victim contracts demonstrates a 78% success rate in partition generation, roughly 30% code reduction, and defense against eight manipulation attacks, with moderate gas overhead due to inter-enclave communication. The work advances practical privacy-preserving smart contract development, enabling least-privilege execution while maintaining functional equivalence, and sets the stage for automated sensitive-data identification and refined partition ranking in future work.
Abstract
Smart contracts are highly susceptible to manipulation attacks due to the leakage of sensitive information. Addressing manipulation vulnerabilities is particularly challenging because they stem from inherent data confidentiality issues rather than straightforward implementation bugs. To tackle this by preventing sensitive information leakage, we present PartitionGPT, the first LLM-driven approach that combines static analysis with the in-context learning capabilities of large language models (LLMs) to partition smart contracts into privileged and normal codebases, guided by a few annotated sensitive data variables. We evaluated PartitionGPT on 18 annotated smart contracts containing 99 sensitive functions. The results demonstrate that PartitionGPT successfully generates compilable, and verified partitions for 78% of the sensitive functions while reducing approximately 30% code compared to function-level partitioning approach. Furthermore, we evaluated PartitionGPT on nine real-world manipulation attacks that lead to a total loss of 25 million dollars, PartitionGPT effectively prevents eight cases, highlighting its potential for broad applicability and the necessity for secure program partitioning during smart contract development to diminish manipulation vulnerabilities.
