Skip to content

ERC777 tokensReceived() Reentrancy

Description

The tokensReceived() function in ERC777 tokens is vulnerable to reentrancy attacks, which can lead to unintended behavior and potential security risks.

Examples

Insecure Code

solidity
contract MyContract { function tokensReceived(...) { tokenContract.tokensReceived(...); } }

Secure Code

solidity
contract MyContract { function tokensReceived(...) { // Update state first; tokenContract.tokensReceived(...); } }

Remediation

Use the Checks-Effects-Interactions pattern to prevent reentrancy attacks. Ensure that all state changes are made before making external calls.

Rule Details

FieldValue
IDCODE-0108
CategoryCrypto
SeverityHIGH
CWECWE-841
ConfidenceHIGH
ImpactHIGH
LikelihoodLOW
ExploitabilityMODERATE
Tagsreentrancy, erc777
OWASPN/A

References