ReEntrancy with multiple coordinating malicious cTokensSee original GitHub issue
The borrowFresh and redeemFresh functions transfer tokens out of the protocol before updating internal accounting. This is a reentrancy vulnerability for tokens that define a malicious
transfer function. The cToken contract has a reentrancy guard for this purpose. However, if multiple malicious tokens coordinate, the reentrancy guards on individual tokens are not sufficient to prevent the comptroller from reading stale liquidity data when checking these transfers.
Compound governance has been diligent in not listing malicious tokens, but the contracts should be fixed for the future.
The fix is to simply move the
doTransferOut call to after internal accounting in the affected functions.
This flaw was discovered by DeFiPie, an independent deployment of the Compound Protocol.
- Created 2 years ago
- Comments:9 (5 by maintainers)
Top GitHub Comments
https://twitter.com/CreamdotFinance/status/1432249771750686721 this flaw has been exploited in a second Compound fork
@llama There is one main subtlety I think you are missing: no individual cToken is ever reentered. cToken A calls into Token B which calls cTokenB which calls token C which calls cToken C which finally calls into a real token with actual value.