Open c4-submissions opened 1 year ago
0xfoobar (sponsor) acknowledged
Noted, this is not a bug in DelegateToken but will be have to be accounted for in integrating protocols
0xfoobar marked the issue as disagree with severity
GalloDaSballo changed the severity to QA (Quality Assurance)
Agree with both sides, downgrading to QA Low Severity as a Gotcha
GalloDaSballo marked the issue as grade-b
Manually awarding B as notable gotcha to integrators
Lines of code
https://github.com/code-423n4/2023-09-delegate/blob/a6dbac8068760ee4fc5bababb57e3fe79e5eeb2e/src/DelegateToken.sol#L398-L408
Vulnerability details
Impact
an attacker can show up as having double the amount of ERC20/ERC1155 to an application that relies on delegate.xyz delegates + wallet balance. This can be a critical problem for many type of systems, for example a governance protocol that allows users to delegate their gov Token through delegate.xyz and to determine the voting power of a specific user it will count the gov tokens in his wallet + all the tokens delegated. Notice also that this exploit can not be mitigated from the application that integrates with delegate.xyz as there is no way for an external contract to determine if a specific user's wallet balance is coming from a flashloan or not, thus this should be categorized as a fundamental flaw of the protocol.
Details
the exploit is possible because during a flashloan, the delegation is still considered valid so an attacker can effectively "double spend" his delegation.
Proof of Concept
as a PoC I will expand the previous example of a governance protocol, to run it you can place this in the
/test/DelegateToken.t.sol
test.output:
Tools Used
manual review
Recommended Mitigation Steps
while a user is calling a flashloan, temporarily revoke his original delegation until the flashloan is not finished
Assessed type
Other