Farseen0/scar-pairs huggingface dataset:
MEDIUM severity: The `VAULT_FEE()` function in the ERC4626-Cloned.sol implementation is vulnerable to an arithmetic o. The `VAULT_FEE()` function in the ERC4626-Cloned.sol implementation is vulnerable to an arithmetic overflow due to an incorrect offset calculation. Specifically, the function is using an offset of 172, which is incorrect, as the value it is intended to retrieve is actually stored at an offset of 165...

Vulnerable code:
```\nfunction testVaultFeeIncorrectlySet() public {\n    Dummy721 nft = new Dummy721();\n    address tokenContract = address(nft);\n    uint256 tokenId = uint256(1);\n    address publicVault = _createPublicVault({\n        strategist: strategistOne,\n        delegate: strategistTwo,\n        epochLength: 14 days\n    });\n    uint fee = PublicVault(publicVault).VAULT_FEE();\n    console.log(fee);\n    assert(fee == 5000);\n}\n```
MEDIUM severity: The vulnerability in the `FixedStrikeOptionTeller` contract allows an attacker to drain all funds fr. The vulnerability in the `FixedStrikeOptionTeller` contract allows an attacker to drain all funds from the contract by exploiting the `create` and `exercise` functions. The contract's ability to deploy and create multiple option tokens, along with the lack of proper validation on the `decimals` valu...

Vulnerable code:
```\nfunction create(\n    FixedStrikeOptionToken optionToken_,\n    uint256 amount_\n) external override nonReentrant {\n    if (call) {\n        // rest of code\n    } else {\n        uint256 quoteAmount = amount_.mulDiv(strikePrice, 10 ** payoutToken.decimals());\n        quoteToken.safeTransferFrom(msg.sender, address(this), quoteAmount);\n        // rest of code\n    }\n\n    optionToken.mint(msg.sender, amount_);\n}\n```\n```\nfunction exercise(\n    FixedStrikeOptionToken optionToken_,\n    uint256 amount_\n) external override nonReentrant {\n    uint256 quoteAmount = amount_.mulDiv(strikePrice, 10 ** payoutToken.decimals());\n\n    if (msg.sender!= receiver) {\n        // rest of code\n    }\n\n    optionToken.burn(msg.sender, amount_);\n\n    if (call) {\n        // rest of code\n    } else {\n        quoteToken.safeTransfer(msg.sender, quoteAmount);\n    }\n}\n```\n```\nuint256 quoteAmount = amount_.mulDiv(strikePrice, 10 ** payoutToken.decimals());\n\nuint256 startBalance = quoteToken.balanceOf(address(this));\nquoteToken.safeTransferFrom(msg.sender, address(this), quoteAmount);\n```\n```\nuint256 amount = optionToken.totalSupply();\n\nif (call) {\n    payoutToken.safeTransfer(receiver, amount);\n} else {\n    uint256 quoteAmount = amount.mulDiv(strikePrice, 10 ** payoutToken.decimals());\n    quoteToken.safeTransfer(receiver, quoteAmount);\n}\n```
MEDIUM severity: The audit revealed inconsistencies between the comments and the actual code implementation in severa. The audit revealed inconsistencies between the comments and the actual code implementation in several areas. This highlights the importance of ensuring that comments accurately reflect the intended behavior and functionality of the code.\n\nIn the `SubjectTypeValidator`, the comment incorrectly stat...

Vulnerable code:
```\n* SCANNER_SUBJECT --> DIRECT\n```\n```\nelse if (subjectType == SCANNER_SUBJECT) {\n    return SubjectStakeAgency.MANAGED;\n```\n```\n/**\n * Assigns the job of running an agent to a scanner.\n * @dev currently only allowed for DISPATCHER_ROLE (Assigner software).\n * @param agentId ERC1155 token id of the agent.\n * @param scannerId ERC1155 token id of the scanner.\n */\n```\n```\nfunction scannerIdToAddress(uint256 scannerId) public pure returns (address) {\n    return address(uint160(scannerId));\n}\n```\n```\n@param nodeRunnerId\nIf set as 0, a new NodeRunnerRegistry ERC721 will be minted to nodeRunner (but it must not own any prior)\n```\n```\n@param nodeRunnerId\nIf set as 0, a new NodeRunnerRegistry ERC721 will be minted to nodeRunner (but it must not own any prior)\n```
MEDIUM severity: The `setMessageService` function, responsible for updating the message service address, lacks a cruc. The `setMessageService` function, responsible for updating the message service address, lacks a crucial aspect of security: event emission. This oversight allows an attacker, who has gained unauthorized access to the owner's account, to silently update the message service address to a malicious one....

Vulnerable code:
```\nfunction setMessageService(address _messageService) public onlyOwner {\n    messageService = IMessageService(_messageService);\n}\n```
MEDIUM severity: The vulnerability lies in the liquidity withdrawal mechanism, which allows a liquidity provider to r. The vulnerability lies in the liquidity withdrawal mechanism, which allows a liquidity provider to request a withdrawal of funds and then withdraw them at a later time. The current implementation has a restriction that requires the liquidity provider to have sufficient funds available at the time of...

Vulnerable code:
```\nfunction requestWithdrawal(uint256 _tokensToWithdraw) external override {\n    WithdrawalStatus _status = getWithdrawalStatus(msg.sender);\n\n    require(_status == WithdrawalStatus.NONE || _status == WithdrawalStatus.EXPIRED,\n        "PB: Can't request withdrawal");\n\n    uint256 _daiTokensToWithdraw = _tokensToWithdraw.mul(getDAIToDAIxRatio()).div(PERCENTAGE_100);\n    uint256 _availableDaiBalance = balanceOf(msg.sender).mul(getDAIToDAIxRatio()).div(PERCENTAGE_100);\n\n    if (block.timestamp < liquidityMining.getEndLMTime().add(neededTimeAfterLM)) {\n        _availableDaiBalance = _availableDaiBalance.sub(liquidityFromLM[msg.sender]);\n    }\n\n    require(totalLiquidity >= totalCoverTokens.add(_daiTokensToWithdraw),\n        "PB: Not enough liquidity");\n\n    require(_availableDaiBalance >= _daiTokensToWithdraw, "PB: Wrong announced amount");\n\n    WithdrawalInfo memory _newWithdrawalInfo;\n    _newWithdrawalInfo.amount = _tokensToWithdraw;\n    _newWithdrawalInfo.readyToWithdrawDate = block.timestamp.add(withdrawalPeriod);\n\n    withdrawalsInfo[msg.sender] = _newWithdrawalInfo;\n    emit RequestWithdraw(msg.sender, _tokensToWithdraw, _newWithdrawalInfo.readyToWithdrawDate);\n}\n```\n```\nfunction withdrawLiquidity() external override {\n    require(getWithdrawalStatus(msg.sender) == WithdrawalStatus.READY,\n        "PB: Withdrawal is not ready");\n\n    uint256 _tokensToWithdraw = withdrawalsInfo[msg.sender].amount;\n    uint256 _daiTokensToWithdraw = _tokensToWithdraw.mul(getDAIToDAIxRatio()).div(PERCENTAGE_100);\n\n    if (withdrawalQueue.length!= 0 || totalLiquidity.sub(_daiTokensToWithdraw) < totalCoverTokens) {\n        withdrawalQueue.push(msg.sender);\n    } else {\n        _withdrawLiquidity(msg.sender, _tokensToWithdraw);\n    }\n}\n```\n```\nrequire(totalLiquidity >= totalCoverTokens.add(_daiTokensToWithdraw),\n  "PB: Not enough liquidity");\n\nrequire(_availableDaiBalance >= _daiTokensToWithdraw, "PB: Wrong announced amount");\n```\n```\nwithdrawalPeriod = 1 * 7\nwithdrawalExpirePeriod = 2 * 24 * 60 * 60 * 1000\n```
MEDIUM severity: The `TradingUtils._executeTrade()` function is responsible for executing trades involving the exchan. The `TradingUtils._executeTrade()` function is responsible for executing trades involving the exchange of tokens, including wrapping and unwrapping of WETH and ETH. The function uses the `preTradeBalance` variable to track the balance of WETH or ETH before executing the trade. However, the function...

