Saturday, June 14, 2025
No Result
View All Result
DOLLAR BITCOIN
Shop
  • Home
  • Blockchain
  • Bitcoin
  • Cryptocurrency
  • Altcoin
  • Ethereum
  • Market & Analysis
  • DeFi
  • More
    • Dogecoin
    • NFTs
    • XRP
    • Regulations
  • Shop
    • Bitcoin Book
    • Bitcoin Coin
    • Bitcoin Hat
    • Bitcoin Merch
    • Bitcoin Miner
    • Bitcoin Miner Machine
    • Bitcoin Shirt
    • Bitcoin Standard
    • Bitcoin Wallet
DOLLAR BITCOIN
No Result
View All Result
Home Ethereum

Solidity Optimizer and ABIEncoderV2 Bug

n70products by n70products
December 8, 2024
in Ethereum
0
Solidity Optimizer and ABIEncoderV2 Bug
0
SHARES
0
VIEWS
Share on FacebookShare on Twitter


Solidity Optimizer and ABIEncoderV2 Bug Announcement

Via the Ethereum bug bounty program, we acquired a report a few flaw throughout the new experimental ABI encoder (known as ABIEncoderV2). Upon investigation, it was discovered that the element suffers from a number of totally different variations of the identical sort. The primary a part of this announcement explains this bug intimately. The brand new ABI encoder remains to be marked as experimental, however we nonetheless suppose that this deserves a distinguished announcement since it’s already used on mainnet.

Moreover, two low-impact bugs within the optimizer have been recognized over the previous two weeks, one among which was mounted with Solidity v0.5.6. Each had been launched with model 0.5.5. See the second a part of this announcement for particulars.

The 0.5.7 release accommodates the fixes to all bugs defined on this weblog publish.

All of the bugs talked about right here needs to be simply seen in assessments that contact the related code paths, a minimum of when run with all combos of zero and nonzero values.

Credit to Melonport staff (Travis Jacobs & Jenna Zenk) and the Melon Council (Nick Munoz-McDonald, Martin Lundfall, Matt di Ferrante & Adam Kolar), who reported this through the Ethereum bug bounty program!

Who needs to be involved

If in case you have deployed contracts which use the experimental ABI encoder V2, then these is perhaps affected. Which means solely contracts which use the next directive throughout the supply code might be affected:

pragma experimental ABIEncoderV2;

Moreover, there are a selection of necessities for the bug to set off. See technical particulars additional beneath for extra info.

So far as we will inform, there are about 2500 contracts stay on mainnet that use the experimental ABIEncoderV2. It isn’t clear what number of of them comprise the bug.

test if contract is weak

The bug solely manifests itself when all the following situations are met:

  • Storage knowledge involving arrays or structs is shipped on to an exterior operate name, to abi.encode or to occasion knowledge with out prior task to an area (reminiscence) variable AND
  • there may be an array that accommodates components with dimension lower than 32 bytes or a struct that has components that share a storage slot or members of sort bytesNN shorter than 32 bytes.

Along with that, within the following conditions, your code is NOT affected:

  • if all of your structs or arrays solely use uint256 or int256 varieties
  • should you solely use integer varieties (which may be shorter) and solely encode at most one array at a time
  • should you solely return such knowledge and don’t use it in abi.encode, exterior calls or occasion knowledge.

If in case you have a contract that meets these situations, and wish to confirm whether or not the contract is certainly weak, you may attain out to us through security@ethereum.org.

forestall these kind of flaws sooner or later

To be able to be conservative about modifications, the experimental ABI encoder has been out there solely when explicitly enabled, to permit folks to work together with it and take a look at it with out placing an excessive amount of belief in it earlier than it’s thought of secure.

We do our greatest to make sure top quality, and have not too long ago began engaged on ‘semantic’ fuzzing of sure elements on OSS-Fuzz (we’ve beforehand crash-fuzzed the compiler, however that didn’t take a look at compiler correctness).

