Attackathon _ Fuel Network 33181 - [Smart Contract - Insight] users messages might encode incorrect

Submitted on Sat Jul 13 2024 14:54:16 GMT-0400 (Atlantic Standard Time) by @zeroK for Attackathon | Fuel Network

Report ID: #33181

Report type: Smart Contract

Report severity: Insight

Target: https://github.com/FuelLabs/fuel-bridge/tree/e3e673e31f9e72d757d68979bb6796a0b7f9c8bc/packages/fungible-token

Impacts:

  • Permanent freezing of funds

  • Permanent freezing of unclaimed yield

  • Contract fails to deliver promised returns, but doesn't lose value

  • Griefing (e.g. no profit motive for an attacker, but damage to the users or the protocol)

  • Block stuffing

Description

Brief/Intro

the fuelERC20gateway.sol allow users to deposit tokens with/without data to L2 by calling the functions deposit and depositWithData, however we recognized that the assetIssuerID play a crusial rule in encoding the data that later used to generate message on L2, the problem arises when users call deposit or depositWthData before the admin make call to the setAssetIssuerId, this lead to encode incorrect data and pass it to L2 sequencer which may lead to return incorrect message data input.

we set this report to high because on the sway L2 part the inputs cames from the bytes that we encoded and incorrect bytes mean incorrect value on L2 sides and its possible to happen only in time gap between deployed gateway and calling the setAssetIssuerId.

Vulnerability Details

the function deposit and DepositWithData and even sendMetadata use assetIssuerID as one of the params to encode valid message data:

the problem is that the assetIssuerId is not set when the implementation initialize function get called which allow the scenario below to be possible:

  • the fuelERC20Gateway.sol deployed on ethereum and since its impl, the proxy made call to the initialize function which shown as below:

  • as shown the assetIssuerID not set in the initialize function and it depends on the admin to call the setAssetIssuerId

  • between the deploy time and calling setAssetIssuerId, any user can make deposit call or send metadata call with the assetIssuerID equal to zero bytes which this lead to create incorrect messageData which in its turn lead to two cases:

case A : the sequencers on L2 fuel not create the messageID or set it to invalid transaction since the assetIssuer not equal to the bridge address and this lead to loss of users funds.

case B: creating incorrect messageData which later used in the l2 bridge contract main.sw to get the message data value and return incorrect data.

in both cases user face lose of funds and creating incorrect message data.

Impact Details

not setting the assetIssuerID inside the initialize function might lead to lose of funds or return incorrect message data.

References

its highly recommended to set the assetIssuerID inside the Initialize function when the fuelERC20Gateway get deployed.

Proof of concept

Proof of Concept

Last updated

Was this helpful?