Submitted by Dravee, also found by thekmj, jnforja, nirlin, squeaky_cactus, xAriextz, peakbolt, Shogoki, and J4X
https://github.com/code-423n4/2023-10-ens/blob/main/contracts/ERC20MultiDelegate.sol#L148
https://github.com/code-423n4/2023-10-ens/blob/main/contracts/ERC20MultiDelegate.sol#L160
https://github.com/code-423n4/2023-10-ens/blob/main/contracts/ERC20MultiDelegate.sol#L170
https://github.com/code-423n4/2023-10-ens/blob/main/contracts/ERC20MultiDelegate.sol#L101-L115
Theres an appropriately invalidated finding found by the bots during the bot race about the unsafe use of transferFrom on non-standard ERC20 tokens. The finding is mostly invalid because, here, were using ERC20Votes tokens, not ERC20 ones; hence the mentioned tokens like USDT arent good arguments.
I would like to argue, however, that the recommendation that wouldve been true here would be to wrap the transferFrom calls in a require statement, as the transferFrom functions used in ERC20Votes are still from the inherited ERC20 interface and therefore could be returning a boolean (transferFrom(address from, address to, uint256 amount) returns bool, see OpenZeppelins implementation), instead of reverting, depending on the existence of such an ERC20Votes token. The assumption of an ERC20Votes token returning true or false instead of reverting will be used in this argumentation and be considered a possibility; especially since the list of potential ERC20Votes tokens used by this contract isnt specified (ENSToken isnt enforced). Also, see these posts from the Discord channel:
About this finding:
This finding is the second one in a series of 2 findings using a similar set of arguments, but the first is used here as a chain:
Some parts are similar between the two findings, but because they each deserved their own analysis and should fix - argumentation, they are submitted as separate findings.
Draining all ERC20Votes tokens.
Starting assumptions:
The token used as ERC20Votes returns the boolean false with transferFrom instead of reverting (not very likely implementation but still a possible and damaging edge case).
MockERC20Votes contract:
The following test/mocks/MockERC20Votes.sol file is a simplified ERC20Votes token that wraps the original transferFrom() function to return a bool instead of reverting:
The tests test_transferFromReturningTrue and test_transferFromReturningFalse are provided to showcase an example implementation of an ERC20Votes token that, instead of reverting, would return a boolean success == false. The reason for such a tokens existence wont be discussed, as the sheer possibility of its existence is the only argument that is of interest to us (and demands from customers are sometimes surprising). As yet again another reminder: the standard is still respected in this argumentation.
Foundry Setup:
Add require("@nomicfoundation/hardhat-foundry") in hardhat.config.js and run this to be able to run the POC:
Test contract:
Heres the layout of whats happening (the first 3 steps are like Bug1: test_freeMinting):
Here, were both breaking accounting (bug1) and taking advantage of approved funds to the main contract by the deployed proxies to drain all ERC20Votes tokens.
Again, this contracts security shouldnt depend on the behavior of an external ERC20Votes contract (it leaves vectors open). Hence, this is a should fix bug, meaning at least Medium severity. The token-draining part makes an argument for a higher severity.
While wrapping the transferFrom() statements in a require statement is a good idea that was suggested in the previous bug, it would also be advisable to try and enforce an invariant by checking for the sources balance inside _reimburse(), just like it is done inside _processDelegation(). Albeit, its for the ERC20MultiDelegates internal balance, and not ERC20Votess external balance check. The principle still holds and adding a check would increase security. Note that, while the existing assert() can be sidestepped, and this is detailed in another finding, it wouldnt be the case with ERC20Votess external balance due to the immediate transfer.
Token-Transfer
141345 (lookout) commented:
Arachnid (ENS) confirmed, but disagreed with severity and commented:
hansfriese (judge) decreased severity to Medium and commented:
Note: for full discussion, see here.
For this audit, 24 reports were submitted by wardens detailing low risk and non-critical issues. The report highlighted below by thekmj received the top score from the judge.
The following wardens also submitted reports: Maroutis, J4X, MiloTruck, 0x3b, radev_sw, Dravee, SBSecurity, Chom, adriro, nmirchev8, 33BYTEZZZ, btk, Limbooo, Sathish9098, adam-idarrha, Bauchibred, rvierdiiev, hyh, peakbolt, MrPotatoMagic, ZanyBonzy, Tadev, and lukejohn.
