The redeem
function in the YieldTokenMock
contract contains two critical vulnerabilities:
A division by zero error in the price()
function.
Missing balance validation, allowing users to redeem more tokens than they own, potentially draining the contract's funds.
Division by Zero in price()
Function
The price()
function returns 0
when totalSupply()
is 0
.
This causes a division by zero in the _burn()
calculation within the redeem
function, leading to a runtime error that halts the transaction.
Lack of Balance Validation in redeem
The redeem
function does not validate whether the user has sufficient shares to redeem the requested _amount
.
This allows users to redeem more than their proportional share of the underlying tokens, leading to a potential drain of the contract's funds.
Division by Zero Impact:
The redeem
function fails when price()
returns 0
, disrupting user operations.
Balance Validation Impact:
Malicious users can exploit this lack of validation to withdraw more than their entitled share of the underlying asset, resulting in:
Financial loss for other users.
Complete depletion of the contract's funds.
Manual code review to analyze the logic of the redeem
function and the price()
function.
Test cases in a local development environment to confirm the behavior of the vulnerabilities.
Fix Division by Zero in price()
Function:
Update the price()
function to revert if totalSupply()
is 0
:
Add Balance Validation in redeem
:
Ensure users can only redeem if they have enough shares to cover the _amount
:
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.