Advanced Security Auditing Methods For Solidity-Ba
Advanced Security Auditing Methods For Solidity-Ba
Article
Advanced Security Auditing Methods for Solidity-Based
Smart Contracts
Meihua Xiao, Yangping Xu *, Zehuan Li and Hongbin Wan
School of Information and Software Engineering, East China Jiaotong University, Nanchang 330013, China;
[email protected] (M.X.); [email protected] (Z.L.); [email protected] (H.W.)
* Correspondence: [email protected]
Abstract: The development of smart contracts remains in its early stages, with significant differences
in underlying programming languages and application platforms resulting in a lack of standard-
ization. This lack of standardization increases the susceptibility to vulnerabilities and associated
financial losses. To address security vulnerabilities in smart contracts on the Ethereum blockchain
platform, this paper proposes a security audit method based on formal verification. The method
integrates an input module, static analysis module, formal verification module, analog execution
module, and report and recommendation module, which can accurately discover the security vulnera-
bilities and logical flaws of smart contracts through formal verification and other analysis techniques,
thus realizing correctness detection. During the experiment, the method detects 8 types of common
vulnerabilities in 148 smart contracts and marks 21 smart contracts with vulnerabilities. After manual
review and analysis, it is found that 17 of these 21 marked smart contracts do have security vulner-
abilities. The experimental results show that the proposed method can accurately detect security
vulnerabilities and logic flaws in smart contracts through formal verification and other analysis
techniques before smart contracts are deployed, thus significantly improving the security of smart
contracts and reducing the economic losses that may be caused by code defects.
DAO pool [7], and Parity, an Ether multi-signature wallet, also suffered from a security
vulnerability, resulting in the theft of more than ETH 150,000 (about USD 30 million) [8],
and the painful lessons of such incidents highlight the importance of ensuring the security
and correctness of smart contracts.
The current blockchain ecosystem is highly heterogeneous, with various platforms
using distinct smart contract programming languages such as Solidity for Ethereum, C++
for EOS, and Go for Hyperledger. While this diversity has enabled unique functionalities,
it has also led to significant standardization issues. Different languages and technical
architectures result in poor cross-platform code compatibility, complicating migration and
validation. Moreover, this diversity impacts the consistency of development tools and
frameworks, posing challenges for establishing unified security auditing standards. Each
language has its own vulnerabilities and risks, making standardized security measures
difficult to implement across platforms. For instance, recursive attacks can exhaust contract
resources, excessive privileges can lead to malicious manipulation, and issues with ran-
domness can introduce uncertainty and increase manipulation risks. Detailed attack types
are listed in Appendix A.
Traditional security auditing methods, which rely on manual reviews and testing, are
inefficient and prone to overlooking unforeseen logic errors and vulnerabilities. To address
these challenges, this paper integrates an input module, static analysis module, formal
verification module, simulation execution module, and a report and recommendation
module, making the following contributions:
• Capable of accurately identifying issues such as security vulnerabilities and logic flaws
in smart contracts through formalized verification and other technologies before smart
contracts are deployed, thereby significantly improving the security of smart contracts
and reducing the economic losses that may be caused by code defects.
• Proposes a scalable, automated smart contract review methodology that minimizes
reliance on manual review and ensures comprehensive and consistent assessment
of smart contracts, thereby improving the overall security and reliability of
blockchain applications.
• Simplifies the review process, shortens the development cycle, and generates clear
and actionable audit reports, thereby improving audit efficiency and reducing human
security risks.
The rest of this paper is organized as follows. Section 2 gives a presentation of
the related proposals carried out in the area of smart contract formal verification. We
propose a security audit method to discover the vulnerabilities of current smart contracts
and make timely modifications before deploying smart contracts in Section 3. Section 4
detects all smart contracts deployed on the test network against various vulnerabilities.
Section 5 analyzes the advantages and disadvantages of the proposed approach. Finally,
the conclusions and future work are discussed in Section 6.
2. Relative Work
Many researchers have carried out several works on vulnerability detection and
formal verification of smart contracts. The main work can be categorized into the following
two aspects: the first aspect is for vulnerability detection of smart contracts, and the
second aspect focuses on ensuring the security and correctness of smart contracts.
3.3.Security
SecurityAudit
Audit Method
Method
Toenhance
To enhance the
the security
security ofofsmart
smartcontracts,
contracts,this paper
this paperintroduces a security
introduces auditaudit
a security ap-
proach that
approach thatintegrates formalization
integrates formalization andandmodel-checking
model-checking techniques
techniqueswith
withformal verifica-
formal verifi-
tion. The
cation. Themethod
methodemploys
employsunified
unifiedspecifications
specificationstotoaudit
auditsmart
smartcontract
contractcode,
code,enabling
enabling
userstotosystematically
users systematicallyidentify
identifyandand mitigate
mitigate vulnerabilities
vulnerabilities before
before deployment.
deployment. ByBy for-
formal-
malizing contract behavior and leveraging model checking to explore all
izing contract behavior and leveraging model checking to explore all potential states, this potential states,
this approach
approach improves
improves the precision
the precision of vulnerability
of vulnerability detection,
detection, allowing
allowing for timely
for timely mod-
modifica-
ifications
tions and reducing
and reducing theof
the risk risk of security
security flawsflaws in deployed
in deployed contracts.
contracts.
Themain
The main method proposed
proposedininthis thispaper
paperis is
illustrated
illustratedin Figure 1, consisting
in Figure of five
1, consisting of
modules:
five modules:an input module,
an input a static
module, analysis
a static module,
analysis a formal
module, verification
a formal module,
verification a sim-a
module,
ulation execution
simulation module,
execution module,andand
a report andand
a report recommendation
recommendation module.
module.
Static Analysis
Formal Verification
Building formal Logical Inference
Smart Contract Simulation
models Algorithm
Security Audit
Method Generate State Verifying Security
LTL
Paths Attributes
Analog Execution
Constructing Generating State Simulating
State Machines Space Diagrams Smart Contracts
Audit Reports
Theinput
The input module
modulereceives
receivesand
and parses
parsesthethe
smart contract
smart source
contract code,code,
source while while
the static
the
analysis module uses the ACL2 [34] tool to detect potential issues in the code.
static analysis module uses the ACL2 [34] tool to detect potential issues in the code. The formal
The
verification
formal modulemodule
verification ensuresensures
the security of the contract
the security through through
of the contract formal methods, and the
formal methods,
simulation execution module evaluates the contract’s performance in different
and the simulation execution module evaluates the contract’s performance in different environ-
ments. Finally,Finally,
environments. the report and recommendation
the report and recommendation module synthesizes
module the results
synthesizes fromfrom
the results all
modules to generate an audit report and provide targeted improvement suggestions.
all modules to generate an audit report and provide targeted improvement suggestions.
3.1.Input
3.1. InputModule
Module
Thismodule
This moduleisisdesigned
designed to
to receive
receive and
and parse smart contract
contract source
source code
code for
for formal
formal
verificationand
verification andmodel
model testing.
testing. It processes
processes contracts
contracts written
written in
in Solidity,
Solidity, identifying
identifyingkey
key
functions and variables while ensuring the integrity of the original code’s semantics during
conversion. By preprocessing and normalizing the input, this module enhances the accuracy
and efficiency of subsequent reviews.
Electronics 2024, 13, x FOR PEER REVIEW 5 of 22
Electronics 2024, 13, 4093 functions and variables while ensuring the integrity of the original code’s semantics 5dur- of 22
ing conversion. By preprocessing and normalizing the input, this module enhances the
accuracy and efficiency of subsequent reviews.
Forinstance,
For instance,consider
consider a smart
a smart contract
contract implementing
implementing an online
an online store.store. The owner
The store store
owner
can add can
newadd new products,
products, update update
existingexisting inventory,
inventory, and withdraw
and withdraw ETH from ETHthe from the
store’s
store’s balance.
balance. Users canUsers
viewcan view product
product details
details and make andpurchases.
make purchases.
The ETH The ETH
paid bypaid
usersbyis
users is adjusted
adjusted according according to the product
to the product price andprice and quantity,
quantity, The excess
The excess will bewill be refunded
refunded to the
to the
user. user.successful
Upon Upon successful purchase,
purchase, the item’s
the item’s inventory
inventory is reduced,
is reduced, andtransactions
and all all transactions
and
and inventory
inventory changes
changes are logged
are logged on-chain
on-chain through
through events.
events. Figure
Figure 2 shows
2 shows an example
an example of
of the
the code of a smart contract.
code of a smart contract.
Finally, the result output unit generates a comprehensive report detailing syntax and
semantic errors, as well as potential security vulnerabilities. Each issue is documented with
its location, type, impact, and remediation recommendations. While automated tools catch
many problems, a manual review is often necessary to confirm the validity of warnings
and ensure that all issues have been accurately resolved. After corrections, the contract
undergoes re-auditing to confirm that vulnerabilities have been eliminated and no new
issues have been introduced.
An example of a static analysis algorithm transforms a program’s instruction sequence
into a chain of blocks and a jump graph. The instructions are organized into blocks, and
“JUMPI” instructions are processed to establish jump relationships, resulting in a jump
graph that visually represents the control flow between blocks. This ensures that the
structure of the contract is clear and can be verified for correctness.
Algorithm 1 constructs a program’s control flow graph by dividing the instruction
sequence into basic blocks and establishing relationships between these blocks using
jump instructions. Through this process, the static analysis tool organizes the program’s
execution logic into distinct blocks and defines the jump paths, resulting in a clear control
flow structure. This approach accurately represents the program’s execution path, helping
developers understand the sequence of instructions and their branching behavior.
validates the safety of conditional jumps, and flags potential loops or recursive behavior,
which contributes to robust control flow validation.
Proper parameter configuration is crucial for automating the detection and correction
of issues in smart contract source code, enhancing both security and reliability. The Solidity
code is scanned by a syntax analyzer to ensure compliance with language specifications,
with parameters tailored to the specific Solidity version for compatibility. Code style settings
are enforced for consistency and readability, while permitted and prohibited features are
defined to avoid common vulnerabilities. Security rules are configured to prevent risky
operations and unauthorized access, while compiler warnings and errors are adjusted to
detect issues such as unused variables or unsafe functions. Additionally, code structure
parameters ensure better organization, and optimization settings are configured to improve
execution efficiency and reduce gas consumption, ultimately making the smart contract
more secure and efficient.
The property
property verified
verified by
by p1
p1isisthe
theinvariance
invarianceofofthe
thetotal
totalaccount
accountbalance.
balance.Specifically,
Specifically,
the total balance
balance of
of each
each account
account in
inthe
thesmart
smartcontract
contractshould
shouldremain
remainconstant
constantthroughout
throughout
the entire
entire transaction process. InIn other
other words,
words, the
thecombined
combined balance
balanceof
ofall
allaccounts
accountsshould
should
not change
change during
duringany
anytransactions
transactionsororoperations.
operations.Below
Below areare explanations
explanations forfor
thethe func-
functions
tions involved
involved in verifying
in verifying this property:
this property:
•• Fa_stm(): Represents
Represents the
theproduction
productionprocess
process with
with re_truck_id,
re_truck_id, truck_id,
truck_id, payment,
payment, and
and nb_goods
nb_goods variables,
variables, wherewhere nb_goods
nb_goods is initialized
is initialized to 1000,
to 1000, andprocess
and this this process calls
calls R_fa()
in a loop
R_fa() in atoloop
simulate the operation
to simulate of production.
the operation of production.
• SCa_stm(): represents the smart contract A process with the payment variable, and
R_sca() is called in a loop to simulate the behavior of smart contract A.
Electronics 2024, 13, 4093 10 of 22
3.4.
3.4. Analog
Analog Execution
Execution Module
Module
The
The main
main objective
objective of this
of this module
module is toisevaluate
to evaluate
the the performance
performance of smart
of smart contracts
contracts in
different operating
in different environments
operating environments through
through exhaustive simulations
exhaustive and and
simulations in-depth analysis
in-depth analy-
tosis
ensure their their
to ensure security and and
security robustness.
robustness.TheThe
module consists
module of five
consists core
of five units:
core a state
units: a state
machine
machine model
model building
buildingunit, state
unit, space
state space graph
graphconstruction
constructionunit,
unit,anomaly
anomaly detection
detectionunit,
unit,
simulation unit, and evaluation unit.
simulation unit, and evaluation unit.
The Figure 5 show the workflow of this module starts with constructing a state ma-
chine model derived from the source code of the smart contract, encompassing all possible
states and their transitions. The state machine model building unit is responsible for
Electronics 2024, 13, 4093 11 of 22
Constructing state machine model from the source code of a smart State Machine Model Building
contract Unit
Simulate the actual operation of the smart contract to be audited Simulation Unit
and test the smart contract response results
Figure5.5.Analog
Figure Analogexecution
executionmodule
moduleworkflow.
workflow.
Thestate
The statespace
spacegraph
graphconstruction
constructionunit unitisisbased
basedon onthe thestate
statemachine
machinemodel,
model,and and
fromwhich
from whichthethestate
statespace
spacegraph
graphisisdeveloped.
developed.The Thestate
statespace
spacegraph
graphcomprehensively
comprehensively
coversall
covers allthe
thestate
statechanges
changesthatthataasmart
smartcontract
contract may
may experience
experience during
during itsits life
life cycle,
cycle,
providing
providinga abasis
basisfor
forsubsequent
subsequent anomaly
anomaly detection and
detection simulation.
and simulation.Through
Through thisthis
graphical
graph-
representation,
ical representation,the state flowflow
the state andandpotential
potentialpaths of of
paths smart
smart contracts
contracts can
canbebeunderstood
understood
intuitively.
intuitively. The anomaly detection unit is responsible for traversing the state spacegraph,
The anomaly detection unit is responsible for traversing the state space graph,
detecting
detectingand andrecording
recording potential
potentialriskrisk
paths thatthat
paths maymayexistexist
during state state
during transitions. The task
transitions. The
oftask
theof
anomaly detection
the anomaly unit isunit
detection to identify potential
is to identify anomalies
potential and risky
anomalies andpaths
riskyinpaths
the smart
in the
contract that maythat
smart contract leadmayto unexpected behaviors behaviors
lead to unexpected or system vulnerabilities, thus providing
or system vulnerabilities, thus
critical information for further security analysis. The simulation unit
providing critical information for further security analysis. The simulation unit employs employs advanced
techniques to simulatetosmart
advanced techniques simulatecontract
smart operations in real-world
contract operations scenarios.
in real-world It generates
scenarios. It gen-
various transactions, including normal, boundary conditions and
erates various transactions, including normal, boundary conditions and intentionally intentionally malicious ma-
ones,
licioustoones,
test how thehow
to test smartthe contract handles
smart contract different
handles inputs.inputs.
different The unit
The also
unit simulates
also simu-
blockchain event event
lates blockchain triggers, such as
triggers, reaching
such specific
as reaching time thresholds
specific time thresholdsor account
or accountbalance
bal-
changes, to verify the correctness of the smart contract’s response logic.
ance changes, to verify the correctness of the smart contract’s response logic. Additionally, Additionally, it
it introduces abnormal conditions like transaction failures, network delays, and resource
constraints to assess the smart contract’s performance under such scenarios.
Electronics 2024, 13, 4093 12 of 22
introduces abnormal conditions like transaction failures, network delays, and resource
constraints to assess the smart contract’s performance under such scenarios.
The evaluation unit integrates results from the anomaly detection and simulation units
to provide a comprehensive assessment of the smart contract. It analyzes the contract’s
performance under normal and extreme conditions, focusing on stability and performance
metrics such as execution efficiency, resource consumption, and response time. The unit also
evaluates the contract’s security, identifying potential vulnerabilities and attack surfaces.
Simulated execution results detail the execution paths of potential risks, successful and
failed transactions, and reasons for any anomalies.
The simulation execution unit plays a key role in the vulnerability detection process
of smart contracts, spanning the entire workflow from source code analysis to perfor-
mance and security assessment. First, a state machine model is constructed based on the
smart contract’s source code, and a state space graph is generated, covering all possible
state changes throughout the contract’s life cycle, providing a foundation for subsequent
anomaly detection and simulation. The anomaly detection module traverses the state space
graph to identify potential risky execution paths, uncovering abnormal behaviors and
unsafe operation patterns that may lead to vulnerabilities, such as reentrancy attacks and
timestamp manipulation. Building on this, the simulation unit employs advanced simula-
tion techniques to emulate various scenarios in a real blockchain environment, including
normal transactions, malicious attacks, and boundary conditions, to assess the contract’s
performance under different inputs and extreme conditions. Finally, the evaluation unit
integrates the results from the simulation execution to comprehensively evaluate the smart
contract’s performance and security, ensuring stability and reliability before formal deploy-
ment. This process effectively reduces the security risks associated with the contract after it
goes live.
Through this detailed and comprehensive simulation execution process, the simulated
execution module provides developers with a powerful tool to help identify and fix po-
tential problems before the smart contract is formally deployed. This pre-assessment and
optimization can significantly improve the reliability and security of smart contracts, ensur-
ing that they can stably and reliably perform their intended functions in actual operation.
Leveraging semantic analysis results and knowledge base insights, the customized rec-
ommendation generation module formulates tailored enhancement strategies. By utilizing
advanced rule engines, it constructs remediation plans to address real-world challenges.
For more complex scenarios, the module synthesizes multiple knowledge sources and
historical case data to deliver comprehensive solutions. These solutions may encompass
code refactoring, vulnerability mitigation, and performance optimization, all with the
objective of improving the security and operational efficiency of smart contracts.
Finally, the interactive suggestion optimization unit offers an interactive interface for
developers to review and provide feedback on the customized suggestions. This feedback
allows the unit to refine the detail and applicability of the recommendations, ensuring
their practical feasibility. This interactive feature enhances the relevance and realism
of the suggestions, optimizing the recommendation generation process and improving
user experience.
In essence, the module produces a clear security audit report and personalized recom-
mendations by thoroughly analyzing multiple data sources. This approach not only boosts
the efficiency and accuracy of smart contract audits but also provides a solid foundation
for the secure deployment and operation of smart contracts, ensuring their security and
stability in diverse operating environments.
4. Experiments
This paper adopts a systematic approach to smart contract vulnerability detection.
First, the types of vulnerabilities to be detected are identified, and the relevant smart
contracts deployed on the test network are screened. Next, targeted vulnerability detection
is performed on these contracts to analyze whether the selected vulnerability type exists.
Eventually, the detection results are presented in the form of a report listing the names of all
the contracts in which vulnerabilities are found. This method effectively reduces redundant
detection steps, improves detection efficiency, and optimizes the detection process by
making the vulnerability detection results more explicit.
The static analysis module uses the ACL2 8.0 to examine the Solidity code’s syntax
and semantics. Configured for Solidity version 0.8.3 with all security checks enabled,
this analysis is essential for detecting vulnerabilities. It focuses on evaluating the ABI
and bytecode of the smart contract, establishing key mappings between the contract, its
ABI functions, and the functions those ABI functions invoke. This foundational anal-
ysis is crucial for identifying potential issues and supporting the overall vulnerability
detection process.
The execution of a smart contract involves transactions between distinct accounts
based on the contract’s rules, including calls to ABI functions. To ensure accurate exe-
cution, it is essential to simulate these transactions with external accounts. For specific
vulnerabilities, such as reentrancy, which involves complex interactions between contracts
and nested function calls, standard transaction analysis may be inadequate. Consequently,
proxy accounts are constructed according to defined attack scenarios to simulate and detect
such vulnerabilities effectively. These proxy accounts are designed to interact in ways that
can trigger reentrancy attacks, thereby identifying and highlighting contracts with such
vulnerabilities. The number of smart contracts tested for different types of vulnerabilities is
shown in Table 1.
After completing the static analysis, we started to detect the vulnerability of each
deployed smart contract for a specific type of vulnerability. First, a random number
generator is used to generate an integer in a certain interval as the number of times the
smart contract is detected, which needs to be selected in a moderate interval.
To achieve an optimal balance between detection efficiency and coverage, a function
from the corresponding function call set of the smart contract is randomly selected for fuzzy
input in each vulnerability detection process. Multiple random selections are involved in a
vulnerability detection process, and the reason for emphasizing randomness is to maximize
the coverage as well as the accuracy of vulnerability detection and to simulate the execution
of the smart contract under different function call sequences by means of randomization.
Table 2 shows the number of smart contracts containing vulnerabilities detected by the
static analysis module.
We tested 148 smart contracts and detected 18 smart contracts with vulnerabilities,
of which three block number dependency vulnerabilities were detected and the number
of actual smart contracts with block number dependency was two, with a 66.9% correct
rate. Nine conditional competition vulnerabilities were detected, and the actual number of
smart contracts with conditional competition vulnerabilities was six, with a 66.7% correct
rate. All other smart contracts with vulnerabilities were correctly identified.
Race condition vulnerabilities are usually caused by mutual interference between
multiple concurrent operations or transactions, especially when accessing shared resources;
at the same time, detecting such vulnerabilities becomes more challenging due to the
complexity of the block numbering dependency logic, which often leads to false positives
and decreased accuracy. This is further verified by the experimental data, which shows
that the detection of block number dependency vulnerabilities has a low correct rate, and
this complexity makes the detection of such vulnerabilities more difficult and uncertain.
To more intuitively demonstrate the performance of the method proposed in this paper
for detecting Ethereum smart contract vulnerabilities, as well as the current challenges it
faces, comparative experiments were conducted, selecting relevant work in the field of
smart contract vulnerability detection for evaluation. Specifically, the proposed method
was compared against five mainstream vulnerability detection tools: Oyente, ReGuard,
Manticore, Securify, and Slither. These tools were tested on the same dataset and for
the same types of vulnerabilities. As shown in Table 3, following the experiments, an
in-depth analysis and discussion of the differences in detection results between each tool
were conducted to comprehensively assess the effectiveness and performance of various
detection methods in practical applications.
lower-level errors. Slither, meanwhile, efficiently identifies obvious reentrancy risks and
sequential problems but falls short in detecting issues in complex multi-contract interactions
and deep calls. Its ability to identify stack overflow vulnerabilities is also relatively limited.
Figure 7. Suggestion
Suggestion for
for the issue.
Figure 7. Suggestion for the issue.
Contract
In Address:
the security audit report, the detected issues are thoroughly described along with
0x27054b13b1b798b345b591a4d22e6562d47ea75a
optimization
In recommendations.
the security audit report, For instance,issues
the detected to address the conditional
are thoroughly contention
described vul-
along with
Link Address:
nerability,
optimization it isrecommendations.
advised to implement a lockingtomechanism
For instance, address thetoconditional
prevent concurrent
contention access
vul-
to https://etherscan.io/address/0x27054b13b1b798b345b591a4d22e6562d47ea75a
shared resources. This can be achieved by incorporating require
nerability, it is advised to implement a locking mechanism to prevent concurrent access statements to (ac-
verify
cessed
theshared
to on 16
contract’s October
resources. 2024)
state before executing
This can critical
be achieved byoperations.
incorporating Additionally, to mitigate
require statements to issues
verify
related This
to tool
the contract’sblock uses formal
numbering
state verification,
dependencies,
before executing static
it is
critical analysis,
recommended
operations. and manual
to avoid
Additionally, review
using
to toblock
conduct
mitigate num-a
issues
multi-dimensional
bers
related in critical
to blocklogic. comprehensive security
Instead,dependencies,
numbering utilizing timestamps audit of the code specifications,
or other on-chain
it is recommended to avoidmetrics security,
using that and
arenum-
block less
business
susceptible logic
bers in critical of the smart
to manipulation contract
logic. Instead,isutilizing in
suggested. three aspects. Table
These measures
timestamps or other5 shows
aim the deployment
to enhance
on-chain address
the security
metrics that are and
less
and relevant
stability of links
smart for the smart
contracts, contract,
reduce the as
risk well
of as the
potential results of
attacks, an
susceptible to manipulation is suggested. These measures aim to enhance the security andandaudit conducted
ensure the during
contract’s
the experiment.
reliability
stability smartBased
ofacross various onenvironments.
contracts, the recommendations
reduce Following
the risk in the
the suggestions
of potential audit report,
attacks, and the source
provided
ensure in code
the the of the
report,
contract’s
smart
the contract
recommended
reliability was
across various modified
changes and resubmitted
were implemented,
environments. Following for further
andthethe audit.
contract was
suggestions The new security
subsequently
provided audit
re-au-
in the report,
report
dited. indicates that
The contractchanges
the recommended all identified
address were
and linksecurity issues
used in theand
implemented, have been
experiment effectively
the contractare shown resolved.
below, andre-au-
was subsequently Table
5dited.
illustrates the results
The contract of this
address re-audit
and link usedafterinthe
themodifications
experiment are were applied.
shown below, and Table
Contract
5 illustrates theAddress:
results of this re-audit after the modifications were applied.
0x27054b13b1b798b345b591a4d22e6562d47ea75a
Contract Address:
0x27054b13b1b798b345b591a4d22e6562d47ea75a
Electronics 2024, 13, 4093 18 of 22
Author Contributions: Conceptualization, M.X. and Y.X.; methodology, Y.X.; validation, Y.X.,
Z.L. and H.W.; formal analysis, Y.X.; investigation, Y.X.; writing—original draft preparation, Y.X.;
writing—review and editing, M.X. and Z.L. All authors have read and agreed to the published
version of the manuscript.
Funding: This research was funded by the National Natural Science Foundation of China (grant num-
ber 62362033, 61962020), the Double Thousand Talent Plan of Jiangxi Province (No. jxsq2023201009),
and the Natural Science Foundation of Jiangxi Province (No. 20224ACB202006).
Data Availability Statement: The authors confirm that the data supporting the findings of this study
are available within the article.
Conflicts of Interest: The authors declare no conflicts of interest.
Appendix A
This appendix provides a comprehensive overview of eight prevalent types of smart
contract vulnerabilities, which are critical for understanding and mitigating potential risks
in blockchain applications.
1. Reentrancy
Reentrancy vulnerabilities arise when a smart contract makes an external call to
another contract before fully completing its internal state updates. This can create a scenario
where the external contract can repeatedly call back into the original contract before its state
is finalized, potentially leading to unintended consequences. This type of vulnerability
was notably exploited in the DAO hack, where attackers exploited the reentrancy flaw to
drain funds from the contract. Proper safeguards, such as using checks–effects–interactions
patterns and reentrancy guards, can help mitigate this risk.
2. Disorder
Disorder vulnerabilities involve problems related to the sequence of operations or the
order in which transactions are processed. These vulnerabilities occur when a contract’s
functionality depends on a specific order of operations, but an attacker can invoke functions
out of the expected order. Such issues can lead to unexpected behaviors or security
breaches, such as unauthorized access or improper state changes. Ensuring that functions
are invoked in a controlled manner and implementing comprehensive validation checks
can help address disorder vulnerabilities.
3. Timestamp Dependency
Electronics 2024, 13, 4093 20 of 22
References
1. Yaga, D.; Mell, P.; Roby, N.; Scarfone, K. Blockchain technology overview. arXiv 2019, arXiv:1906.11078.
2. Ethereum: A Secure Decentralised Generalised Transaction Ledger. 2019. Available online: https://ethereum.github.io/
yellowpaper/paper.pdf (accessed on 19 September 2024).
3. Antonopoulos, A.M.; Wood, G. Mastering Ethereum: Building Smart Contracts and DApps; O’Reilly Media: Sebastopol, CA,
USA, 2018.
4. Szabo, N. The idea of smart contracts. Nick Szabo’s Pap. Concise Tutor. 1997, 6, 199.
5. He, H.; Yan, A.; Chen, Z. Survey of Smart Contract Technology and Application Based on Blockchain. J. Comput. Res. Dev. 2018,
55, 2452–2466. (In Chinese)
6. Atzei, N.; Bartoletti, M.; Cimoli, T. A survey of attacks on ethereum smart contracts (SoK). In Proceedings of the International
Conference on Principles of Security and Trust, Uppsala, Sweden, 24–25 April 2017; Springer: Berlin/Heidelberg, Germany, 2017;
pp. 164–186.
7. Kushwaha, S.S.; Joshi, S.; Singh, D.; Kaur, M.; Lee, H.N. Systematic review of security vulnerabilities in ethereum blockchain
smart contract. IEEE Access 2022, 10, 6605–6621. [CrossRef]
8. Liu, J.; Liu, Z. A survey on security verification of blockchain smart contracts. IEEE Access 2019, 7, 77894–77904. [CrossRef]
9. Luu, L.; Chu, D.H.; Olickel, H.; Saxena, P.; Hobor, A. Making smart contracts smarter. In Proceedings of the 2016 ACM SIG-SAC
Conference on Computer and Communications Security, Vienna, Austria, 24–28 October 2016; pp. 254–269.
10. Mossberg, M.; Manzano, F.; Hennenfent, E.; Groce, A.; Grieco, G.; Feist, J.; Brunson, T.; Dinaburg, A. Manticore: A User-Friendly
Symbolic Execution Framework for Binaries and Smart Contracts. In Proceedings of the 2019 34th IEEE/ACM International
Conference on Automated Software Engineering (ASE), San Diego, CA, USA, 11–15 November 2019; pp. 1186–1189. [CrossRef]
11. Krupp, J.; Rossow, C. teEther: Gnawing at Ethereum to Automatically Exploit Smart Contracts. In Proceedings of the 27th
USENIX Security Symposium, Baltimore, MD, USA, 15–17 August 2018.
12. Torres, C.F.; Schütte, J.; State, R. Osiris: Hunting for integer bugs in ethereum smart contracts. In Proceedings of the 34th Annual
Computer Security Applications Conference, San Juan, PR, USA, 3–7 December 2018; pp. 664–676.
13. Miller, A.K.; Xia, Y.; Croman, K.; Shi, E.; Song, D.X. The Honey Badger of BFT Protocols. In Proceedings of the 2016 ACM SIGSAC
Conference on Computer and Communications Security, Vienna, Austria, 24–28 October 2016.
14. Chen, T.; Zhang, Y.; Li, Z.; Luo, X.; Wang, T.; Cao, R.; Xiao, X.; Zhang, X. TokenScope: Automatically Detecting Inconsistent
Behaviors of Cryptocurrency Tokens in Ethereum. In Proceedings of the 2019 ACM SIGSAC Conference on Computer and
Communications Security, London, UK, 11–15 November 2019.
15. Tsankov, P.; Dan, A.M.; Drachsler-Cohen, D.; Gervais, A.; Buenzli, F.; Vechev, M.T. Securify: Practical Security Analysis of Smart
Contracts. In Proceedings of the 2018 ACM SIGSAC Conference on Computer and Communications Security, Toronto, ON,
Canada, 15–19 October 2018.
16. Feist, J.; Grieco, G.; Groce, A. Slither: A Static Analysis Framework for Smart Contracts. In Proceedings of the 2019 IEEE/ACM
2nd International Workshop on Emerging Trends in Software Engineering for Blockchain (WETSEB), Montreal, QC, Canada, 27
May 2019; pp. 8–15. [CrossRef]
17. Tikhomirov, S.; Voskresenskaya, E.; Ivanitskiy, I.; Takhaviev, R.; Marchenko, E.; Alexandrov, Y. SmartCheck: Static Analysis of
Ethereum Smart Contracts. In Proceedings of the 2018 IEEE/ACM 1st International Workshop on Emerging Trends in Software
Engineering for Blockchain (WETSEB), Gothenburg, Sweden, 27 May 2018; pp. 9–16.
18. Schneidewind, C.; Grishchenko, I.; Scherer, M.; Maffei, M. eThor: Practical and Provably Sound Static Analysis of Ethereum
Smart Contracts. In Proceedings of the 2020 ACM SIGSAC Conference on Computer and Communications Security (CCS’20),
Virtual Event, 9–13 November 2020; Association for Computing Machinery: New York, NY, USA, 2020; pp. 621–640. [CrossRef]
19. Krötzsch, M.; Rudolph, S.; Hitzler, P. Complexities of Horn Description Logics. ACM Trans. Comput. Logic 2013, 14, 2. [CrossRef]
20. Grech, N.; Kong, M.; Jurisevic, A.; Brent, L.; Scholz, B.; Smaragdakis, Y. MadMax: Surviving out-of-gas conditions in Ethereum
smart contracts. Proc. ACM Program. Lang. 2018, 2, 116. [CrossRef]
21. Bhargavan, K.; Delignat-Lavaud, A.; Fournet, C.; Gollamudi, A.; Gonthier, G.; Kobeissi, N.; Kulatova, N.; Rastogi, A.; Sibut-
Pinote, T.; Swamy, N.; et al. Formal verification of smart contracts: Short paper. In Proceedings of the 2016 ACM Workshop on
Programming Languages and Analysis for Security, Vienna, Austria, 24 October 2016; pp. 91–96.
22. Kalra, S.; Goel, S.; Dhawan, M.; Sharma, S. Zeus: Analyzing safety of smart contracts. In Proceedings of the 25th Annual Network
and Distributed System Security Symposium (NDSS), San Diego, CA, USA, 18–21 February 2018; pp. 1–12.
23. Baier, C.; Katoen, J. Principles of Model Checking; MIT Press: Cambridge, MA, USA, 2008.
24. Cimatti, A.; Clarke, E.; Giunchiglia, E.; Giunchiglia, F.; Pistore, M.; Roveri, M.; Sebastiani, R.; Tacchella, A. Nusmv 2: An
opensource tool for symbolic model checking. In Proceedings of the International Conference on Computer Aided Verification,
Copenhagen, Denmark, 27–31 July 2002; Springer: Berlin/Heidelberg, Germany, 2002; pp. 359–364.
25. Holzmann, G.J. The model checker SPIN. IEEE Trans. Softw. Eng. 1997, 23, 279–295. [CrossRef]
26. Xiao, M.; Zhao, H.; Yang, K.; Ouyang, R.; Song, W. A formal analysis method for composition protocol based on model checking.
Sci. Rep. 2022, 12, 8493. [CrossRef] [PubMed] [PubMed Central]
27. Bai, X.; Cheng, Z.; Duan, Z.; Hu, K. Formal Modeling and Verification of Smart Contracts. In Proceedings of the 2018 7th
International Conference on Software and Computer Applications, Kuantan, Malaysia, 8–10 February 2018.
Electronics 2024, 13, 4093 22 of 22
28. Amani, S.; Bégel, M.; Bortin, M.; Staples, M. Towards verifying ethereum smart contract bytecode in Isabelle/HOL. In Proceedings
of the 7th ACM SIGPLAN International Conference on Certified Programs and Proofs, Los Angeles, CA, USA, 8–9 January 2018;
pp. 66–77.
29. Grishchenko, I.; Maffei, M.; Schneidewind, C. Ethertrust: Sound Static Analysis of Ethereum Bytecode; Technische Universität Wien:
Vienna, Austria, 2018; pp. 1–41.
30. Nehai, Z.; Piriou, P.Y.; Daumas, F. Model-checking of smart contracts. In Proceedings of the 2018 IEEE International Conference
on Internet of Things (iThings) and IEEE Green Computing and Communications (GreenCom) and IEEE Cyber, Physical and
Social Computing (CPSCom) and IEEE Smart Data (SmartData), Halifax, NS, Canada, 30 July–3 August 2018; pp. 980–987.
31. Browne, M.C.; Clarke, E.M.; Grümberg, O. Characterizing finite Kripke structures in propositional temporal logic. Theor. Comput.
Sci. 1988, 59, 115–131. [CrossRef]
32. Osterland, T.; Rose, T. Model checking smart contracts for ethereum. Pervasive Mob. Comput. 2020, 63, 101129. [CrossRef]
33. Mikk, E.; Lakhnech, Y.; Siegel, M.; Holzmann, G.J. Implementing statecharts in PROMELA/SPIN. In Proceedings of the 2nd IEEE
Workshop on Industrial Strength Formal Specification Techniques, Boca Raton, FL, USA; 1998; pp. 90–101. [CrossRef]
34. Kaufmann, M.; Moore, J.S. ACL2: An industrial strength version of Nqthm. In Proceedings of the 11th Annual Conference on
Computer Assurance—COMPASS ’96, Gaithersburg, MD, USA, 17–21 June 1996; pp. 23–34. [CrossRef]
35. Paulin-Mohring, C. Inductive definitions in the system Coq rules and properties. In Typed Lambda Calculi and Applications—TLCA
1993; Bezem, M., Groote, J.F., Eds.; Lecture Notes in Computer Science; Springer: Berlin/Heidelberg, Germany, 1993; Volume 664.
[CrossRef]
Disclaimer/Publisher’s Note: The statements, opinions and data contained in all publications are solely those of the individual
author(s) and contributor(s) and not of MDPI and/or the editor(s). MDPI and/or the editor(s) disclaim responsibility for any injury to
people or property resulting from any ideas, methods, instructions or products referred to in the content.