Unauthorized Token Transfer Due To Bad Approval Mechanism #349
Labels
3 (High Risk)
Assets can be stolen/lost/compromised directly
bug
Something isn't working
duplicate-102
low quality report
This report is of especially low quality
unsatisfactory
does not satisfy C4 submission criteria; not eligible for awards
Lines of code
https://github.com/code-423n4/2023-09-ondo/blob/main/contracts/usdy/rUSDY.sol#L277
https://github.com/code-423n4/2023-09-ondo/blob/main/contracts/usdy/rUSDY.sol#L310
https://github.com/code-423n4/2023-09-ondo/blob/main/contracts/usdy/rUSDY.sol#L493
Vulnerability details
Impact
The identified issue pertains to the token transfer mechanism within a smart contract. Specifically, the contract allows a user to approve themselves for a certain amount of tokens without actually deducting this amount from their balance. Subsequently, when the user (or an approved spender) initiates a transfer, the contract deducts the allowance but fails to check and deduct the actual balance of the sender. This flaw allows any user to effectively mint tokens out of thin air, leading to a severe security vulnerability.
Proof of Concept
an attacker calls approve as he sets _spender as his address
thus allowances[attacker][attacker] = _amount;
but _amount is not deducted from _owner's balance
when he calls transferFrom currentAllowance would be allowances[attacker][attacker] which is _amount,
the _amount s transfered to _recipient, which can be his address as well,
_approve deduct the _amount from the allowance, means allowances[attacker][attacker] = 0,
while it was not deducted from _owner's balance, thus the _amount was sent from the contract's balance.
Tools Used
Manual review
Recommended Mitigation Steps
Modify the transferFrom function to not only check the allowance but also ensure that the sender has a sufficient balance. Deduct the transferred amount from the sender's balance.
Assessed type
Token-Transfer
The text was updated successfully, but these errors were encountered: