Claim airdrop repeatedly
The airdrop contract's validate function allowed a user who had already claimed their entire airdrop to reset their claimed amount to zero and claim again. An attacker could repeatedly claim tokens from the contract as long as it held a balance.
Submitted by gpersoon, also found by elprofesor, fr0zn, and pauliax
Impact
Suppose someone claims the last part of his airdrop via claimExact() of AirdropDistribution.sol Then airdrop\[msg.sender].amount will be set to 0.
Suppose you then call validate() again. The check airdrop\[msg.sender].amount == 0 will allow you to continue, because amount has just be set to 0. In the next part of the function, airdrop\[msg.sender] is overwritten with fresh values and airdrop\[msg.sender].claimed will be reset to 0.
Now you can claim your airdrop again (as long as there are tokens present in the contract)
Note: The function claim() prevents this from happening via assert(airdrop\[msg.sender].amount - claimable != 0);, which has its own problems, see other reported issues.
Proof of Concept
function claimExact(uint256 \_value) external nonReentrant {
require(msg.sender != address(0));
require(airdrop\[msg.sender].amount != 0);`
uint256 avail = _available_supply();
uint256 claimable = avail * airdrop[msg.sender].fraction / 10**18; //
if (airdrop[msg.sender].claimed != 0){
claimable -= airdrop[msg.sender].claimed;
}
require(airdrop[msg.sender].amount >= claimable); // amount can be equal to claimable
require(_value <= claimable); // _value can be equal to claimable
airdrop[msg.sender].amount -= _value; // amount will be set to 0 with the last claim
function validate() external nonReentrant {
...
require(airdrop\[msg.sender].amount == 0, "Already validated.");
...
Airdrop memory newAirdrop = Airdrop(airdroppable, 0, airdroppable, 10\*\*18 \* airdroppable / airdrop_supply);
airdrop\[msg.sender] = newAirdrop;
validated\[msg.sender] = 1; // this is set, but isn't checked on entry of this function
Recommended Mitigation Steps
Add the following to validate() : require(validated\[msg.sender]== 0, "Already validated.");
chickenpie347 (Boot Finance) confirmed and resolved:
Addressed in issue #101
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
How it worked
Root cause
Likely the validate function checked that the user's remaining airdrop amount was zero but did not check a separate 'validated' flag, so it could be called again after a full claim to reset the user's state.
What the attacker needed
A wallet eligible for the airdrop; contract holds remaining tokens
The fix
The validate function should check that the user has not already been validated before proceeding.
How it was found
- Claim the last part of the airdrop using claimExact, which sets the user's amount to zero.
- Call validate again; the check that amount equals zero passes.
- The user's airdrop record is overwritten with fresh values and claimed is reset to zero.
- Claim the airdrop again while the contract still holds tokens.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
An airdrop gives free tokens to users. The contract tracked how much each user had claimed, but a function meant to set up a new airdrop could be called again after claiming everything, resetting the record. This let the user take more tokens than they were owed.
What is Business logic?
The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.