Tool Demonstration: FSolidM for Designing Secure Ethereum Smart Contracts

Anastasia Mavridou, Aron Laszka

Abstract

Ethereum smart contracts are immutable once deployed, making security bugs catastrophic. FSolidM is a framework that allows developers to design these contracts as Finite State Machines (FSMs) through a graphical interface. By generating Solidity code from formal models and providing "one-click" security plugins, FSolidM aims to make smart contracts secure by design. This paper demonstrates the tool's architecture, its model-driven development workflow, and its ability to mitigate common vulnerabilities.

Introduction

In the Ethereum ecosystem, "code is law." While decentralization offers many benefits, the immutability of the blockchain means that bugs in deployed smart contracts are often impossible to patch. Given that these contracts frequently manage significant financial assets, they are high-stakes targets. Automated analyses suggest that over 43% of Ethereum smart contracts contain security vulnerabilities. These issues often stem from a "semantic gap"—a misalignment between a developer's conceptual model and the actual execution behavior of the Ethereum Virtual Machine (EVM). High-profile exploits, such as the $50 million DAO attack, highlight the dangers of subtle execution nuances like re-entrancy.

Methodology: Model-Driven Development

FSolidM addresses these challenges by shifting from manual coding to a Model-Driven Development (MDD) workflow. Built on the WebGME framework, the tool follows a structured process:

  1. FSM-Based Modeling: Logic is defined as a Finite State Machine with explicit states (e.g., AcceptingBids) and transitions (e.g., bid).
  2. Graphical Editor: A visual interface allows developers to drag and drop states and define transitions, ensuring a rigorous control flow.
  3. Code Generation: The tool automatically translates the FSM into a Solidity "skeleton." This generated code is read-only ("dark code") to prevent manual errors in the control logic.
  4. Security Plugins: Developers can toggle pre-built plugins to address specific vulnerabilities.
The FSolidM interface showing the graphical FSM editor alongside the generated "dark" Solidity code.

Security Plugins and Vulnerability Mitigation

A core feature of FSolidM is its modular security system. Rather than requiring developers to manually implement complex security patterns, the tool provides plugins that encapsulate expert knowledge. These plugins address critical issues such as re-entrancy (via Locking) and transaction-ordering dependencies (via Transition Counters), as well as common patterns like timed transitions and access control.

Mapping of common smart contract vulnerabilities and patterns to FSolidM's automated plugins.

Key Insights

FSolidM leverages abstraction as a security mechanism. By forcing developers to think in terms of states, it eliminates "spaghetti logic." If a transition is not explicitly modeled in the FSM, it cannot exist in the resulting code. Furthermore, the clear distinction between tool-generated control logic and user-provided business logic reduces the surface area for human error.

Case Study: Blind Auction

The utility of FSolidM is demonstrated through a Blind Auction contract. This complex process involves multiple stages—collecting bids, revealing them, determining winners, and handling withdrawals. Mapping this to an FSM provides a clear, verifiable structure that is far easier to audit than raw Solidity code. The primary result is a functional tool that provides a collaborative, version-controlled environment for smart contract design with a seamless pipeline to deployable EVM bytecode.

Limitations and Future Work

While FSolidM secures the contract's structure, it does not automatically verify the internal logic of user-defined actions. Future iterations aim to integrate formal model checkers (like nuXmv) to mathematically prove design safety and explore compositional verification for interacting contracts.

Summary updated

Abstract

Blockchain-based distributed computing platforms enable the trusted execution of computation—defined in the form of smart contracts—without trusted agents. Smart contracts are envisioned to have a variety of applications, ranging from financial to IoT asset tracking. Unfortunately, the development of smart contracts has proven to be extremely error prone. In practice, contracts are riddled with security vulnerabilities comprising a critical issue since bugs are by design non-fixable and contracts may handle financial assets of significant value. To facilitate the development of secure smart contracts, we have created the FSolidM framework, which allows developers to define contracts as finite state machines (FSMs) with rigorous and clear semantics. FSolidM provides an easy-to-use graphical editor for specifying FSMs, a code generator for creating Ethereum smart contracts, and a set of plugins that developers may add to their FSMs to enhance security and functionality.
BibTeX
@inproceedings{mavridou2018tool,
  author = {Anastasia Mavridou and Aron Laszka},
  title = {{Tool Demonstration: FSolidM for Designing Secure Ethereum Smart Contracts}},
  booktitle = {POST},
  year = {2018},
  doi = {10.1007/978-3-319-89722-6\_11},
}
Figure