Skip to main content
QUICK REVIEW

[Paper Review] ACFIX: Guiding LLMs with Mined Common RBAC Practices for Context-Aware Repair of Access Control Vulnerabilities in Smart Contracts

Lyuye Zhang, Kaixuan Li|arXiv (Cornell University)|Mar 11, 2024
Blockchain Technology Applications and SecurityComputer Science5 citations
TL;DR

ACFIX uses a mined RBAC taxonomy and context-aware prompting with GPT-4 to repair access control vulnerabilities in smart contracts, achieving substantial improvement over baseline GPT-4 and enabling human-aligned patches.

ABSTRACT

Smart contracts are susceptible to various security issues, among which access control (AC) vulnerabilities are particularly critical. While existing research has proposed multiple detection tools, the automatic and appropriate repair of AC vulnerabilities in smart contracts remains a challenge. Unlike commonly supported vulnerability types by existing repair tools, such as reentrancy, which are usually fixed by template-based approaches, the main obstacle of AC lies in identifying the appropriate roles or permissions amid a long list of non-AC-related source code to generate proper patch code, a task that demands human-level intelligence. Leveraging recent advancements in large language models (LLMs), we employ the state-of-the-art GPT-4 model and enhance it with a novel approach called ACFIX. The key insight is that we can mine common AC practices for major categories of code functionality and use them to guide LLMs in fixing code with similar functionality. To this end, ACFIX involves both offline and online phases. First, during the offline phase, ACFIX mines a taxonomy of common Role-based Access Control (RBAC) practices from 344,251 on-chain contracts, categorizing 49 role-permission pairs from the top 1,000 pairs mined. Second, during the online phase, ACFIX tracks AC-related elements across the contract and uses this context information along with a Chain-of-Thought pipeline to guide LLMs in identifying the most appropriate role-permission pair for the subject contract and subsequently generating a suitable patch. This patch will then undergo a validity and effectiveness check. To evaluate ACFIX, we built the first benchmark dataset of 118 real-world AC vulnerabilities, and our evaluation revealed that ACFIX successfully repaired 94.92% of them. This represents a significant improvement compared to the baseline GPT-4, which achieved only 52.54%.

Motivation & Objective

  • Identify common RBAC (Role-Based Access Control) practices in real-world smart contracts and build a dynamic RBAC taxonomy.
  • Leverage static code analysis to construct an AC context graph that informs patch generation.
  • Guide GPT-4 with the RBAC taxonomy and context graphs to produce correct patches for AC vulnerabilities.
  • Validate patches with a dedicated validator to ensure alignment with RBAC policies and prevent regressions.
  • Benchmark ACFIX against state-of-the-art tools and assess alignment with human repairs.

Proposed method

  • Offline mining of RBAC practices from 344,251 on-chain contracts to build a taxonomy of 49 role-permission pairs.
  • Static slicing to construct an AC context graph (ACG) around the vulnerable function.
  • Online dual-agent (generator and validator) MAD framework guides LLMs to select appropriate role-permission pairs and generate patches (CoT prompting).
  • Patches are statically checked and iteratively validated by a validator for semantic correctness and RBAC consistency.
  • Evaluation on a real-world AC vulnerability benchmark of 118 cases showing 94.92% repair rate with ACFIX vs 52.54% for GPT-4 baseline.
  • Comparison against SOTA repair tools and an ablation study to assess contributions of context and taxonomy.

Experimental results

Research questions

  • RQ1Can mined RBAC patterns effectively guide LLMs to repair AC vulnerabilities in smart contracts?
  • RQ2Does incorporating an AC context graph and RBAC taxonomy improve patch accuracy and semantic alignment over vanilla LLM repairs?
  • RQ3How does ACFIX perform relative to baseline GPT-4 and other state-of-the-art vulnerability repair tools on real-world AC cases?
  • RQ4What is the impact of the validator in the MAD framework on repair success and quality?

Key findings

  • ACFIX repaired 94.92% of AC vulnerabilities in the benchmark, substantially higher than the GPT-4 baseline at 52.54%.
  • Ablation shows that enriching context and taxonomy improves repair effectiveness (GPT-4 alone fixed 52.54%).
  • Validator component raised repair effectiveness from 87.28% to 94.92%.
  • Human experts largely align with ACFIX repairs and sometimes outperform in open issues, while many fixes are non-trivial for humans alone.
  • The RBAC taxonomy captured 49 role-permission pairs, covering the majority of common AC practices observed in on-chain contracts.

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.