Farseen0/scar-pairs huggingface dataset:
MEDIUM severity: The vulnerability lies in the lack of validation of the selling token within the Curve adaptors, whi. The vulnerability lies in the lack of validation of the selling token within the Curve adaptors, which allows malicious users to sell reward tokens or Convex deposit tokens under certain conditions. Specifically, the `EXACT_IN_BATCH` trade function does not restrict the `data.route` to only the prim...

Vulnerable code:
```\nFile: CurveV2Adapter.sol\n\nfunction getExecutionData(address from, Trade calldata trade)\n    internal\n    view\n    returns (\n        address spender,\n        address target,\n        uint256 msgValue,\n        bytes memory executionCallData\n    )\n{\n    if (trade.tradeType == TradeType.EXACT_IN_SINGLE) {\n        CurveV2SingleData memory data = abi.decode(trade.exchangeData, (CurveV2SingleData));\n        executionCallData = abi.encodeWithSelector(\n            ICurveRouterV2.exchange.selector,\n            data.pool,\n            _getTokenAddress(trade.sellToken),\n            _getTokenAddress(trade.buyToken),\n            trade.amount,\n            trade.limit,\n            address(this)\n        );\n    } else if (trade.tradeType == TradeType.EXACT_IN_BATCH) {\n        CurveV2BatchData memory data = abi.decode(trade.exchangeData, (CurveV2BatchData));\n        address[4] memory pools;\n        executionCallData = abi.encodeWithSelector(\n            ICurveRouterV2.exchange_multiple.selector,\n            data.route,\n            data.swapParams,\n            trade.amount,\n            trade.limit,\n            pools,\n            address(this)\n        );\n    }\n```\n```\nFile: CurveAdapter.sol\n\nfunction _exactInBatch(Trade memory trade) internal view returns (bytes memory executionCallData) {\n    CurveBatchData memory data = abi.decode(trade.exchangeData, (CurveBatchData));\n\n    return abi.encodeWithSelector(\n        ICurveRouter.exchange.selector,\n        trade.amount,\n        data.route,\n        data.indices,\n        trade.limit\n    );\n}\n```\n```\nFile: TradingUtils.sol\n\nfunction _approve(Trade memory trade, address spender) private {\n    uint256 allowance = _isExactIn(trade)? trade.amount : trade.limit;\n    address sellToken = trade.sellToken;\n    if (sellToken == Constants.ETH_ADDRESS) {\n        sellToken = address(Deployments.WETH);\n    }\n    IERC20(sellToken).approve(spender, allowance);\n}\n```
MEDIUM severity: The `validateOrderParam` function in the Exchange contract is responsible for verifying the signatur. The `validateOrderParam` function in the Exchange contract is responsible for verifying the signature and version of a provided order. However, instead of checking the order version against the contract's `SUPPORTED_ORDER_VERSION` constant, it directly checks against a hardcoded value of `2` within...

Vulnerable code:
```\nfunction validateOrderParam(\n    IPerpetual perpetual,\n    LibOrder.OrderParam memory orderParam\n) \ninternal\nview\nreturns (bytes32) {\n    address broker = perpetual.currentBroker(orderParam.trader);\n    require(broker == msg.sender, "invalid broker");\n    require(orderParam.getOrderVersion() == 2, "unsupported version");\n    require(orderParam.getExpiredAt() >= block.timestamp, "order expired");\n\n    bytes32 orderHash = orderParam.getOrderHash(address(perpetual), broker);\n    require(orderParam.signature.isValidSignature(orderHash, orderParam.trader), "invalid signature");\n    require(filled[orderHash] < orderParam.amount, "fullfilled order");\n\n    return orderHash;\n}\n```
MEDIUM severity: The `verifyNonce` function in the VotingMachine smart contract is vulnerable to a nonce replay attac. The `verifyNonce` function in the VotingMachine smart contract is vulnerable to a nonce replay attack. This function is responsible for verifying the nonce submitted by a relayer when a voter submits a vote. The nonce is checked against the previous nonce saved for that voter to ensure that the vote...

Vulnerable code:
```\nfunction verifyNonce(uint256 _proposalId, address _voter, uint256 _relayerNonce) public view {\n    Proposal storage _proposal = proposals[_proposalId];\n    require(_proposal.voters[_voter].nonce < _relayerNonce, "INVALID_NONCE");\n}\n```\n```\nvoter.nonce = voter.nonce.add(1)\n```
MEDIUM severity: The vulnerability in the ConvexSpell/CurveSpell.openPositionFarm function lies in its handling of th. The vulnerability in the ConvexSpell/CurveSpell.openPositionFarm function lies in its handling of the `borrowBalance` variable. Specifically, the function may revert in certain cases when attempting to add liquidity to the Curve pool. This occurs when the `borrowBalance` is smaller than the actual b...

Vulnerable code:
```\nFile: blueberry-core\contracts\spell\CurveSpell.sol\n\n    // 2. Borrow specific amounts\n    uint256 borrowBalance = _doBorrow(\n        param.borrowToken,\n        param.borrowAmount\n    );\n\n    // 3. Add liquidity on curve\n    address borrowToken = param.borrowToken;\n    _ensureApprove(param.borrowToken, pool, borrowBalance);\n\n    if (tokens.length == 2) {\n        uint256[2] memory suppliedAmts;\n        for (uint256 i = 0; i < 2; i++) {\n            if (tokens[i] == borrowToken) {\n                suppliedAmts[i] = IERC20Upgradeable(tokens[i]).balanceOf(\n                    address(this)\n                );\n                break;\n            }\n        }\n        ICurvePool(pool).add_liquidity(suppliedAmts, minLPMint);\n    } else if (tokens.length == 3) {\n```
MEDIUM severity: The vulnerability arises from the fact that the private key associated with an EMPAM auction is not . The vulnerability arises from the fact that the private key associated with an EMPAM auction is not submitted before the auction can be settled. This allows for potential griefing scenarios, particularly in cases where the private key is held by the seller or a key management solution is used. Witho...

Vulnerable code:
```\nfunction claimBids(\n    uint96 lotId_,\n    uint64[] calldata bidIds_\n)\n    external\n    override\n    onlyInternal\n    returns (BidClaim[] memory bidClaims, bytes memory auctionOutput)\n{\n    // Standard validation\n    _revertIfLotInvalid(lotId_);\n    _revertIfLotNotSettled(lotId_);\n}\n```\n```\nfunction refundBid(\n    uint96 lotId_,\n    uint64 bidId_,\n    address caller_\n) external override onlyInternal returns (uint96 refund) {\n    _revertIfLotInvalid(lotId_);\n    _revertIfBeforeLotStart(lotId_);\n    _revertIfBidInvalid(lotId_, bidId_);\n    _revertIfNotBidOwner(lotId_, bidId_, caller_);\n    _revertIfBidClaimed(lotId_, bidId_);\n    _revertIfLotConcluded(lotId_);\n}\n```\n```\nfunction _cancelAuction(uint96 lotId_) internal override {\n    _revertIfLotActive(lotId_);\n}\n```\n```\nfunction cancelAuction(uint96 lotId_) external override onlyInternal {\n    _revertIfLotInvalid(lotId_);\n    _revertIfLotConcluded(lotId_);\n}\n```\n```\nfunction _settle(uint96 lotId_)\n    internal\n    override\n    returns (Settlement memory settlement_, bytes memory auctionOutput_)\n{\n    if (auctionData[lotId_].status!= Auction.Status.Decrypted) {\n        revert Auction_WrongState(lotId_);\n    }\n    // Settle the auction\n```
MEDIUM severity: This vulnerability occurs when a delegation request is rejected, and the previous status of some tok. This vulnerability occurs when a delegation request is rejected, and the previous status of some tokens is not properly maintained. Specifically, if some tokens are initially locked and the rest are unlocked, they are incorrectly treated as locked after the rejection. This issue arises from the way...

Vulnerable code:
```\nif (_purchased[delegation.holder] > 0) {\n    _isPurchased[delegationId] = true;\n    if (_purchased[delegation.holder] > delegation.amount) {\n        _purchased[delegation.holder] -= delegation.amount;\n    } else {\n        _purchased[delegation.holder] = 0;\n    }\n} else {\n    _isPurchased[delegationId] = false;\n}\n```\n```\nfunction _cancel(uint delegationId, DelegationController.Delegation memory delegation) internal returns (State state) {\n    if (_isPurchased[delegationId]) {\n        state = purchasedProposedToPurchased(delegationId, delegation);\n    } else {\n        state = proposedToUnlocked(delegationId);\n    }\n}\n```
MEDIUM severity: The `OrderStatus` enum is defined with four possible values: `EXPIRED`, `CANCELLED`, `FILLABLE`, and. The `OrderStatus` enum is defined with four possible values: `EXPIRED`, `CANCELLED`, `FILLABLE`, and `FULLY_FILLED`. However, despite its declaration, the `OrderStatus` enum is not utilized anywhere in the code. This suggests that the intended functionality or logic related to order status tracking...

Vulnerable code:
```\nenum OrderStatus {\n    EXPIRED,\n    CANCELLED,\n    FILLABLE,\n    FULLY_FILLED\n}\n```
MEDIUM severity: The vulnerability allows an attacker to manipulate secondary market rates by exploiting the lack of . The vulnerability allows an attacker to manipulate secondary market rates by exploiting the lack of triggering the `penrose.reAccrueBigBangMarkets()` function when leveraging. This function is responsible for recalculating interest rates for non-ETH markets based on the current debt in the ETH marke...

Vulnerable code:
```\nfunction reAccrueBigBangMarkets() external notPaused {\n    if (msg.sender == bigBangEthMarket) {\n        _reAccrueMarkets(false);\n    }\n}\n\nfunction _reAccrueMarkets(bool includeMainMarket) private {\n    uint256 len = allBigBangMarkets.length;\n    address[] memory markets = allBigBangMarkets;\n    for (uint256 i = 0; i < len; i++) {\n        address market = markets[i];\n        if (isMarketRegistered[market]) {\n            if (includeMainMarket || market!= bigBangEthMarket) {\n                IBigBang(market).accrue();\n            }\n        }\n    }\n\n    emit ReaccruedMarkets(includeMainMarket);\n}\n```\n```\nfunction buyCollateral(address from, uint256 borrowAmount, uint256 supplyAmount, bytes calldata data)\n    external\n    optionNotPaused(PauseType.LeverageBuy)\n    solvent(from, false)\n    notSelf(from)\n    returns (uint256 amountOut)\n{\n    {\n        (, uint256 borrowShare) = _borrow(\n            calldata_.from,\n            address(this),\n            borrowAmount,\n            _computeVariableOpeningFee(borrowAmount)\n        );\n        (memoryData.borrowShareToAmount, ) = yieldBox.withdraw(assetId, address(this), address(leverageExecutor), 0, borrowShare);\n    }\n}\n```
MEDIUM severity: The `_calculatePendingRewards` function is vulnerable to running out of gas due to an inefficient im. The `_calculatePendingRewards` function is vulnerable to running out of gas due to an inefficient implementation of reward rate updates. The function iterates over all historical changes to the reward rate, which can lead to a significant increase in gas consumption if the reward rate has been updat...

Vulnerable code:
```\nfunction setRewardRate(uint256 rewardRate)\n    public\n    virtual\n    override\n    returns (bool success)\n{\n    require(rewardRate <= _valueDivisor.mul(100), "ST17");\n    require(hasRole(DEFAULT_ADMIN_ROLE, _msgSender()), "ST2");\n    _rewardRate.push(rewardRate);\n    _lastMovingRewardTimestamp.push(block.timestamp);\n    emit SetRewardRate(rewardRate);\n\n    return true;\n}\n```
MEDIUM severity: The vulnerability allows signers to manipulate the safe's ownership structure by adding an unlimited. The vulnerability allows signers to manipulate the safe's ownership structure by adding an unlimited number of additional signers, effectively bricking the safe. This is achieved by exploiting the lack of checks in the `execTransaction` function, which allows new owners to be added without verifying...

Vulnerable code:
```\nif (safe.getThreshold()!= _getCorrectThreshold()) {\n    revert SignersCannotChangeThreshold();\n}\n\nfunction _getCorrectThreshold() internal view returns (uint256) {\n    uint256 count = _countValidSigners(safe.getOwners());\n    uint256 min = minThreshold;\n    uint256 max = targetThreshold;\n    if (count < min) {\n        _threshold = min;\n    } else if (count > max) {\n        _threshold = max;\n    } else {\n        _threshold = count;\n    }\n}\n```\n```\nif (validSignerCount > maxSigners) {\n    revert MaxSignersReached();\n}\n```
MEDIUM severity: This vulnerability allows an attacker to manipulate the liquidation process by adding collateral in . This vulnerability allows an attacker to manipulate the liquidation process by adding collateral in advance, thereby causing the liquidator to lose premium. The vulnerability arises when a position has a debt ratio greater than or equal to 1e18, and the start liquidation timestamp is non-zero. In th...

Vulnerable code:
```\nuint deltaTime;\n\nif (pos.startLiqTimestamp > 0) {\n    deltaTime = Math.max(deltaTime, block.timestamp - pos.startLiqTimestamp);\n}\n\nif (block.timestamp > pos.positionDeadline) {\n    deltaTime = Math.max(deltaTime, block.timestamp - pos.positionDeadline);\n}\n\nuint timeDiscountMultiplierE18 = Math.max(\n    IConfig(config).minLiquidateTimeDiscountMultiplierE18(),\n    ONE_E18 - deltaTime * IConfig(config).liquidateTimeDiscountGrowthRateE18()\n);\n\nuint curHealthFactorE18 = (ONE_E18 * ONE_E18) / getPositionDebtRatioE18(_positionManager, _user, _posId);\nuint minDesiredHealthFactorE18 = IConfig(config).minDesiredHealthFactorE18s(strategy);\n\nuint healthDiscountMultiplierE18 = ONE_E18;\nif (curHealthFactorE18 < ONE_E18) {\n    healthDiscountMultiplierE18 = curHealthFactorE18 > minDesiredHealthFactorE18\n       ? ((curHealthFactorE18 - minDesiredHealthFactorE18) * ONE_E18) / (ONE_E18 - minDesiredHealthFactorE18)\n        : 0;\n}\n\nliquidationDiscountMultiplierE18 = (timeDiscountMultiplierE18 * healthDiscountMultiplierE18) / ONE_E18;\n```
MEDIUM severity: The system's design allows for unpredictable behavior due to the ability of administrators to update. The system's design allows for unpredictable behavior due to the ability of administrators to update or upgrade system components without warning. This can lead to a violation of a security goal, as privileged roles could exploit this feature to make malicious changes just ahead of incoming transact...

Vulnerable code:
```\nfunction setSignerFeeDivisor(uint256 _signerFeeDivisor)\n    external\n    onlyOwner\n{\n    require(_signerFeeDivisor > 9, "Signer fee divisor must be greater than 9, for a signer fee that is <= 10%.");\n    signerFeeDivisor = _signerFeeDivisor;\n    emit SignerFeeDivisorUpdated(_signerFeeDivisor);\n}\n```\n```\n/**\n * @dev Upgrade current implementation.\n * @param _implementation Address of the new implementation contract.\n */\nfunction upgradeTo(address _implementation)\n    public\n    onlyOwner\n{\n    address currentImplementation = implementation();\n    require(_implementation!= address(0), "Implementation address can't be zero.");\n    require(_implementation!= currentImplementation, "Implementation address must be different from the current one.");\n    setImplementation(_implementation);\n    emit Upgraded(_implementation);\n}\n```\n```\nfunction upgradeTo(address _implementation) public onlyOwner {\n    address currentImplementation = implementation();\n    require(\n        _implementation!= address(0),\n        "Implementation address can't be zero."\n    );\n    require(\n        _implementation!= currentImplementation,\n        "Implementation address must be different from the current one."\n    );\n    setImplementation(_implementation);\n    emit Upgraded(_implementation);\n}\n```\n```\nfunction registerFactory(address payable _factory) external onlyOperatorContractUpgrader {\n    require(_factory!= address(0), "Incorrect factory address");\n    require(\n        registry.isApprovedOperatorContract(_factory),\n        "Factory contract is not approved"\n    );\n    keepFactory = _factory;\n}\n```
MEDIUM severity: The `getAmountsForDelta` function in the `Underlying.sol` contract is responsible for calculating th. The `getAmountsForDelta` function in the `Underlying.sol` contract is responsible for calculating the quantities of `token0` and `token1` to add to a position based on a given delta of liquidity. This calculation depends on the delta of liquidity, the current tick, and the ticks of the range boundar...

Vulnerable code:
```\nif (sqrtRatioX96 <= sqrtRatioAX96) {\n    amount0 = SafeCast.toUint256(\n        SqrtPriceMath.getAmount0Delta(\n            sqrtRatioAX96,\n            sqrtRatioBX96,\n            liquidity\n        )\n    );\n}\n```\n```\nif (_slot0.tick < params.tickLower) {\n    amount0 = SqrtPriceMath.getAmount0Delta(\n        TickMath.getSqrtRatioAtTick(params.tickLower),\n        TickMath.getSqrtRatioAtTick(params.tickUpper),\n        params.liquidityDelta\n    );\n}\n```
MEDIUM severity: The `doCutRewardsFee` function, responsible for processing ICHI rewards collected through farming, c. The `doCutRewardsFee` function, responsible for processing ICHI rewards collected through farming, contains a critical flaw. Specifically, it utilizes the `depositFee` instead of the intended `withdrawFee` when calculating the fee to be transferred to the treasury. This oversight may lead to incorre...

Vulnerable code:
```\nfunction doCutRewardsFee(address token) internal {\n    if (bank.config().treasury() == address(0)) {\n        revert NO_TREASURY_SET();\n    }\n\n    uint256 balance = IERC20Upgradeable(token).balanceOf(address(this));\n    if (balance > 0) {\n        uint256 fee = (balance * bank.config().depositFee()) / DENOMINATOR;\n        IERC20Upgradeable(token).safeTransfer(\n            bank.config().treasury(),\n            fee\n        );\n\n        balance -= fee;\n        IERC20Upgradeable(token).safeTransfer(bank.EXECUTOR(), balance);\n    }\n}\n```
MEDIUM severity: The vulnerability allows an attacker to destroy user voting power by exploiting a discrepancy in the. The vulnerability allows an attacker to destroy user voting power by exploiting a discrepancy in the `ERC721Power` contract's logic. Specifically, the attacker can set the `totalPower` variable and the `currentPower` of all existing NFTs to 0 by manipulating the `recalculateNftPower` function.\n\nTh...

Vulnerable code:
```\nfunction recalculateNftPower(uint256 tokenId) public override returns (uint256 newPower) {\n    if (block.timestamp < powerCalcStartTimestamp) {\n        return 0;\n    }\n    newPower = getNftPower(tokenId);\n\n    NftInfo storage nftInfo = nftInfos[tokenId];\n\n    totalPower -= nftInfo.lastUpdate!= 0? nftInfo.currentPower : getMaxPowerForNft(tokenId);\n    totalPower += newPower;\n\n    nftInfo.lastUpdate = uint64(block.timestamp);\n    nftInfo.currentPower = newPower;\n}\n\nfunction getNftPower(uint256 tokenId) public view override returns (uint256) {\n    if (block.timestamp <= powerCalcStartTimestamp) {\n        return 0;\n    }\n}\n```
MEDIUM severity: The TOFTOptionsReceiverModule::exerciseOptionsReceiver module is responsible for facilitating the ex. The TOFTOptionsReceiverModule::exerciseOptionsReceiver module is responsible for facilitating the exchange of `mTOFT` and `tapOFT` tokens across different blockchain networks. When a user initiates a token exercise, the module ensures that the amount of `tapOFT` tokens sent to the user on the desire...

