Abstract
With recent advances in large language models (LLMs), this paper explores the potential of leveraging state-of-the-art LLMs, such as GPT-4, to transfer existing human-written properties (e.g., those from Certora auditing reports) and automatically generate customized properties for unknown code. To this end, we embed existing properties into a vector database and retrieve a reference property for LLM-based in-context learning to generate a new property for a given code. While this basic process is relatively straightforward, ensuring that the generated properties are (i) compilable, (ii) appropriate, and (iii) runtime-verifiable presents challenges. To address (i), we use the compilation and static analysis feedback as an external oracle to guide LLMs in iteratively revising the generated properties. For (ii), we consider multiple dimensions of similarity to rank the properties and employ a weighted algorithm to identify the top-K properties as the final result. For (iii), we design a dedicated prover to formally verify the correctness of the generated properties. We have implemented these strategies into a novel system called PropertyGPT, with 623 human-written properties collected from 23 Certora projects. Our experiments show that PropertyGPT can generate comprehensive and high-quality properties, achieving an 80% recall compared to the ground truth. It successfully detected 26 CVEs/attack incidents out of 37 tested and also uncovered 12 zero-day vulnerabilities, resulting in $8,256 bug bounty rewards.
Introduction
Formal verification represents the "gold standard" for smart contract security, offering mathematical proof of a system's correctness. However, its widespread adoption is hindered by the significant bottleneck of specification engineering. To verify a contract, experts must manually define "properties"—logical rules such as invariants or pre/post-conditions. This process is labor-intensive, expensive, and requires deep domain expertise.
PropertyGPT addresses this challenge by leveraging Large Language Models (LLMs) to automate the generation of these properties. By "transferring" the wisdom contained in existing human-written audit reports to new, unseen code, PropertyGPT lowers the barrier to entry for formal verification and enhances the security posture of decentralized applications.
The PropertyGPT Framework
PropertyGPT operates through a sophisticated pipeline designed to move from raw source code to verified security properties. The system architecture is centered around a Retrieval-Augmented Generation (RAG) approach combined with an iterative refinement loop.
1. Retrieval-Augmented Generation (RAG)
Instead of relying solely on the pre-trained knowledge of an LLM, PropertyGPT utilizes a vector database containing hundreds of human-written properties from real-world Certora audits. When a user provides a "Subject Code under testing," the system embeds the code and queries the database to retrieve the most relevant code-property pairs. These serve as high-quality in-context examples, guiding the LLM to generate properties that are contextually relevant to the target contract.
2. Iterative Refinement
LLMs frequently produce code with syntax errors or hallucinations. To ensure the generated properties are compilable, PropertyGPT incorporates a "compiler-in-the-loop" mechanism. If a property fails to compile, the error logs are fed back to the LLM as feedback. This iterative process allows the model to self-correct, significantly increasing the success rate of generating valid property code.
3. Property Specification Language (PSL)
To bridge the gap between natural language and formal logic, the authors designed a Property Specification Language (PSL). PSL extends Solidity syntax, making it intuitive for LLMs (which are already proficient in Solidity) while remaining formal enough for automated provers to process.
Formal Verification and Proving
Generating a property is only half the battle; the property must then be verified against the actual contract implementation. PropertyGPT employs a dedicated prover that uses symbolic execution and model checking to determine if the generated properties hold true.
As shown in the verification workflow, the system performs source code-level symbolic execution. It attempts Modular Verification first; if that fails, it proceeds to Bounded Model Checking. This tiered approach allows the system to either confirm the property ("Pass") or identify specific "Counter-examples" that indicate a potential vulnerability or bug in the code.
Evaluation and Real-World Impact
The effectiveness of PropertyGPT was evaluated using a curated dataset of 623 human-written properties and a benchmark of 37 known vulnerabilities (CVEs and attack incidents).
- High Fidelity: The system achieved an 80% recall rate compared to human-written ground truth properties.
- Vulnerability Detection: PropertyGPT detected 9 out of 13 tested CVEs, outperforming traditional static analysis tools like Slither and Mythril.
- Zero-Day Discovery: In real-world testing on active bug bounty platforms like Secure3 and Code4Rena, PropertyGPT identified 12 zero-day vulnerabilities, earning over $8,000 in rewards.
Conclusion
PropertyGPT demonstrates that LLMs, when augmented with retrieval mechanisms and iterative feedback, can effectively automate the complex task of property generation for formal verification. While challenges remain—particularly regarding complex cross-contract interactions and "liveness" properties—the system marks a significant step toward making formal verification a scalable and accessible tool for the smart contract ecosystem.
Summary updated