Skip to content

Possible issue in ERC7579Utils.decodeBatch #5395

Open
@Amxx

Description

@Amxx

Recently, v5.2-rc.1 included a fix to a known issue in ERC7579Utils.decodeBatch. The issue was identified as originating from missing checks that solidity automatically inserts when doing a decode operation. These checks were not present in v5.2-rc.0

The way these checks are currently implemented is as follows:

  • when decoding bytes (in calldata) as an array, we check that the bytes is long enough so that all the "first-level elements" of the array fit inside the bytes. Because the array contains dynamic objects, the "first-level elements" are only pointers (offsets) to the actual elements.
  • during the decoding, it is NOT checked that the the target of the pointers falls inside the calldata bytes object. It is only when dereferencing these "pointers" that solidity checks weither they are "valid".

However, solidity does that by checking that the dereferenced object is in the calldata as defined by calldatasize. This means that the pointers could target data that is outside thebytes object while still being in allocated calldata.

This could potentially cause issues, though it is not 100% clear how this could be exploited and what the consequences would be. Currently no POC of this bad behavior exists.

Signers of ERC-7579 batch operations (usually within the scope of of an ERC-4337 user operation) should verify that the calldata they sign is properly formed. A possible adversarial senario would exist if the signer is a session key with limited access to the account. This issue, if confirmed, could potentially cause the validation and execution phases to missmatch, allowing the session key to perform restricted operations.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions