The mintRewards
function in the audited contract is vulnerable to a reentrancy attack due to improper ordering of state updates and external calls. The function performs a token transfer before updating the excessTokens
state variable. If the RAAC token supports callback functions, an attacker could exploit this by recursively calling mintRewards
, draining funds before the contract correctly updates its state.
This vulnerability bypasses the nonReentrant
modifier since the reentrant call occurs through an external contract. If exploited, it could lead to a significant loss of tokens from the contract.
Likelihood: High (depends on RAAC token behavior)
Impact: High (potential for token theft)
mintRewards
The function calls safeTransfer
before updating excessTokens
.
If the RAAC token allows callbacks, an attacker could reenter the function before the state is updated.
The attacker could recursively call mintRewards
multiple times, withdrawing excess tokens each time.
An attacker could drain excess tokens from the contract.
The contract's token balance could be reduced to zero without proper accounting.
Token holders or the protocol relying on this contract could suffer significant financial losses.
Hardhat: For setting up the test environment.
Chai/Mocha: For writing and executing test cases.
Solidity Coverage
I create a malicious RAAC token contract that implements a callback function to recursively call mintRewards
.
This confirms that an attacker can repeatedly call mintRewards
and drain funds.
Prevents reentrancy: The excessTokens
update occurs before the external call, making recursion ineffective.
Follows best practices: Uses Checks-Effects-Interactions pattern.
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.