Crypto Flexs
  • DIRECTORY
  • CRYPTO
    • ETHEREUM
    • BITCOIN
    • ALTCOIN
  • BLOCKCHAIN
  • EXCHANGE
  • ADOPTION
  • TRADING
  • HACKING
  • SLOT
  • CASINO
Crypto Flexs
  • DIRECTORY
  • CRYPTO
    • ETHEREUM
    • BITCOIN
    • ALTCOIN
  • BLOCKCHAIN
  • EXCHANGE
  • ADOPTION
  • TRADING
  • HACKING
  • SLOT
  • CASINO
Crypto Flexs
Home»ETHEREUM NEWS»Solidity Optimizer and ABIEncoderV2 bugs
ETHEREUM NEWS

Solidity Optimizer and ABIEncoderV2 bugs

By Crypto FlexsMarch 1, 20247 Mins Read
Facebook Twitter Pinterest LinkedIn Tumblr Email
Solidity Optimizer and ABIEncoderV2 bugs
Share
Facebook Twitter LinkedIn Pinterest Email

Solidity Optimizer and ABIEncoderV2 bug announced

Through the Ethereum bug bounty program, we have received reports of a flaw in a new experimental ABI encoder (called ABIEncoderV2). Our investigation revealed that the component has several variants of the same type. The first part of this announcement details this bug. The new ABI encoder is still marked as experimental, but since it’s already in use on mainnet, we think it’s worth announcing prominently.

Additionally, two low-impact bugs have been discovered in the optimizer over the past two weeks, one of which is fixed in Solidity v0.5.6. Both were introduced in version 0.5.5. Please see the second part of this announcement for more details.

that much 0.5.7 release Includes fixes for all bugs described in this blog post.

Any bugs mentioned here should be easily visible in tests that cover the relevant code path, at least when executed with all combinations of 0 and non-zero values.

Thanks to the Melonport team (Travis Jacobs and Jenna Zenk) and the Melon Council (Nick Munoz-McDonald, Martin Lundfall, Matt di Ferrante, and Adam Kolar) for reporting this issue through the Ethereum bug bounty program!

Who should worry?

If you have deployed contracts that use the experimental ABI Encoder V2, those contracts may be affected. This means that only contracts that use the following directives within their source code can be affected:

pragma experimental ABIEncoderV2;

Additionally, there are several requirements for a bug to occur. See technical details below for more information.

As far as we can tell, there are about 2500 contracts on the mainnet using the experimental ABIEncoderV2. It’s unclear how many of them contain bugs.

How to tell if a contract is vulnerable

The bug only appears if all of the following conditions are met:

  • Storage data associated with an array or structure is transferred directly to an external function call. abi.encode OR AND to event data without pre-assignment to a local (memory) variable
  • You have an array that contains elements that are less than 32 bytes in size, or you have a structure that has elements that share members of a storage slot or type. ByteNN Less than 32 bytes.

Additionally, your code will not be affected in the following situations:

  • If any struct or array uses: Unit256 or integer256 type
  • If you only use integer types (possibly shorter) and encode at most one array at a time.
  • If you just return that data and don’t use that data abi.encodeExternal call or event data.

If you have a contract that meets these conditions and would like to determine whether it is in fact vulnerable, you can contact us via: security@ethereum.org.

How to avoid this type of defect in the future

To be conservative about changes, experimental ABI encoders are only available when explicitly enabled, allowing people to interact with and test them without placing too much trust before they are considered stable.

We are doing our best to ensure high quality and have recently started working on ‘semantic’ fuzzing of certain parts. OSS-Fuzz (We have crash-fuzzed the compiler before, but have not tested compiler correctness).

For developers, bugs within the Solidity compiler are difficult to detect with tools such as vulnerability detectors because tools that operate on source code or AST representations do not detect defects introduced only in the compiled bytecode.

The best way to protect against these types of defects is to have a rigorous end-to-end test suite for your contracts (checking all code paths). This is because bugs in the compiler are not “silent” and are more likely to show up as incorrect errors instead. data.

possible outcome

Naturally, any bug can have very different consequences depending on the program control flow, but this is expected to be more likely to lead to malfunction than exploitability.

The bug occurs when, under certain circumstances, a method call sends corrupted parameters to another contract.

timeline

2019-03-16:

  • Report corruptions that occur when reading Boolean arrays directly from storage with the ABI encoder via the bug bounty.

From March 16, 2019 to March 21, 2019:

  • Root cause investigation, analysis of affected contracts. An unexpectedly large number of contracts compiled with experimental encoders have been found deployed on the mainnet, many of which do not have verified source code.
  • After investigating the bug, we found more ways to cause the bug, including using structs. Additionally, an array overflow bug was discovered in the same routine.
  • We checked a small number of contracts found on Github and did not find any contracts affected.
  • Bugfixes have been made to the ABI encoder.

2019-03-20:

  • We have decided to make the information public.
  • Corollary: It is impossible to detect all vulnerable contracts and contact all authors in a timely manner, and it would be good to prevent further proliferation of vulnerable contracts on the mainnet.

2019-03-26:

  • New compiler release, version 0.5.7.
  • This post has been made public.

technical details

background

