TLDR: This research introduces a three-stage pipeline to improve smart contract vulnerability detection by reducing false alarms. It combines Slither-based static analysis, Large Language Models for generating specific exploit tests, and formal/empirical verification using Kontrol (symbolic execution) or Forge (concrete execution). This method effectively validates true positives for critical defects like Reentrancy, Complex Fallback, and Faulty Access Control, offering a more reliable and automated auditing framework.
Smart contracts, the self-executing agreements on blockchain platforms like Ethereum, have revolutionized decentralized applications. However, their immutable nature means that any coding defect, once deployed, can lead to catastrophic financial losses, as seen in events like the “DAO Hack” and the “Parity Wallet Hack.” Detecting these vulnerabilities is crucial, but current tools and even advanced Large Language Models (LLMs) often struggle, producing many false alarms or missing critical flaws entirely.
Traditional static analysis tools, such as Slither, are fast and effective for many issues but can be misled by specific scenarios. For instance, a common false alarm is flagging a withdraw() function as “reentrant” even when it uses the transfer() primitive, which limits gas to 2300 units, making a reentrancy attack impossible. Similarly, while LLMs like Google Gemini 2.5 Flash show promise, they too can be tricked by these nuances and suffer from consistency issues. This highlights a critical need for more reliable and automated smart contract auditing.
A Novel Approach to Smart Contract Security
A new research paper introduces a sophisticated, three-stage pipeline designed to overcome these limitations by integrating custom static analysis, the power of Large Language Models, and the precision of symbolic and concrete execution tools like Kontrol and Forge. This combined approach aims to reliably detect defects and generate verifiable proofs, significantly reducing the burden of manual verification.
The pipeline works as follows:
Stage 1: Smart Contract Preprocessing
The process begins with a custom static analysis tool built on Slither modules. This tool scans the smart contract for specific coding patterns that are prerequisites for certain types of bugs. For example, a reentrancy analysis is only triggered if the contract handles Ether or tokens, as these vulnerabilities typically involve currency transfers. By extracting rich, structured data about the contract’s structure and logic, this stage efficiently filters out scenarios where a particular issue is definitely not present. If no relevant patterns are found, the analysis for that specific defect type concludes, saving time and resources.
Stage 2: Intelligent Test Generation with LLMs
Once relevant information is gathered, it’s passed to a Large Language Model, such as Google Gemini 2.5 Pro. The LLM’s task is to generate concrete proof-of-exploit tests by populating bespoke “testing patterns” or templates tailored to each defect class. These templates include code comments that guide the LLM, leveraging its instruction-following capabilities to create contract-specific test code. While some test generation tasks are straightforward, others require more complex reasoning, such as inferring recommended access policies for a function. The LLM’s ability to create these executable tests is a core innovation of this pipeline.
Stage 3: Verifying Defects with Symbolic and Concrete Execution
The final stage involves executing the LLM-generated tests using either Forge or Kontrol, depending on the nature of the vulnerability.
-
Forge is used for concrete execution, which is fast and ideal for empirical proofs, such as identifying “Gas Costly Patterns” where inefficient code leads to high transaction fees. It can perform fuzz testing to discover edge-case vulnerabilities.
-
Kontrol is a formal verification tool that uses symbolic execution to analyze all possible execution paths simultaneously, providing mathematical certainty. It’s particularly effective for formal proofs, like verifying the absence of reentrancy or the correctness of access control.
A successfully executed test, whether it passes or fails as expected, serves as a formal or empirical proof of the defect’s presence or absence within the scope of the tested scenarios.
Addressing Specific Vulnerabilities
The paper demonstrates the pipeline’s effectiveness across seven critical defect types, highlighting three challenging vulnerabilities:
-
Reentrancy (False Positive): The pipeline can correctly identify that a
withdraw()function usingtransfer()is not vulnerable to reentrancy, even though many tools and LLMs might flag it. It does this by running two tests: one to confirm normal operation and another to simulate an attack, expecting it to revert due to the gas limit. -
Complex Fallback (Gas Costly Pattern): This occurs when a contract’s
receive()function performs an expensive operation, causing transactions with limited gas (like those fromtransfer()) to fail. The pipeline uses Forge to prove this by comparing a successfulcall()(which forwards all gas) with a failingtransfer()(which has a 2300 gas limit). -
Faulty Access Control Policies: When critical functions (e.g.,
selfdestruct) lack proper security, allowing unauthorized access. Kontrol is used to symbolically test if an arbitrary, non-owner address can call such a function. If the call doesn’t revert, the defect is confirmed.
Also Read:
- Securing the AI Frontier: A Deep Dive into Threats and Defenses for LLM Systems
- Large Language Models Transform Security Operations Centers: A Survey of Capabilities and Future Directions
Challenges and the Road Ahead
While promising, the approach faces challenges. The consistency and cost of LLMs remain significant factors. Obtaining consistently structured output from LLMs can be difficult, although templates and contextual information help. Additionally, most state-of-the-art LLMs are proprietary and accessed via APIs, leading to cost concerns, while powerful open-source models require substantial computational resources. Integrating Forge and Kontrol robustly also presents a challenge, ideally requiring an “API mode” for seamless interaction.
Despite these hurdles, the researchers are optimistic about developing a practical implementation. Their prior experience with Slither-based detectors and programmatic LLM interaction will accelerate development. This novel pipeline represents a significant step towards more reliable and automated smart contract auditing, combining the strengths of various analysis techniques to build a robust framework for securing decentralized applications. You can read the full research paper here: Validating Solidity Code Defects using Symbolic and Concrete Execution powered by Large Language Models.