For builders — bugs throughout the Solidity compiler are troublesome to detect with instruments like vulnerability detectors, since instruments which function on supply code or AST-representations don’t detect flaws which can be launched solely into the compiled bytecode.

The easiest way to guard in opposition to these kind of flaws is to have a rigorous set of end-to-end assessments in your contracts (verifying all code paths), since bugs in a compiler very doubtless usually are not “silent” and as an alternative manifest in invalid knowledge.

Doable penalties

Naturally, any bug can have wildly various penalties relying on this system management movement, however we anticipate that that is extra more likely to result in malfunction than exploitability.

The bug, when triggered, will underneath sure circumstances ship corrupt parameters on technique invocations to different contracts.

Timeline

2019-03-16:

  • Report through bug bounty, about corruption triggered when studying from arrays of booleans instantly from storage into ABI encoder.

2019-03-16 to 2019-03-21:

  • Investigation of root trigger, evaluation of affected contracts. An unexpectedly excessive rely of contracts compiled with the experimental encoder had been discovered deployed on mainnet, many with out verified source-code.
  • Investigation of bug discovered extra methods to set off the bug, e.g. utilizing structs. Moreover, an array overflow bug was present in the identical routine.
  • A handful of contracts discovered on Github had been checked, and none had been discovered to be affected.
  • A bugfix to the ABI encoder was made.

2019-03-20:

  • Resolution to make info public.
  • Reasoning: It might not be possible to detect all weak contracts and attain out to all authors in a well timed method, and it could be good to forestall additional proliferation of weak contracts on mainnet.

2019-03-26:

  • New compiler launch, model 0.5.7.
  • This publish launched.

Technical particulars

Background

The Contract ABI is a specification how knowledge might be exchanged with contracts from the surface (a Dapp) or when interacting between contracts. It helps quite a lot of varieties of knowledge, together with easy values like numbers, bytes and strings, in addition to extra complicated knowledge varieties, together with arrays and structs.

When a contract receives enter knowledge, it should decode that (that is finished by the “ABI decoder”) and previous to returning knowledge or sending knowledge to a different contract, it should encode it (that is finished by the “ABI encoder”). The Solidity compiler generates these two items of code for every outlined operate in a contract (and likewise for abi.encode and abi.decode). Within the Solidity compiler the subsystem producing the encoder and decoder is known as the “ABI encoder”.

In mid-2017 the Solidity staff began to work on a contemporary implementation named “ABI encoder V2” with the aim of getting a extra versatile, protected, performant and auditable code generator. This experimental code generator, when explicitly enabled, has been supplied to customers for the reason that finish of 2017 with the 0.4.19 launch.

The flaw

The experimental ABI encoder doesn’t deal with non-integer values shorter than 32 bytes correctly. This is applicable to bytesNN varieties, bool, enum and different varieties when they’re a part of an array or a struct and encoded instantly from storage. This implies these storage references have for use instantly inside abi.encode(…), as arguments in exterior operate calls or in occasion knowledge with out prior task to an area variable. Utilizing return doesn’t set off the bug. The kinds bytesNN and bool will lead to corrupted knowledge whereas enum would possibly result in an invalid revert.

Moreover, arrays with components shorter than 32 bytes might not be dealt with accurately even when the bottom sort is an integer sort. Encoding such arrays in the best way described above can result in different knowledge within the encoding being overwritten if the variety of components encoded will not be a a number of of the variety of components that match a single slot. If nothing follows the array within the encoding (notice that dynamically-sized arrays are at all times encoded after statically-sized arrays with statically-sized content material), or if solely a single array is encoded, no different knowledge is overwritten.


Unrelated to the ABI encoder difficulty defined above, two bugs have been discovered within the optimiser. Each have been launched with 0.5.5 (launched on fifth of March). They’re unlikely to happen in code generated by the compiler, except inline meeting is used.

