Cointime

Download App
iOS & Android

How Effective Is GPT for Auditing Smart Contracts?

Introduction

Recently, ChatGPT has gained a great deal of popularity, impressing its users with its capacity to enhance traditional text, work efficiency, and provide concise overviews. Following closely behind is CodeGPT, a GPT-based plugin that further enhances coding efficiency. With the recent release of GPT-4, can it be applied to auditing blockchain and Solidity smart contracts? Based on this question, we conducted various feasibility tests.’

Testing Environment and Methodology

The comparison models used in this test are: GPT-3.5(Web),GPT-3.5-turbo-0301,GPT-4(Web).

Prompt used in the test: Help me discover vulnerabilities in this Solidity smart contract.

Comparison of Vulnerability Code Snippet Detectio

We performed three rounds of testing. In tests 1 and 2, we utilized historical vulnerability codes commonly encountered in the past as test cases to evaluate the model’s ability to detect fundamental vulnerabilities. In Test 3, we introduced moderately challenging vulnerability codes as the primary test cases.

Test 1:

Example: “Intro to Smart Contract Audit Series: Phishing With tx.orgin”

Vulnerability Code:

Sent to GPT:

GPT-3.5(Web) Response:

GPT-3.5-turbo-0301 Response:

GPT-4(Web) Response:

As you can see from the results, all three models identified critical issues related to tx.origin.

Test 2:

Example: “Intro to Smart Contract Security Audits | Overflow”

Sent to GPT:

GPT-3.5(Web) Response:

GPT-3.5-turbo-0301 Response:

GPT-4(Web) Response:

It is worth noting that both GPT-3.5 (Web) and gpt-3.5-turbo-0301 were able to identify a critical overflow vulnerability, whereas surprisingly, GPT-4 (Web) did not provide any relevant prompt.

Test 3:

Example: “Empty-handed with a White Wolf — Analysis of the Popsicle Hack”

Sent to GPT:

GPT-3.5(Web) Response:

GPT-3.5-turbo-0301 Response:

Looking at the results,, we can see that none of the three versions detected any of the critical vulnerability points.

Summary of Code Snippet Detection

While the GPT models displayed adequate detection capabilities for simple vulnerability code snippets, it falls short when it comes to identifying more complex ones. Throughout the tests, GPT-4 (Web) showcased exceptional readability and a clear output format. However, its ability to audit code does not appear to surpass that of GPT-3.5 (Web) or GPT-3.5-turbo-0301. In some cases, due to the inherent uncertainties in the transformer output, GPT-4 (Web) managed to overlook certain critical issues.

Comparative Detection of Known Vulnerabilities in Full Contracts

To better accommodate the practical requirements of projects during contract audits, we raised the difficulty level by importing contracts with an extensive codebase. This allowed us to comprehensively test the GPT-4 model’s auditing capabilities, as opposed to GPT-3 which has a smaller contextual character limit and thus was not evaluated in this context.

For this instance, we used previous case studies as a test template to simulate real-world scenarios:

Example: “Detailed analysis of the $31 Million MonoX Protocol Hack”.

To initiate the audit, we inputted the complete contract in batches and submitted a vulnerability detection request towards the end of the dialogue.

The following prompt was utilized for this test:

“Here is a Solidity smart contract”

Insert Contract Code

“The above is the complete code,help me discover vulnerabilities in this smart contract.”

As demonstrated, despite GPT-4 having the highest single input character limit, according to the information published by OpenAI, it still encountered contextual challenges due to text overflow during the final vulnerability detection request. Consequently, the model can only identify a portion of the content, rendering it incapable of conducting a thorough contextual audit for large-scale contracts.

Batched Auditing: Unpacked Contracts through Incremental Input and Detection:

Prompt 1:

“Help me discover vulnerabilities in this Solidity smart contract.”

Batch 1 of the contract code.

Prompt 2:

“Help me discover vulnerabilities in this Solidity smart contract.”

Batch 2 of the contract code.

Prompt 3:

“Help me discover vulnerabilities in this Solidity smart contract.”

Batch 3 of the contract code.

It is worth mentioning that GPT-4 failed to identify any critical vulnerability points.

Summary: While the current state of GPT’s capabilities may not be entirely suitable for contract analysis, the potential of AI in this domain remains impressive.

Advantages:

While GPT’s detection capabilities for complex vulnerabilities in contract code may be limited, it has shown impressive partial detection capabilities for basic and simple vulnerabilities. Additionally, once a vulnerability is identified, the model provides an explanation in an easily understandable and user-readable format. This unique feature is especially beneficial for novice contract auditors who require quick guidance and straightforward answers during their initial training phase.

Challenges:

There is a certain amount of variation in GPT’s output for each dialogue, which can be adjusted through API interface parameters. However, the output is still not constant. Although such variability is beneficial for language dialogues and greatly enhances the authenticity of the conversation, it is not ideal for code analysis work. In order to cover multiple possible vulnerability answers that AI may provide, we had to make multiple requests for the same question and compare and filter the results. This inadvertently increases the workload, ultimately undermining the fundamental objective of AI in assisting humans to improve their efficiency.

For instance, we conducted an additional test by running Test 2 of the Comparison of Vulnerability Code Snippet Detection with a slight modification of the function name before generating again.

As we can see, its output results have added some additional content compared to the previous test.

There is still significant room for improvement in its vulnerability analysis capabilities.

It is worth noting that the current (as of March 16, 2024) training models of GPT are unable to accurately analyze and identify critical vulnerability points for slightly complex vulnerabilities.

Despite the current limitations of GPT’s analysis and mining capabilities for contract vulnerabilities, its ability to analyze and generate reports on simple code blocks for common vulnerabilities still sparks excitement among users. With continued training and development of GPT and other AI models, we firmly believe that assisted auditing of large and complex contracts will achieve faster, more intelligent, and more comprehensive outcomes in the foreseeable future. As technological development exponentially improves human efficiency, a transformative shift is imminent. We eagerly anticipate the benefits of AI in enhancing blockchain security and remain vigilant in monitoring the impact of emerging AI products on this vital field. In the visible future, we will inevitably integrate with AI to some extent. May AI and blockchain be with you.

Read more: https://slowmist.medium.com/how-effective-is-gpt-for-auditing-smart-contracts-cdeddfa76dbe

Comments

All Comments

