[Paper Review] HCC: A Language-Independent Hardening Contract Compiler for Smart Contracts
This paper presents hcc, the first practical, language-independent smart contract compiler that automatically inserts security hardening checks at the source-code level using a Code-Property Graph (CPG) to model control-flow and data-flow. hcc effectively prevents all known reentrancy and integer overflow vulnerabilities in 10,000 real-world Solidity contracts with 99.99% success rate on top-valued contracts and minimal runtime overhead, outperforming existing tools in coverage and practicality.
Developing secure smart contracts remains a challenging task. Existing approaches are either impractical or leave the burden to developers for fixing bugs. In this paper, we propose the first practical smart contract compiler, called HCC, which automatically inserts security hardening checks at the source-code level based on a novel and language-independent code property graph (CPG) notation. The high expressiveness of our developed CPG allows us to mitigate all of the most common smart contract vulnerabilities, namely reentrancy, integer bugs, suicidal smart contracts, improper use of tx.origin, untrusted delegate-calls, and unchecked low-level call bugs. Our large-scale evaluation on 10k real-world contracts and several sets of vulnerable contracts from related work demonstrates that HCC is highly practical, outperforms state-of-the-art contract hardening techniques, and effectively prevents all verified attack transactions without hampering functional correctness.
Motivation & Objective
- To address the lack of practical, automated tools that harden smart contracts at the source level without burdening developers.
- To overcome limitations of existing solutions that rely on manual fixes, suffer from false positives/negatives, or are incompatible with modern blockchain platforms.
- To design a compiler that supports inter-procedural and inter-contract analysis, accurately identifies mitigation points, and is extensible across multiple smart contract languages and platforms.
- To demonstrate effectiveness on real-world contracts, including high-value and complex contracts, with minimal performance overhead.
- To enable integration with diverse blockchain systems such as Ethereum and Hyperledger Fabric through a generic, extensible CPG-based representation.
Proposed method
- hcc uses a Code-Property Graph (CPG) to model control-flow and data-flow relationships in smart contracts, enabling precise static analysis of vulnerabilities.
- The CPG schema is specifically designed to model smart contract semantics, including function calls, state variables, and data dependencies across contracts.
- hcc queries the CPG to detect reentrancy and integer overflow patterns, identifying optimal insertion points for security hardening checks.
- It inserts field- and offset-sensitive locking mechanisms to prevent reentrancy, avoiding false positives from over-constrained locks.
- The compiler supports source-to-source transformation, preserving original logic while inserting defensive checks that are inspectable and verifiable by developers.
- hcc is implemented for Solidity on Ethereum and extended to support Hyperledger Fabric, demonstrating portability across platforms.
Experimental results
Research questions
- RQ1Can a source-level smart contract compiler automatically and effectively prevent known reentrancy and integer overflow vulnerabilities with minimal developer effort?
- RQ2How does hcc’s CPG-based analysis compare to symbolic execution or bytecode rewriting in terms of scalability, accuracy, and practicality?
- RQ3To what extent can hcc handle real-world, complex, and high-value smart contracts without breaking functionality?
- RQ4Does hcc’s field- and offset-sensitive locking strategy reduce false positives compared to global lock mechanisms used in prior tools?
- RQ5Can hcc be effectively extended to multiple blockchain platforms and programming languages using a generic code representation?
Key findings
- hcc successfully processed 7,174 out of 10,000 contracts (71.74%) within a one-minute timeout, significantly outperforming sGuard, which processed only 3,286 contracts (32.86%).
- With a 12-hour timeout, sGuard compiled only 17 out of 40 vulnerable contracts, while hcc compiled 36 out of 40, including all 25 top-valued ERC20 contracts.
- hcc achieved 100% patch effectiveness in preventing all confirmed reentrancy attack transactions in the EEG dataset, with no false positives on benign transactions.
- hcc prevented two newly discovered reentrant transactions in real contracts (0x85d2…ea0b and 0x516d…29a9), confirming its detection capability beyond known benchmarks.
- The average runtime gas overhead introduced by hcc’s hardening was only 11.95%, demonstrating low performance impact.
- hcc’s field- and offset-sensitive locking strategy avoids false positives from legitimate concurrent access patterns, unlike global lock mechanisms in tools like sGuard.
Read this paper
Open the full text in the Nubint reader and ask about any passage as you read.
Read this paper on NubintThis review was generated by AI from the original paper. Please check the paper before citing it.