The addUnderlying
function in the Beanstalk protocol uses the transferFrom
method to move barnRaiseToken
from
the user's address to the contract. However, the function does not validate the success of this operation, which can lead to unhandled exceptions if the token transfer fails. This could result in partial execution of the function, where some state changes are committed while others are not, potentially leading to inconsistent state.
The ```transferFrom`` function is used to transfer tokens on behalf of users, which requires prior approval.
The ERC-20 standard does not mandate transferFrom
to return a boolean indicating success, and failing silently is common in many token
implementations. In the context of Beanstalk's addUnderlying
function, failure to handle these potential exceptions can disrupt the transaction flow, leading to failure in minting or adding liquidity as intended.
If transferFrom
doesn't revert upon failure, the addUnderlying
function will continue to execute, potentially resulting in an approval being granted without the corresponding transfer.
This will also lead to a cascading effect on the rest of addUnderlying's logic.
Manual Review
To mitigate this issue, Beanstalk should implement a check to ensure that the transferFrom operation is successful.
Use Openzeppelin's safeTransferFrom library.
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.