Recommended for you

  • Hong Kong Stock Exchange Collaborates with S&P Dow Jones Indices to Launch Co-Branded Index

    The Hong Kong Stock Exchange has announced a collaboration with S&P Dow Jones Indices to develop and launch the S&P 500 Hong Kong Stock Exchange Technology 100 Index. This index aims to measure the performance of leading companies listed in the United States as well as the largest technology companies by market capitalization listed in Hong Kong. The index is approximately 60% allocated to the Hong Kong Stock Exchange Technology 100 Index and 40% to the S&P 500 Index, with weights adjusted quarterly.

  • LeCun et al. Propose H-JEPA Hierarchical World Model for End-to-End Learning in Visual Planning

    On October 12, according to an arXiv paper, researchers Wancong Zhang, Basile Terver, Michael Rabbat, Yann LeCun, and Randall Balestriero proposed H-JEPA, an end-to-end training scheme for a hierarchical action-conditioned JEPA world model, where each layer predicts further into the future within its learned latent space. Planning is conducted top-down: the top layer optimizes the goal, and each layer's predictions become sub-goals for the layer below. When factors in the data evolve at separate time scales, higher layers discard rapid, unpredictable details while retaining slower, task-relevant states. In four simulated navigation and manipulation environments, hierarchical planning outperformed flat JEPA; in the Visual AntMaze task, a three-layer structure increased the success rate from 18% to 73%, while requiring less computational power for planning. Ablation experiments indicate that the gains come from both temporal decomposition and high-level goal representation. Under inverse dynamics supervision, this method can be scaled to real robot videos in DROID.

  • Anthropic Bans 11.4 Million Accounts in Six Months, 42000 Appeals Overturned

    On October 12, Anthropic's transparency report updated on July 23 revealed that a total of 11.4 million accounts were banned in the first half of 2026. This is significantly higher than the 1.45 million accounts banned in the second half of 2025, marking an increase of approximately 7.9 times. The statistics cover all of Anthropic's products and services without distinguishing between Claude chat and developer products. During the same period, 398,000 appeals against account bans were received, of which 42,000 resulted in overturned decisions. Based on these figures, the number of overturned bans accounts for approximately 10.6% of the total appeals. Anthropic stated that accounts may be banned for violating usage policies, terms of service, or regional support policies.

  • 2026 Nobel Prize in Economic Sciences Announced

    On October 12, the Royal Swedish Academy of Sciences announced that Robert E. Hall and Michael Woodford have been awarded the Nobel Prize in Economic Sciences. They are recognized for developing new macroeconomic models that significantly enhance the ability to implement effective stabilization policies. Based on these models, timely fiscal and monetary policy measures can reduce the peaks and troughs of the economy. Robert E. Hall and Michael Woodford received this year's award for demonstrating how to reconstruct economic models to revitalize stabilization policies. Instead of building models based on statistical relationships among macroeconomic variables such as inflation, production, and consumption, they opted to establish a foundation based on microeconomic principles. This includes understanding how the overall behavior of households and businesses influences the economy. Robert E. Hall was born in 1943 in Palo Alto, California, and earned his Ph.D. from the Massachusetts Institute of Technology in 1967. He is a professor at Stanford University in California. Michael Woodford was born in 1955 in Chicopee, Massachusetts, and earned his Ph.D. from the Massachusetts Institute of Technology in 1983. He is a professor at Columbia University in New York.

  • Amazon Plans $7 Billion Acquisition of AI Company Decart

    According to sources, Amazon is in talks to acquire the AI startup Decart, with the deal potentially valued at around $7 billion. Decart, headquartered in San Francisco, USA, has software that allows developers to switch more easily between different AI chips. As companies compete for greater computing power, this capability is becoming increasingly important. Sources indicate that if negotiations do not break down and no other bidders emerge, the deal could be finalized soon. According to private market data firm PitchBook, Decart has raised over $400 million in venture capital from investors such as Sequoia Capital, Benchmark, and Radical Ventures. In May of this year, the company's valuation was close to $4 billion.

  • Contractor for Supermicro Pleads Guilty to Illegal Transfer of Nvidia Chips to China

    Court documents reveal that a contractor associated with Supermicro has pleaded guilty to participating in a scheme to illegally transfer servers equipped with Nvidia's advanced AI chips to China. The court case records, released on October 9, indicate that external contractor Sun Tingwei (phonetic) pleaded guilty on Thursday in the U.S. District Court in Manhattan. The U.S. Department of Justice charged Supermicro co-founder Liang Yixian, Taiwan area business manager Zhang Ruicang, and Sun Tingwei in March, accusing the three of conspiring to violate U.S. export control regulations by illegally transferring approximately $2.5 billion worth of equipment utilizing U.S. AI technology to mainland China. The indictment states that the scheme began around 2024, with the three allegedly using a Southeast Asian company as a transit entity to conceal the fact that the ultimate customer was located in China.

  • Yixin Issues Apology: May Be Insolvent

    On October 12, Yixin Group published an "Apology Letter to Clients of Fixed-Income-Like Products" on its subsidiaries Ruicheng and Yirenyouxuan App. Yixin Group stated that due to the contraction of its inclusive finance and wealth management business scale and poor earnings, it has decided to completely stop the redemption of fixed-income-like products by May 22, 2026, and will strive to fairly compensate all investors through orderly exit. However, due to significant losses in multiple business areas, coupled with low asset values in market-based disposals and a lack of effective funding sources, the fixed-income-like products have effectively defaulted, for which the company sincerely apologizes to its clients. The letter indicated that after halting the redemption of fixed-income-like products, Yixin Group systematically reviewed the status of various businesses and promptly commissioned third-party institutions to conduct asset verification and financial due diligence. Preliminary findings suggest that Yixin Group may be insolvent, with a significant debt gap. The underlying assets corresponding to the unpaid fixed-income-like products are of poor quality, and efforts to seek market-based overall disposal have been unsuccessful. Legal due diligence institutions stated that they could not independently investigate the compliance of fixed-income-like products based on the transaction channels and models provided by the group. Yixin Group stated that it will further clarify its asset and liability situation, continue to stabilize its lending and other licensed businesses, make every effort to accelerate the recovery of non-performing loans, expedite the disposal and monetization of valuable assets, and communicate sincerely with clients of fixed-income-like products to resolve risks in accordance with laws and regulations, aiming for fair compensation for investors.

  • IMF Warns: AI May Have Disruptive Effects on Employment and Tax Systems

    On October 12, IMF President Kristalina Georgieva warned that AI is having disruptive effects on the labor market and tax systems, and policymakers need to rethink the education system and take immediate action to help society adapt to these changes. Georgieva stated during her debut at the IMF and World Bank Annual Meetings in Bangkok on Monday, "This is a slowly moving tsunami, but it is still a tsunami." In a session discussing the impact of AI on employment, she noted that AI has weakened demand for certain human workers by replacing a large number of repetitive, procedural jobs; at the same time, it is driving an increase in low-wage positions in industries such as construction, which she believes is "not something to celebrate." Georgieva indicated that this transformation will have profound implications for public finances, with the risk that AI may shift the economy from labor to capital, thereby undermining government tax revenues, as labor income has traditionally been a significant basis for taxation.

  • SWI Group Raises $895 Million to Transform Bitcoin Mining Facilities into AI Infrastructure

    On October 12, The Block reported that SWI Group has raised €800 million (approximately $895 million) from institutional investors following its acquisition of Genesis Digital Assets, a Bitcoin miner owned by FTX. The funds will be used to expand its AI data centers and high-performance computing infrastructure in the United States and Europe. As part of its strategic transformation, the company is repurposing suitable Bitcoin mining facilities for AI computing, gradually exiting the cryptocurrency mining business.

  • CSRC: Exploring Systems and Practices More Suitable for Innovative SMEs

    Wang Li, Deputy Director of the General Office of the China Securities Regulatory Commission (CSRC), stated at a press conference for the 2026 Financial Street Forum Annual Meeting on October 12 that over the past five years, the CSRC has solidly promoted high-quality market development. The Beijing Stock Exchange has operated safely and stably, effectively fulfilling its functions, and positive results have been achieved in market construction.