Anyone Can Arbitrarily Call FSDVesting.updateVestedTokens()
The updateVestedTokens() function in FSDVesting.sol lacks a check that the caller is the trusted FSD.sol contract, and the _user argument is user-controlled, so anyone can call it to arbitrarily increase a user's vested token amount. This allows an attacker to either withdraw more tokens early or block legitimate withdrawals by causing safeTransfer() to fail due to insufficient balance.
Submitted by leastwood, also found by cmichel, hickuphh3, hyh, rfa, and WatchPug
Impact
The updateVestedTokens() function is intended to be called by the FSD.sol contract when updating a user’s vested token amount. A check is performed to ensure that _user == beneficiary, however, as _user is a user controlled argument, it is possible to spoof calls to updateVestedTokens() such that anyone can arbitrarily add any amount to the vested contract. Additionally, there is no check to ensure that the call originated from a trusted/whitelisted source.
There are two main reasons as to why the beneficiary or an attacker would want to call this function:
- To increase the vested amount such that
calculateVestingClaim()allows them to withdraw their entire vested amount without waiting the entire duration. - An attacker wishes to block withdrawals from other vested contracts by preventing successful calls to
claimVestedTokens()by the beneficiary account. This can be done by increasing the vested amount such thatsafeTransfer()calls fail due to insufficient token balance within the contract.
Proof of Concept
- https://github.com/code-423n4/2021-11-fairside/blob/main/contracts/token/FSDVesting.sol#L147-L161
- https://github.com/code-423n4/2021-11-fairside/blob/main/contracts/token/FSDVesting.sol#L100-L115
- https://github.com/code-423n4/2021-11-fairside/blob/main/contracts/token/FSDVesting.sol#L125
- https://github.com/code-423n4/2021-11-fairside/blob/main/contracts/token/FSDVesting.sol#L134
Tools Used
Manual code review. Discussions with dev.
Recommended Mitigation Steps
Ensure that the updateVestedTokens() function is only callable from the FSD.sol contract. This can be done by implementing an onlyFSD role.
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
The function updateVestedTokens() lacks an access control check to ensure the caller is the trusted FSD.sol contract, and it uses a user-supplied _user parameter to determine the beneficiary.
Impact
An attacker could increase the vested amount to withdraw more tokens early or block legitimate withdrawals by causing safeTransfer() to fail due to insufficient balance.
What the attacker needed
None
The fix
The updateVestedTokens() function should be restricted to be callable only from the FSD.sol contract, for example by implementing an onlyFSD role.
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.
A smart contract has a function that is supposed to be called only by another specific contract to update how many tokens a user has vested. Because the function does not check who is calling and lets the caller specify any user, anyone can call it and set a huge vested amount. This can let them take more tokens than they should or stop the real user from withdrawing.
What is Access control?
A user can do something their role should not allow: reach an admin function, act on a feature they have not paid for, or skip a permission check. IDOR is the special case where the object belongs to someone else.