September 24, 2026

Capitalizations Index – B ∞/21M

Solidity’s SMTChecker can automatically find real bugs

Solidity’s SMTChecker can automatically find real bugs

In my previous post (https://medium.com/@leonardoalt/formal-verification-in-solidity-5cbff7b7ff8) I wrote about the SMTChecker, a formal verification module embedded in Solidity’s compiler that is under development. The goal of the SMTChecker is to be a compile-time automated prover and bug finder, where properties are specified using Solidity’s require/assert.

While developing the SMTChecker we often try examples from other more stable/established formal verification tools, which we use as benchmarks for what should be supported and proved. After reading https://medium.com/ethworks/formal-verification-for-n00bs-part-3-an-attempt-to-prevent-classic-hack-with-klab-8e8d13318086, we were curious to see how the SMTChecker would perform on that example after our recent work on supporting arrays and reporting fewer false positives when SafeMath is used.

The bug analyzed here is the batch overflow vulnerability. The following code snippet is a reduced version of the full contract which contains the original function:

pragma solidity ^0.5.0;
pragma experimental SMTChecker;
import "./SafeMath.sol";
contract Bug
function batchTransfer(
address[] memory _receivers,
uint256 _value
) public whenNotPaused returns (bool)
return true;
}
}

Briefly, the bug is an overflow in the operation uint256(cnt) * _value . An attacker can choose specific _receivers and a huge _value such that cnt > 0 && cnt <= 20 is true and amount is small, such that they have enough funds. Notice that the gain is in balances[_receivers[i]].add(_value) , where _value might be much higher than it should be.

If we simply run the compiler on the example, the output (among some false positives) contains:

bug.sol:18:20: Warning: Overflow (resulting value larger than 2**256 - 1) happens here
uint256 amount = uint256(cnt) * _value;
^-------------------^
for:
<result> = 2**256
_value = 0x80 * 2**248
amount = 0
balances[msg.sender] = 0
cnt = 2
msg.sender = 2997

The run took 10.24s with 2 backend SMT solvers on my laptop. It basically tells us how to exploit the bug: call batchTransfer(_receivers, 0x80 * 2**248) , where _receivers is an array with two addresses. After the overflow, amount = 0 which satisfies balances[msg.sender] >= amount . The addresses will then receive 0x80 * 2**248 tokens each.

This example shows that the SMTChecker can be used at compile-time to quickly find real bugs, even though it still lacks support to parts of Solidity. We are constantly increasing the power of the SMTChecker, hopefully eventually making it able to fully analyze complex smart contracts automatically.

If you have any questions/ideas please reach out! You can comment here, talk to us on our Gitter channel or start a thread in the Solidity repository.

Published at Tue, 26 Feb 2019 16:12:14 +0000

Previous Article

Chinese Stock Market’s 18% Surge Should Ignite Massive Dow Comeback

Next Article

CBDC: Ukrainische Notenbank forscht an digitaler Währung

You might be interested in …

179 - thomas voegtlin: blocksize, bitcoin unlimited, asicboost and activating segwit

179 – Thomas Voegtlin: Blocksize, Bitcoin Unlimited, ASICBoost and Activating SegWit

Support the show, consider donating:BTC: 1KgnEbgUAtpmBBNKGhR7JroJBoMvEpJ5GZ (http://bit.ly/2pmi6ky)ETH: 0x8cdb49ca5103Ce06717C4daBBFD4857183f50935 (http://bit.ly/2nKneP1)

Years into the great bitcoin scaling debate no solution is in reach. Neither bigger blocks nor Segregated Witness have anywhere near consensus support. With the conflict escalating, a bitcoin fork has become a real possibility.

Topics discussed in this episode:

  • Possible outcomes include that bitcoin Unlimited gains a majority of hashing power and starts mining bigger blocks. In the event of a fork, a proof-of-work change could be done to defend the minority chain from miner attacks. And lately a proposal was brought forward to activate SegWit without the support of the hashing power.

  • Thomas Voegtlin, developer of the popular Electrum Wallet, joined us to shed light on these complex issues and share his perspective on the best way forward.
    • ASICBoost and its potential role in the conflict
    • How to split coins in case of a fork
    • How UASF could be used to activate SegWit without miner support
    • Requirements for UASF to be safe
    • How Electrum would handle a fork

Links mentioned in this episode:

Sponsors:

  • Jaxx: Wallets that Unify the Blockchain Experience Across Devices – http://jaxx.io

This episode is also available on :

Watch or listen, Epicenter is available wherever you get your podcasts.

Epicenter is hosted by Brian Fabian Crain, S?ƒbastien Couture & Meher Roy.

Fortnite 11 kill win #octanox

Fortnite 11 Kill Win #Octanox

Fortnite 11 Kill Win #Octanox VERBESSERUNGEN BITTE IN DIE KOMMENTARE 😀 ********************************************************************* 63 wins ********************************************************************* DANKE, das du dabei warst und ich hoffe du hast die Glocke aktiviert und bist nächstes mal wieder pünktlich dabei […]