The RAACToken::burn
function incorrectly calculates the amount to be burned when the feeCollector
is set to the zero address. Instead of burning the entire specified amount, the function only burns amount - taxAmount
, leading to unintended behavior and leaving tokens in the user's balance that should have been removed.
The burn
function applies a burn tax calculated as amount.percentMul(burnTaxRate)
.
The function then burns only amount - taxAmount
and, if taxAmount > 0
, attempts to transfer the tax amount to feeCollector
.
If feeCollector
is set to the zero address, the tax transfer does not occur, but the deducted taxAmount
is also not burned, leaving an unintended residual balance in the user's account.
Below is a PoC demonstrating the issue, with added comments for clarity:
Code Reference: https://github.com/Cyfrin/2025-02-raac/blob/89ccb062e2b175374d40d824263a4c0b601bcb7f/contracts/core/tokens/RAACToken.sol#L80
Incorrect Token Burning: Users attempting to burn their entire balance may still have leftover tokens due to tax miscalculations.
Manual Review
To fix the issue, modify the burn
function to ensure that all tokens are properly burned, even if the feeCollector
is the zero address. The updated function should look like this:
This ensures:
If feeCollector
is not the zero address, the tax is transferred correctly.
If feeCollector
is the zero address, the entire amount is burned.
By implementing this fix, the contract will maintain its expected behavior and properly handle token burning in all cases.
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.