Vulnerable code:
```\nfunction _executeTrade(\n    address target,\n    uint256 msgValue,\n    bytes memory params,\n    address spender,\n    Trade memory trade\n) private {\n    uint256 preTradeBalance;\n\n    if (trade.sellToken == address(Deployments.WETH) && spender == Deployments.ETH_ADDRESS) {\n        preTradeBalance = address(this).balance;\n        uint256 withdrawAmount = _isExactIn(trade)? trade.amount : trade.limit;\n        Deployments.WETH.withdraw(withdrawAmount);\n    } else if (trade.sellToken == Deployments.ETH_ADDRESS && spender!= Deployments.ETH_ADDRESS) {\n        preTradeBalance = IERC20(address(Deployments.WETH)).balanceOf(address(this));\n        uint256 depositAmount = _isExactIn(trade)? trade.amount : trade.limit;\n        Deployments.WETH.deposit{value: depositAmount}();\n    }\n\n    (bool success, bytes memory returnData) = target.call{value: msgValue}(params);\n    if (!success) revert TradeExecution(returnData);\n\n    if (trade.buyToken == address(Deployments.WETH)) {\n        if (address(this).balance > preTradeBalance) {\n            uint256 depositAmount;\n            unchecked {\n                depositAmount = address(this).balance - preTradeBalance;\n            }\n            Deployments.WETH.deposit{value: depositAmount}();\n        }\n    } else if (trade.buyToken == Deployments.ETH_ADDRESS) {\n        uint256 postTradeBalance = IERC20(address(Deployments.WETH)).balanceOf(address(this));\n        if (postTradeBalance > preTradeBalance) {\n            uint256 withdrawAmount;\n            unchecked {\n                withdrawAmount = postTradeBalance - preTradeBalance;\n            }\n            Deployments.WETH.withdraw(withdrawAmount);\n        }\n    }\n}\n```
MEDIUM severity: This vulnerability occurs when a user is able to claim a reward only once, despite the policy being . This vulnerability occurs when a user is able to claim a reward only once, despite the policy being removed after the claim. This is because the `commitClaim` function updates the `policyHolders` mapping to remove the claimer's policy after the claim is processed. However, this removal of the policy...

Vulnerable code:
```\nfunction commitClaim(address claimer, uint256 claimAmount)\n    external\n    override\n    onlyClaimVoting\n    updateBMIDAIXStakingReward\n{\n    PolicyHolder storage holder = policyHolders[claimer];\n\n    epochAmounts[holder.endEpochNumber] = \n        epochAmounts[holder.endEpochNumber].sub(holder.coverTokens);\n\n    totalLiquidity = totalLiquidity.sub(claimAmount);\n\n    daiToken.transfer(claimer, claimAmount);\n\n    delete policyHolders[claimer];\n    policyRegistry.removePolicy(claimer);\n}\n```
MEDIUM severity: The `commit` function in the GenesisGroup contract allows anyone to commit a purchased FGEN token to. The `commit` function in the GenesisGroup contract allows anyone to commit a purchased FGEN token to a swap that will occur once the genesis group is launched. This commitment can be performed on behalf of other users, as long as the calling account has sufficient allowance. The `commit` function is...

Vulnerable code:
```\nfunction commit(address from, address to, uint amount) external override onlyGenesisPeriod {\n    burnFrom(from, amount);\n\n    committedFGEN[to] = amount;\n    totalCommittedFGEN += amount;\n\n    emit Commit(from, to, amount);\n}\n```
MEDIUM severity: The `CollateralManager` contract's `_commitCollateral` function allows for the overwriting of collat. The `CollateralManager` contract's `_commitCollateral` function allows for the overwriting of collateral information when committing duplicate collateral. This vulnerability enables malicious borrowers to manipulate the collateral amount associated with a specific token, thereby altering the amount...

