Skip to main content
QUICK REVIEW

[Paper Review] sGUARD: Towards Fixing Vulnerable Smart Contracts Automatically

Tai D. Nguyen, Long Hoang Pham|arXiv (Cornell University)|Jan 6, 2021
Security and Verification in ComputingComputer Science22 references7 citations
TL;DR

This paper proposes sGuard, a tool that automatically repairs smart contracts to eliminate four common vulnerabilities through provably correct run-time verification. By analyzing symbolic execution traces and applying fixed, sound transformation patterns, sGuard ensures correctness while introducing only minor overhead—14.79% in execution time and 0.79% in gas consumption on average across 5,000 contracts.

ABSTRACT

Smart contracts are distributed, self-enforcing programs executing on top of blockchain networks. They have the potential to revolutionize many industries such as financial institutes and supply chains. However, smart contracts are subject to code-based vulnerabilities, which casts a shadow on its applications. As smart contracts are unpatchable (due to the immutability of blockchain), it is essential that smart contracts are guaranteed to be free of vulnerabilities. Unfortunately, smart contract languages such as Solidity are Turing-complete, which implies that verifying them statically is infeasible. Thus, alternative approaches must be developed to provide the guarantee. In this work, we develop an approach which automatically transforms smart contracts so that they are provably free of 4 common kinds of vulnerabilities. The key idea is to apply runtime verification in an efficient and provably correct manner. Experiment results with 5000 smart contracts show that our approach incurs minor run-time overhead in terms of time (i.e., 14.79%) and gas (i.e., 0.79%).

Motivation & Objective

  • To address the critical problem of unpatchable smart contracts that may contain exploitable vulnerabilities after deployment.
  • To overcome the limitations of existing verification and testing approaches, which cannot guarantee absence of vulnerabilities due to undecidability and false positives.
  • To design a fix-automation approach that ensures correctness through formal soundness and completeness guarantees, not just test-suite coverage.
  • To minimize performance overhead in both execution time and gas consumption, which are critical in blockchain environments.
  • To provide a self-contained, provably correct repair tool tailored specifically for smart contracts written in Turing-complete languages like Solidity.

Proposed method

  • Collecting symbolic execution traces from smart contracts to explore all feasible program paths without full symbolic exploration.
  • Performing custom static analysis on the collected traces to detect four specific types of vulnerabilities: reentrancy, integer overflow/underflow, timestamp dependence, and delegatecall misuse.
  • Designing and applying domain-specific, provably correct fixing patterns for each vulnerability type, ensuring semantic correctness post-fix.
  • Using a context-sensitive, trace-based analysis engine built from scratch to avoid false positives common in existing tools like Securify and Ethainter.
  • Applying run-time checks via code instrumentation that are formally proven to prevent the identified vulnerabilities without altering functional behavior.
  • Validating fixes through formal soundness and completeness proofs for the supported vulnerability classes, ensuring no false negatives or overfitting to test cases.

Experimental results

Research questions

  • RQ1Can a fully automated, provably correct repair technique be designed for smart contracts that are inherently unpatchable after deployment?
  • RQ2How can run-time verification be applied efficiently and soundly to fix common smart contract vulnerabilities without introducing significant performance overhead?
  • RQ3To what extent can symbolic execution traces be used to enable precise, scalable vulnerability detection and repair in smart contracts?
  • RQ4Can a repair approach avoid overfitting to test suites by relying on formal correctness guarantees rather than test coverage?
  • RQ5What is the actual performance impact (in time and gas) of automatically injecting secure run-time checks into real-world smart contracts?

Key findings

  • sGuard successfully identified and fixed 1,605 out of 5,000 analyzed smart contracts, demonstrating strong practical applicability.
  • The average runtime overhead introduced by fixes was 14.79% in execution time and 0.79% in gas consumption, indicating minimal performance impact.
  • Among high-profile contracts, sGuard detected and repaired a single arithmetic vulnerability in the BAT token contract, though further analysis showed it was unexploitable due to existing checks.
  • For the BAT contract, gas overhead was measured at 18% when executing 10 real transactions, confirming the tool's efficiency in real-world scenarios.
  • The tool correctly identified 7 out of 10 high-profile tokens (e.g., LINK, BNB, CRO) as safe, with no modifications needed, validating its precision.
  • sGuard’s custom static analysis engine reduced false positives compared to existing tools like Securify and Ethainter, which suffer from incomplete or conflicting semantic rules.

Read this paper

Open the full text in the Nubint reader and ask about any passage as you read.

Read this paper on Nubint

This review was generated by AI from the original paper. Please check the paper before citing it.