Vulnerable code:
```\nuint256 amountToSend = _send.amountLD > _options.tapAmount? _options.tapAmount : _send.amountLD;\nif (_send.minAmountLD > amountToSend) {\n    _send.minAmountLD = amountToSend;\n}\n```\n```\nif (msg_.withdrawOnOtherChain) {\n    uint256 amountToSend = _send.amountLD > _options.tapAmount? _options.tapAmount : _send.amountLD;\n    if (_send.minAmountLD > amountToSend) {\n        _send.minAmountLD = amountToSend;\n    }\n\n    _sendPacket(msg_.lzSendParams, msg_.composeMsg, _options.from);\n\n    if (_options.tapAmount - amountToSend > 0) {\n        IERC20(tapOft).safeTransfer(_options.from, _options.tapAmount - amountToSend);\n    }\n}\n```
MEDIUM severity: The MooniswapGovernance contract's `_beforeTokenTransfer` function is vulnerable to an issue that af. The MooniswapGovernance contract's `_beforeTokenTransfer` function is vulnerable to an issue that affects the accurate reflection of voting power when minting pool tokens. When a user provides liquidity to the pool, pool tokens are minted, triggering the `_beforeTokenTransfer` callback. This callbac...

Vulnerable code:
```\nfunction _beforeTokenTransfer(address from, address to, uint256 amount) internal override {\n    uint256 balanceFrom = (from!= address(0))? balanceOf(from) : 0;\n    uint256 balanceTo = (from!= address(0))? balanceOf(to) : 0;\n    uint256 newTotalSupply = totalSupply().add(from == address(0)? amount : 0).sub(to == address(0)? amount : 0);\n\n    ParamsHelper memory params = ParamsHelper({\n        from: from,\n        to: to,\n        amount: amount,\n        balanceFrom: balanceFrom,\n        balanceTo: balanceTo,\n        newTotalSupply: newTotalSupply\n    });\n```\n```\nif (params.to!= address(0)) {\n    votingData.updateBalance(\n        params.to,\n        voteTo,\n        params.balanceTo,\n        params.balanceTo.add(params.amount),\n        params.newTotalSupply,\n        defaultValue,\n        emitEvent\n    );\n}\n```
MEDIUM severity: The `fulfillDomainBid` function in the ZNS (ZeroNet Storage) protocol allows anyone to front-run the. The `fulfillDomainBid` function in the ZNS (ZeroNet Storage) protocol allows anyone to front-run the original bidder's call, potentially altering the domain's metadata, royalty amount, or locking the metadata. This is because the function does not verify the bidder's signature against the provided m...

Vulnerable code:
```\nfunction fulfillDomainBid(\n    uint256 parentId,\n    uint256 bidAmount,\n    uint256 royaltyAmount,\n    string memory bidIPFSHash,\n    string memory name,\n    string memory metadata,\n    bytes memory signature,\n    bool lockOnCreation,\n    address recipient\n) external {\n    bytes32 recoveredBidHash = createBid(parentId, bidAmount, bidIPFSHash, name);\n    address recoveredBidder = recover(recoveredBidHash, signature);\n    require(recipient == recoveredBidder, "ZNS: bid info doesn't match/exist");\n    bytes32 hashOfSig = keccak256(abi.encode(signature));\n    require(approvedBids[hashOfSig] == true, "ZNS: has been fulfilled");\n    infinity.safeTransferFrom(recoveredBidder, controller, bidAmount);\n    uint256 id = registrar.registerDomain(parentId, name, controller, recoveredBidder);\n    registrar.setDomainMetadataUri(id, metadata);\n    registrar.setDomainRoyaltyAmount(id, royaltyAmount);\n    registrar.transferFrom(controller, recoveredBidder, id);\n    if (lockOnCreation) {\n        registrar.lockDomainMetadataForOwner(id);\n    }\n}\n```