Beginner FriendlyFoundryNFT
100 EXP
View results
Submission Details
Severity: high
Invalid

No bet value check on `RapBattle::goOnStageOrBattle`, leading to bets with a value of 0.

  • Description:

    • The protocol design allows only one battle at a time. So, a user can call RapBattle::goOnStageOrBattle constantly betting 0 Cred and blocking other users to battle

    • Impact:

      • Break the Rap Battle functionality in the RapBattle::goOnStageOrBattle function.

    • Proof of Concept:

      Add the following code to `OneShotTest.t.sol`
      function testPoCGoOnStage() public mintRapper {
      vm.startPrank(user);
      oneShot.approve(address(rapBattle), 0);
      rapBattle.goOnStageOrBattle(0, 0);
      address defender = rapBattle.defender();
      assert(defender == address(user));
      }
    • Recommendation:

      See the code recommendation below
      function goOnStageOrBattle(uint256 _tokenId, uint256 _credBet) external {
      + if(_credBet < 1){
      + revert RapBattle__YouMustPutYourCredInTheLine();
      + }
      if (defender == address(0)) {
      defender = msg.sender;
      defenderBet = _credBet;
      defenderTokenId = _tokenId;
      emit OnStage(msg.sender, _tokenId, _credBet);
      oneShotNft.transferFrom(msg.sender, address(this), _tokenId);
      credToken.transferFrom(msg.sender, address(this), _credBet);
      } else {
      // credToken.transferFrom(msg.sender, address(this), _credBet);
      _battle(_tokenId, _credBet);
      }
      }
Updates

Lead Judging Commences

inallhonesty Lead Judge over 1 year ago
Submission Judgement Published
Invalidated
Reason: Design choice

Support

FAQs

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