Vulnerable code:
```\nfunction _commitCollateral(\n    uint256 _bidId,\n    Collateral memory _collateralInfo\n) internal virtual {\n    CollateralInfo storage collateral = _bidCollaterals[_bidId];\n    collateral.collateralAddresses.add(_collateralInfo._collateralAddress);\n    collateral.collateralInfo[\n        _collateralInfo._collateralAddress\n    ] = _collateralInfo;\n    emit CollateralCommitted(\n        _bidId,\n        _collateralInfo._collateralType,\n        _collateralInfo._collateralAddress,\n        _collateralInfo._amount,\n        _collateralInfo._tokenId\n    );\n}\n```\n```\nfunction lenderAcceptBid(uint256 _bidId)\n    external\n    override\n    whenNotPaused\n    pendingBid(_bidId, "lenderAcceptBid")\n    returns (\n        uint256 amountToProtocol,\n        uint256 amountToMarketplace,\n        uint256 amountToBorrower\n    ) {\n    // Retrieve bid\n    Bid storage bid = bids[_bidId];\n    address sender = _msgSenderForMarket(bid.marketplaceId);\n}\n```
MEDIUM severity: The `addLiquidity` function in the `DAOfiV1Router01` contract allows an attacker to steal token appr. The `addLiquidity` function in the `DAOfiV1Router01` contract allows an attacker to steal token approvals by exploiting the lack of address validation when transferring tokens. This function creates a new pair contract if it does not already exist, then transfers tokens from an arbitrary address to...

Vulnerable code:
```\nfunction addLiquidity(\n    LiquidityParams calldata lp,\n    uint deadline\n) external override ensure(deadline) returns (uint256 amountBase) {\n    if (IDAOfiV1Factory(factory).getPair(\n        lp.tokenBase,\n        lp.tokenQuote,\n        lp.slopeNumerator,\n        lp.n,\n        lp.fee\n    ) == address(0)) {\n        IDAOfiV1Factory(factory).createPair(\n            address(this),\n            lp.tokenBase,\n            lp.tokenQuote,\n            msg.sender,\n            lp.slopeNumerator,\n            lp.n,\n            lp.fee\n        );\n    }\n    address pair = DAOfiV1Library.pairFor(\n        factory,\n        lp.tokenBase,\n        lp.tokenQuote,\n        lp.slopeNumerator,\n        lp.n,\n        lp.fee\n    );\n\n    TransferHelper.safeTransferFrom(\n        lp.tokenBase,\n        lp.sender,\n        pair,\n        lp.amountBase\n    );\n    TransferHelper.safeTransferFrom(\n        lp.tokenQuote,\n        lp.sender,\n        pair,\n        lp.amountQuote\n    );\n    amountBase = IDAOfiV1Pair(pair).deposit(lp.to);\n}\n```
MEDIUM severity: The `InvestorBasedRateLimiter` class contains a vulnerability in its `setInvestorMintLimit` and `set. The `InvestorBasedRateLimiter` class contains a vulnerability in its `setInvestorMintLimit` and `setInvestorRedemptionLimit` methods. These methods can potentially cause subsequent calls to `checkAndUpdateMintLimit` and `checkAndUpdateRedemptionLimit` to revert due to an underflow condition.\n\nThe...

Vulnerable code:
```\nif (amount > rateLimit.limit - rateLimit.currentAmount) {\n    revert RateLimitExceeded();\n}\n```
MEDIUM severity: The `PositionManager` contract's `mint` function calculates the preliminary premium to be paid for b. The `PositionManager` contract's `mint` function calculates the preliminary premium to be paid for buying an option and transfers it from the user. However, if the actual premium paid is smaller than the preliminary premium, the excess is intended to be returned to the user. Unfortunately, the `Posi...

Vulnerable code:
```\nif (obtainedPremium > premium) {\n    baseToken.safeTransferFrom(address(this), msg.sender, obtainedPremium - premium);\n}\n```\n```\nfunction transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) {\n    _transfer(sender, recipient, amount);\n    _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance"));\n    return true;\n}\n```\n```\nfunction transferFrom(\n    address from,\n    address to,\n    uint256 value\n)\n    external\n    override\n    whenNotPaused\n    notBlacklisted(msg.sender)\n    notBlacklisted(from)\n    notBlacklisted(to)\n    returns (bool)\n{\n    require(\n        value <= allowed[from][msg.sender],\n        "ERC20: transfer amount exceeds allowance"\n    );\n    _transfer(from, to, value);\n    allowed[from][msg.sender] = allowed[from][msg.sender].sub(value);\n    return true;\n}\n```
MEDIUM severity: The Moving Average Momentum (MAM) governance feature allows administrators to set a value for the al. The Moving Average Momentum (MAM) governance feature allows administrators to set a value for the alpha coefficient, which determines the degree of weighting decrease in the Exponential Moving Average (EMA) calculation. The alpha value is a constant smoothing factor between 0 and 1, with higher valu...

Vulnerable code:
```\n} else if (key == "emaAlpha") {\n    require(value > 0, "alpha should be > 0");\n    governance.emaAlpha = value;\n    emaAlpha2 = 10 ** 18 - governance.emaAlpha;\n    emaAlpha2Ln = emaAlpha2.log();\n```
MEDIUM severity: This vulnerability occurs when a borrower, who has previously borrowed and increased their collatera. This vulnerability occurs when a borrower, who has previously borrowed and increased their collateral balance, attempts to repay their debt. The repayment process involves a conditional statement that checks if the borrower's current fees and fees owed exceed a minimum threshold. If this condition i...

Vulnerable code:
```\nif (\n    collateralBalance > 0 &&\n    (currentFees + borrowing.feesOwed) / Constants.COLLATERAL_BALANCE_PRECISION >\n    Constants.MINIMUM_AMOUNT\n) {\n    liquidationBonus +=\n        uint256(collateralBalance) / Constants.COLLATERAL_BALANCE_PRECISION;\n} else {\n    currentFees = borrowing.dailyRateCollateralBalance;\n}\n```\n```\nliquidationBonus += uint256(collateralBalance) / Constants.COLLATERAL_BALANCE_PRECISION;\n```\n```\nVault(VAULT_ADDRESS).transferToken(\n    borrowing.holdToken,\n    address(this),\n    borrowing.borrowedAmount + liquidationBonus\n);\n```\n```\n_pay(borrowing.holdToken, address(this), msg.sender, holdTokenBalance);\n_pay(borrowing.saleToken, address(this), msg.sender, saleTokenBalance);\n```
MEDIUM severity: The `HatsSignerGateBase` mechanism, responsible for ensuring the integrity of multisig transactions,. The `HatsSignerGateBase` mechanism, responsible for ensuring the integrity of multisig transactions, fails to verify a crucial aspect: the change of owners after a transaction has been executed. This oversight allows a group of malicious signers to collude and replace opposing signers with cooperati...

Vulnerable code:
```\nfor (uint256 i; i < _ownerCount - 1;) {\n    ownerToCheck = _owners[i];\n\n    if (!isValidSigner(ownerToCheck)) {\n        data = abi.encodeWithSignature("swapOwner(address,address,address)", \n            // rest of code\n```
MEDIUM severity: The `RocketMiniPoolDelegate`'s `destroy()` function is designed to destroy the mini-pool and send an. The `RocketMiniPoolDelegate`'s `destroy()` function is designed to destroy the mini-pool and send any remaining ETH to the `RocketVault`. However, this implementation has a critical flaw. When the mini-pool is destroyed, the leftover ETH is sent to the `RocketVault` without any mechanism to recover...

Vulnerable code:
```\nfunction destroy() private {\n    RocketMinipoolManagerInterface rocketMinipoolManager = \n        RocketMinipoolManagerInterface(getContractAddress("rocketMinipoolManager"));\n    rocketMinipoolManager.destroyMinipool();\n    // Self destruct & send any remaining ETH to vault\n    selfdestruct(payable(getContractAddress("rocketVault")));\n}\n```
MEDIUM severity: The vulnerability allows an attacker to steal the rewards (BPT) from a Balancer vault by exploiting . The vulnerability allows an attacker to steal the rewards (BPT) from a Balancer vault by exploiting the `reinvestReward` function. The attacker can do this by flash-loaning a large amount of WETH from a lending protocol, depositing it into the vault, and then calling the `reinvestReward` function. T...

