The user delegates rights for tokens via the create function which pulls the delegateInfo.amount amount of ERC20 tokens from the user's account via the DelegateTokenTransferHelpers.pullERC20AfterCheck function. The same amount is written at the storage:
https://github.com/code-423n4/2023-09-delegate/blob/a6dbac8068760ee4fc5bababb57e3fe79e5eeb2e/src/DelegateToken.sol#L311
Suppose there were no other deposits during the delegation period and the token was rebased such that the balance of the DelegateToken contract became less than at the start of the period. Then the user tries to withdraw tokens from the contract via withdraw (suppose the rescind function was successfully executed). The withdraw function reads the saved amount and tries transfer but throws due to insufficient balance of the DelegateToken:
Lines of code
https://github.com/code-423n4/2023-09-delegate/blob/a6dbac8068760ee4fc5bababb57e3fe79e5eeb2e/src/libraries/DelegateTokenTransferHelpers.sol#L57-L59
Vulnerability details
Proof of Concept
The user delegates rights for tokens via the
create
function which pulls thedelegateInfo.amount
amount of ERC20 tokens from the user's account via theDelegateTokenTransferHelpers.pullERC20AfterCheck
function. The same amount is written at the storage:https://github.com/code-423n4/2023-09-delegate/blob/a6dbac8068760ee4fc5bababb57e3fe79e5eeb2e/src/DelegateToken.sol#L311 Suppose there were no other deposits during the delegation period and the token was rebased such that the balance of the
DelegateToken
contract became less than at the start of the period. Then the user tries to withdraw tokens from the contract viawithdraw
(suppose therescind
function was successfully executed). Thewithdraw
function reads the saved amount and tries transfer but throws due to insufficient balance of theDelegateToken
:Tools Used
Manual review
Recommended Mitigation Steps
Consider handling the deposits in shares instead of balances to account for rebase changes on refunds.
Assessed type
ERC20