Contract ABI is a specification for how data can be exchanged with a contract externally (Dapp) or when interacting between contracts. It supports many types of data, including simple values ​​such as numbers, bytes, and strings, as well as more complex data types including arrays and structures.

When a contract receives input data, it must decode that data (this is done by the “ABI Decoder”) and encode it (this is done by the “ABI Encoder”) before returning the data or sending it to another contract. The Solidity compiler generates two code snippets for each function defined in the contract: abi.encode and abi.decode). The subsystem that generates encoders and decoders in the Solidity compiler is called the “ABI encoder”.

In mid-2017, the Solidity team started working on a new implementation called “ABI Encoder V2” with the goal of having a more flexible, secure, performant, and auditable code generator. This experimental code generator has been available to users since the 0.4.19 release in late 2017, if explicitly enabled.

flaw

The experimental ABI encoder does not properly handle non-integer values ​​shorter than 32 bytes. This applies to: ByteNN category, boolean, enumeration Other types that are part of an array or structure and encoded directly in the store. This means that these repository references must be used directly internally. abi.encode(…), used as arguments for external function calls or event data without prior assignment to local variables. use return It doesn’t cause bugs. category ByteNN and boolean Doing so may damage your data. enumeration may lead to invalidation going back.

Additionally, arrays with elements shorter than 32 bytes may not be processed correctly, even if their underlying type is an integer type. Encoding such an array in the manner described above may cause other data in the encoding to be overwritten if the number of encoded elements is not a multiple of the number of elements that fit in a single slot. In encoding, if the array is followed by nothing (a dynamically sized array is always encoded after a statically sized array with statically sized content), or if only a single array is encoded, no other data is overwritten.


Two bugs were discovered in the optimizer that were not related to the ABI encoder issue described above. Both were introduced in 0.5.5 (released March 5). This problem is unlikely to occur in compiler-generated code unless inline assembly is used.

These two bugs were confirmed with the recent addition of Solidity. OSS-Fuzz – A security toolkit for finding inconsistencies or problems in various projects. For Solidity, we’ve included several Fuzzers that test different aspects of the compiler.

  1. The optimizer replaces the opcode sequence as follows: ((x << a) << b))where all and rain This is a compile-time constant. (x << (a + b)) Failure to properly handle overflow in addition.
  2. The optimizer handled it incorrectly. byte The opcode when the constant 31 is used as the second argument. This can happen when performing index access. ByteNN If the compile-time constant value (not the index) is 31, or if you use a byte opcode in inline assembly.

This post was co-written by @axic, @chriseth, and @holiman.

Share. Facebook Twitter Pinterest LinkedIn Tumblr Email

Related Posts

Is Alt Season finally here, just as Ether Lee’s tearing and a small cap follows?

August 11, 2025

Protocol Update 001 -scale L1

August 7, 2025

Stablecoins are finally legal

August 3, 2025
Add A Comment

Comments are closed.

Recent Posts

The leading RWA ecosystem player starts the RWA growth by quickly tracking the ASCEND startup accelerator.

August 13, 2025

Caldera Launches ERA Force One To Strengthen On-Chain Tokenholder Community

August 13, 2025

Encryption Inheritance Update: August 2025

August 12, 2025

Remittix Announces Beta Web3 Wallet Launch Date, Presale Passes $18.7M With CEX Listings Soon To Be Announced

August 12, 2025

How Cloud Mining Becomes An Opportunity In The Mainstream Wave

August 12, 2025

Can Remittix be the successor of ADA? Experts have a 13,000% increase.

August 12, 2025

FLOKI’s Valhalla MMORPG Storms U.S. Television With 60-Day National Commercial Blitz

August 11, 2025

A Global Initiative To Transform Crypto Education From The Ground Up

August 11, 2025

Cango Inc. Acquires 50 MW Bitcoin Mining Facility In Georgia, Laying Groundwork For Future Energy Strategy

August 11, 2025

SIM Mining Cloud Mining Allows Global Investors To Easily Earn BTC And DOGE Profits Using Just Their Smartphones (daily Income Of $23,999 USD)

August 11, 2025

MultiBank Group Delivers Record H1 Results With $209M Revenue And MBG Token Driving 7X Returns Since Launch.

August 11, 2025

Crypto Flexs is a Professional Cryptocurrency News Platform. Here we will provide you only interesting content, which you will like very much. We’re dedicated to providing you the best of Cryptocurrency. We hope you enjoy our Cryptocurrency News as much as we enjoy offering them to you.

Contact Us : Partner(@)Cryptoflexs.com

Top Insights

The leading RWA ecosystem player starts the RWA growth by quickly tracking the ASCEND startup accelerator.

August 13, 2025

Caldera Launches ERA Force One To Strengthen On-Chain Tokenholder Community

August 13, 2025

Encryption Inheritance Update: August 2025

August 12, 2025
Most Popular

Uniswap price plummets despite surging whale activity. Why?

December 27, 2024

Why is the cryptocurrency market down today? Main reasons explained

April 25, 2024

Bitcoin (BTC) shows elasticity in economic uncertainty.

April 22, 2025
  • Home
  • About Us
  • Contact Us
  • Disclaimer
  • Privacy Policy
  • Terms and Conditions
© 2025 Crypto Flexs

Type above and press Enter to search. Press Esc to cancel.