Skip to content

ERC827: abuse of CUSTOM_CALL will cause unexpected result #1044

@p0n1

Description

@p0n1

🎉 Description

Dangerous ERC827 implementation about anythingAndCall.

https://github.com/OpenZeppelin/openzeppelin-solidity/blob/f18c3bc438b366f9cb3a8613f5be160c2cbced5e/contracts/token/ERC827/ERC827Token.sol#L46

Users are allowed to pass arbitrary data, leading to call any function with any data on any contract address.

  • 🐛 This is a bug report.
  • 📈 This is a feature request.

💻 Environment

Any contract using this ERC827 implementation or with similar CUSTOM_CALL feature will be affected.

📝 Details

It is a really bad practice to allow the abuse of CUSTOM_CALL in token standard.

<address>.call.value(msg.value)(_data)

Attackers could call any contract in the name of vulnerable contract with CUSTOM_CALL.

This vulnerability will make these attacking scenarios possible:

  • Attackers could steal almost each kind of tokens belong to the vulnerable contract [1] [2]

  • Attackers could steal almost each kind of tokens approved to the vulnerable contract

  • Attackers could bypass the auth check in vulnerable contract by proxy of contract itself in special situation [3] (edit: current openzeppelin implementation is not affected with the help of require(_to != address(this));)

  • Attackers could pass fake values as parameter to cheat with receiver contract [4]

We (SECBIT) think that the ERC827 proposal should be discussed further in community before OpenZeppelin putting the implementation in the repo. Many developers could use this code without knowledge of hidden danger.

[1] attack 1, https://etherscan.io/tx/0xb72dcc4d04381ccad416b960e95183e94ee13e942743da913cf139c8abe212e7

[2] attack 2, https://etherscan.io/tx/0x40a292d74bddaac2690385aee0c366edf31904ef681b547b1baa3190ba568888

[3] custom_call related bug, https://medium.com/@atnio/erc223-smart-contract-breach-and-resolution-vulnerability-relating-to-the-concurrent-9a402495f382

[4] pass fake values to receiver contract, ethereum/EIPs#827 (comment)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions