A large amount of CredTokens can be minted by calling CredToken::mint
after CredToken contract deployment, but prior to deployment script's call to CredToken::setStreetsContract
The private storage variable _streetsContract
in CredToken has a default value of 0 since it is of address type. An attacker can take advantage of this default value by calling CredToken::mint
using address(0) in a very specific timeframe between the deployment of the CredToken contract and the calling of CredToken::setStreetsContract
within a deployment script. The attack would consist of minting maximum possible amount of CredTokens as address(0) and then transfering them to another address.
Note: This vulnerability also exists for the OneShot contract, but the only impact is that an attacker using address(0) could call OneShot::updateRapperStats
function, which would be minimal impact.
Severity is judged as Medium, with impact being High and likelihood being hard to evaluate as a deployment script was not provided and therefore could not be examined for proper deployment of the OneShot set of smart contracts.
Visual Studio Code, Foundry, manual review
To show how this attack could be executed, take the following steps.
1 . To simulate the uninitialized pre-condition needed for the attack, alter OneShotTest::setUp
to not call CredToken::setStreetsContract
Add the following test function to OneShotTest
:
Execute the test and see that it passes - meaning that all possible CredTokens have been minted and sent to the attacker's intended recipient address.
It is recommended to place a check in CredToken::mint
for address(0) as shown below:
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.