These two bugs have been recognized by way of the current addition of Solidity to OSS-Fuzz – a safety toolkit for locating discrepancies or points in quite a lot of initiatives. For Solidity we’ve included a number of totally different fuzzers testing totally different elements of the compiler.

  1. The optimizer turns opcode sequences like ((x << a) << b)), the place a and b are compile-time constants, into (x << (a + b)) whereas not dealing with overflow within the addition correctly.
  2. The optimizer incorrectly handles the byte opcode if the fixed 31 is used as second argument. This may occur when performing index entry on bytesNN varieties with a compile-time fixed worth (not index) of 31 or when utilizing the byte opcode in inline meeting.

This publish was collectively composed by @axic, @chriseth, @holiman



Source link

Tags: ABIEncoderV2BugOptimizerSolidity
Previous Post

Two Under-the-Radar Altcoins Skyrocket in Price Following Friday Binance Listings

Next Post

Uniswap Consolidates At $17: A Calm Before The Bullish Storm?

Next Post
Uniswap Consolidates At $17: A Calm Before The Bullish Storm?

Uniswap Consolidates At $17: A Calm Before The Bullish Storm?

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Premium Content

Massive Bitcoin Options Expiry Imminent, BTC Inflows Spike

Analyst Predicts 2 Scenarios For Price Beforehand

January 9, 2024
Is Bitcoin Price In Bearish Phase? Here’s What The MVRV Ratio Says

Is Bitcoin Price In Bearish Phase? Here’s What The MVRV Ratio Says

August 18, 2024
Ethereum Network Activity Crashes, Transaction Volume Down To A Five-Month Low

Ethereum Network Activity Crashes, Transaction Volume Down To A Five-Month Low

August 9, 2024
President Trump Eliminates SAB 121, Allowing Banks To Custody Bitcoin and Crypto Assets

President Trump Eliminates SAB 121, Allowing Banks To Custody Bitcoin and Crypto Assets

January 24, 2025
This Analyst Correctly Predicted The Bitcoin Price Jump To $99,000, But His Prediction Is Not Done

This Analyst Correctly Predicted The Bitcoin Price Jump To $99,000, But His Prediction Is Not Done

November 23, 2024
WIF Jumps 19% Beyond Major Resistance Level

WIF Jumps 19% Beyond Major Resistance Level

August 7, 2024

Recent Posts

  • Time To Long Bitcoin? Market Expert Reveals When $600,000 BTC Will Happen
  • Ripple Plans To Take 14% Of SWIFT Volume, USDC Lands On XRPL – What Does This Mean For XRP Price?
  • Trump Calls Fed Chair Jerome Powell a ‘Numbskull,’ Claims Lack of Rate Cuts Are Costing US $600,000,000,000 a Year

Categories

  • Altcoin
  • Bitcoin
  • Blockchain
  • Blog
  • Cryptocurrency
  • DeFi
  • Dogecoin
  • Ethereum
  • Market & Analysis
  • NFTs
  • Regulations
  • XRP

Recommended

Time To Long Bitcoin? Market Expert Reveals When $600,000 BTC Will Happen

Time To Long Bitcoin? Market Expert Reveals When $600,000 BTC Will Happen

June 14, 2025
Ripple Plans To Take 14% Of SWIFT Volume, USDC Lands On XRPL – What Does This Mean For XRP Price?

Ripple Plans To Take 14% Of SWIFT Volume, USDC Lands On XRPL – What Does This Mean For XRP Price?

June 14, 2025

© 2023 Dollar-Bitcoin | All Rights Reserved

No Result
View All Result
  • Home
  • Blockchain
  • Bitcoin
  • Cryptocurrency
  • Altcoin
  • Ethereum
  • Market & Analysis
  • DeFi
  • More
    • Dogecoin
    • NFTs
    • XRP
    • Regulations
  • Shop
    • Bitcoin Book
    • Bitcoin Coin
    • Bitcoin Hat
    • Bitcoin Merch
    • Bitcoin Miner
    • Bitcoin Miner Machine
    • Bitcoin Shirt
    • Bitcoin Standard
    • Bitcoin Wallet

© 2023 Dollar-Bitcoin | All Rights Reserved

Are you sure want to unlock this post?
Unlock left : 0
Are you sure want to cancel subscription?
Go to mobile version