BriVault

First Flight #52
Beginner FriendlySolidity
100 EXP
View results
Submission Details
Impact: low
Likelihood: low
Invalid

Missing check on on stakedAsset

Root + Impact

Description

  • Should be checked if stakedAsset <> 0. This checks does not avoid errors but avoid unnecesary gas consumption.

/**
@dev cancel participation
*/
function cancelParticipation () public {
if (block.timestamp >= eventStartDate){
revert eventStarted();
}
@> missing check on stakedAsset[msg.sender] <> 0
uint256 refundAmount = stakedAsset[msg.sender];
stakedAsset[msg.sender] = 0;
uint256 shares = balanceOf(msg.sender);
_burn(msg.sender, shares);
IERC20(asset()).safeTransfer(msg.sender, refundAmount);
}
// Root cause in the codebase with @> marks to highlight the relevant section

Risk

Likelihood:

  • High. Each time the user decide to cancel the participation

Impact:

  • The impact is low. Only in gas consumption

Recommended Mitigation

function cancelParticipation () public {
if (block.timestamp >= eventStartDate){
revert eventStarted();
}
+ if (stakedAsset[msg.sender] == 0) {
+ revert depositNotDone();
+ }
uint256 refundAmount = stakedAsset[msg.sender];
stakedAsset[msg.sender] = 0;
uint256 shares = balanceOf(msg.sender);
_burn(msg.sender, shares);
IERC20(asset()).safeTransfer(msg.sender, refundAmount);
}
Updates

Appeal created

bube Lead Judge 19 days ago
Submission Judgement Published
Invalidated
Reason: Non-acceptable severity
Assigned finding tags:

Gas optimizations

Gas optimizations are invalid according to the CodeHawks documentation.

Support

FAQs

Can't find an answer? Chat with us on Discord, Twitter or Linkedin.

Give us feedback!