Vulnerable code:
```\nbptClaim = (strategyTokenAmount * context.totalBPTHeld) / context.vaultState.totalStrategyTokenGlobal;\nbptClaim = (1000000 * 1002000) / 1001000\n```\n```\nfunction _convertBPTClaimToStrategyTokens(StrategyContext memory context, uint256 bptClaim)\n    internal\n    pure\n    returns (uint256 strategyTokenAmount)\n{\n    if (context.totalBPTHeld == 0) {\n        return (bptClaim * uint256(Constants.INTERNAL_TOKEN_PRECISION)) / \n            BalancerConstants.BALANCER_PRECISION;\n    }\n\n    strategyTokenAmount = (bptClaim * context.vaultState.totalStrategyTokenGlobal) / context.totalBPTHeld;\n}\n```\n```\nfunction _convertStrategyTokensToBPTClaim(\n    StrategyContext memory context,\n    uint256 strategyTokenAmount\n) internal pure returns (uint256 bptClaim) {\n    require(strategyTokenAmount <= context.vaultState.totalStrategyTokenGlobal);\n    if (context.vaultState.totalStrategyTokenGlobal > 0) {\n        bptClaim = (strategyTokenAmount * context.totalBPTHeld) / context.vaultState.totalStrategyTokenGlobal;\n    }\n}\n```
MEDIUM severity: The `BondAggregator.liveMarketsBy` function is prone to reverting due to the block gas limit constra. The `BondAggregator.liveMarketsBy` function is prone to reverting due to the block gas limit constraint. This function iterates over all markets, making a minimum of `marketCounter` external calls when all markets are not live and a maximum of 4 * `marketCounter` external calls when all markets are...

Vulnerable code:
```\nfunction liveMarketsBy(address owner_) external view returns (uint256[] memory) {\n    uint256 count;\n    IBondAuctioneer auctioneer;\n    for (uint256 i; i < marketCounter; ++i) {\n        auctioneer = marketsToAuctioneers[i];\n        if (auctioneer.isLive(i) && auctioneer.ownerOf(i) == owner_) {\n            ++count;\n        }\n    }\n\n    uint256[] memory ids = new uint256[](count);\n    count = 0;\n    for (uint256 i; i < marketCounter; ++i) {\n        auctioneer = marketsToAuctioneers[i];\n        if (auctioneer.isLive(i) && auctioneer.ownerOf(i) == owner_) {\n            ids[count] = i;\n            ++count;\n        }\n    }\n\n    return ids;\n}\n```
MEDIUM severity: The ChainlinkAdapterOracle's reliance on Chainlink aggregators' built-in circuit breakers can lead t. The ChainlinkAdapterOracle's reliance on Chainlink aggregators' built-in circuit breakers can lead to incorrect price returns for assets when the underlying aggregator's minPrice is hit. This vulnerability can have severe consequences, as it allows users to continue borrowing against an asset at an...

Vulnerable code:
```\nfunction latestRoundData(\n  address base,\n  address quote\n)\n  external\n  view\n  override\n  checkPairAccess()\n  returns (\n    uint80 roundId,\n    int256 answer,\n    uint256 startedAt,\n    uint256 updatedAt,\n    uint80 answeredInRound\n  )\n{\n  uint16 currentPhaseId = s_currentPhaseId[base][quote];\n  AggregatorV2V3Interface aggregator = _getFeed(base, quote);\n  require(address(aggregator)!= address(0), "Feed not found");\n  (\n    roundId,\n    answer,\n    startedAt,\n    updatedAt,\n    answeredInRound\n  ) = aggregator.latestRoundData();\n  return _addPhaseIds(roundId, answer, startedAt, updatedAt, answeredInRound, currentPhaseId);\n}\n```
MEDIUM severity: The vulnerability arises when attempting to roll an account's maturity in a Notional Strategy Vault . The vulnerability arises when attempting to roll an account's maturity in a Notional Strategy Vault that is already at its maximum borrow capacity. This occurs when the account attempts to borrow from a later maturity to repay the debt of the earlier maturity, resulting in a new borrow that exceeds...

Vulnerable code:
```\nfunction updateUsedBorrowCapacity(\n    address vault,\n    uint16 currencyId,\n    int256 netfCash\n) internal returns (int256 totalUsedBorrowCapacity) {\n    VaultBorrowCapacityStorage storage cap = LibStorage.getVaultBorrowCapacity()[vault][currencyId];\n\n    totalUsedBorrowCapacity = int256(uint256(cap.totalUsedBorrowCapacity)).sub(netfCash);\n\n    if (netfCash < 0) {\n        require(totalUsedBorrowCapacity <= int256(uint256(cap.maxBorrowCapacity)), "Max Capacity");\n    }\n}\n```