Assessment reports>warpdotgreen-cli>Threat Model>receiveMessage

Function: receiveMessage(byte[32], byte[3] _source_chain, byte[32] _source, byte[32][] _contents)

This function is used to receive messages from the portal contract and process them. This function transfers tokens to the receiver and the portal tip to the portal. This function is called by the portal contract.

Inputs

  • nonce

    • Control: Arbitrary.

    • Constraints: None.

    • Impact: Not used in the function.

  • _source_chain

    • Control: Arbitrary.

    • Constraints: None.

    • Impact: Source chain ID.

  • _source

    • Control: Arbitrary.

    • Constraints: None.

    • Impact: Source puzzle hash (address of sender).

  • _contents

    • Control: Arbitrary.

    • Constraints: None.

    • Impact: Message contents (asset contract, receiver, and amount).

Branches and code coverage

Intended branches

  • Update the amount using the decimals of the asset contract.

  • Calculate the transfer tip.

  • If the asset contract is not IWETH, transfer the amount to the receiver and the tip to the portal.

  • If the asset contract is IWETH, withdraw the amount and send it to the receiver and the tip to the portal.

Negative behavior

  • Revert if the message sender is not the portal.

  • Revert if the source is not the burnPuzzleHash of the contract.

  • Revert if the source chain is not the otherChain of the contract.

  • Revert if the amount is less than the transfer tip.

Function call analysis

  • ERC20Decimals(assetContract).decimals()

    • What is controllable? assetContract — it is not whitelisted.

    • If the return value is controllable, how is it used and how can it go wrong? If the decimals of the asset contract are manipulated, the amount will be calculated incorrectly.

Zellic © 2024Back to top ↑