A vulnerability exists in the switchUnderlyingToken function of the UnripeFacet contract, where a timing gap between the balance check and the token switch can be exploited by a malicious user. This manipulation can lead to state inconsistencies and financial exploitation, where the non-atomic nature of the transaction can be exploited by a malicious user to increase their balance between checks. This can result in unintended gains and compromises the integrity of the underlying token switch process.
The switchUnderlyingToken function checks the underlying balance of the specified Unripe Token and then switches the underlying token in separate steps, making the transaction non-atomic.
1: Balance Check:
The function checks if the balance of the underlying tokens for the specified Unripe Token is zero.
2: Balance Manipulation:
After the balance check, the malicious user exploits the time gap to increase their balance by transferring tokens or using another function.
3: Underlying Token Switch:
The function then switches the underlying token based on the assumption that the balance was zero at the time of the check.
Malicious users can exploit the time gap between the balance check and the token switch to manipulate their balance, leading to unintended gains and compromising the integrity of the token switch process.
Manual review
The function should be made atomic, ensuring that the balance check and the underlying token switch occur in a single transaction.
Enhanced switchUnderlyingToken Function
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.