Two address tokens can be withdrawn by the admin even if they are vested
The vesting contract's withdrawOtherToken function only checks that the supplied token address differs from the vesting token address. For tokens that expose two addresses for the same underlying asset, the admin could pass the second address and withdraw funds already reserved for vesting, leaving the contract unable to pay beneficiaries.
Originally disclosed on Code4rena
Submitted by CertoraInc, also found by 0xhunter, datapunk, dipp, Lambda, and wuwe1
Two address tokens exist in the blockchain. For example, Synthetix’s ProxyERC20 contract is such a token which exists in many forms (sUSD, sBTC…). Tokens as such can be vested, but the admin can withdraw them even if they are vested by providing the other address to the withdrawOtherToken function. The only check in this function is that _otherTokenAddress != tokenAddress, which is irrelevant in the case of two address tokens.
This can make the admin be able to withdraw the vested funds and break the system, because the balance of the contract can be less than the vested amount.
Proof of Concept
- The
VTVLVestingis deployed with thesUSDcontract, using its main (proxy) address -0x57Ab1ec28D129707052df4dF418D58a2D46d5f51. - A claim is created for Alice, vesting 1000 sUSD in linear vesting. Assuming this is the only claim currently, the balance of the contract is 1000 sUSD and the value of
numTokensReservedForVestingis1000e18. - The admin calls the
withdrawOtherTokenfor 1000e18 sUSD, providing its second address -0x57Ab1ec28D129707052df4dF418D58a2D46d5f51. The value ofnumTokensReservedForVestingis still1000e18, but the balance of the contract is now 0 sUSD. - Alice waits for her vest to end, calls the withdraw function, but the function reverts on the call to
safeTransfer()because there is insufficient balance of sUSD. Alice can’t receive her funds.
Recommended Mitigation Steps
Replace the address check with a balance check - record the vesting token balance of the contract before and after the transfer and assert that they are equal.
0xean (judge) decreased severity to Medium and commented:
Downgrading to Medium. The fix is a good idea, but this is a pretty rare token implementation and definitely qualifies as an external factor.
lawrencehui (VTVL) acknowledged and commented:
Yes, agreed with @0xean that this is very rare and appreciate warden’s suggestion on the fix on balance checking.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
How it worked
Root cause
Likely the guard relies on comparing token addresses rather than checking that the vesting token balance is unchanged after the withdrawal.
Impact
The admin could withdraw funds reserved for vesting, leaving the contract balance below the vested amount and causing beneficiaries' withdrawals to fail; the judge rated this Medium because such token implementations are rare.
What the attacker needed
Admin role; vesting token with two addresses; existing vesting claim
The fix
The address check should be replaced with a balance check that records the vesting token balance before and after the transfer and asserts they are equal.
How it was found
- Deploy the vesting contract using the main proxy address of a token that has two addresses.
- Create a vesting claim for a user, so the contract holds the vested amount.
- Call withdrawOtherToken with the second address of the same token.
- The user later calls withdraw and the transfer reverts because the balance is gone.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
Some tokens, such as proxy tokens, can be reached through more than one contract address even though both point to the same balance. The contract tried to stop the admin from taking the vesting token by comparing addresses, but that comparison fails when a second address for the same token is used. The result is that money promised to users could be taken out, and their later withdrawals would fail.
What is Business logic?
The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.