Farseen0/scar-pairs huggingface dataset:
MEDIUM severity: The `GoatV1Pair.takeOverPool()` function in the provided smart contract code does not properly valid. The `GoatV1Pair.takeOverPool()` function in the provided smart contract code does not properly validate the `initialEth` parameter. Specifically, it only checks the amount of `token` for initialization, but not `initialETH`. This allows an attacker to set `initParams.initialEth` to 0, which would en...

Vulnerable code:
```\nfunction takeOverPool(GoatTypes.InitParams memory initParams) external {\n    if (_vestingUntil!= _MAX_UINT32) {\n        revert GoatErrors.ActionNotAllowed();\n    }\n\n    GoatTypes.InitialLPInfo memory initialLpInfo = _initialLPInfo;\n\n    GoatTypes.LocalVariables_TakeOverPool memory localVars;\n    address to = msg.sender;\n    localVars.virtualEthOld = _virtualEth;\n    localVars.bootstrapEthOld = _bootstrapEth;\n    localVars.initialTokenMatchOld = _initialTokenMatch;\n\n    (\n        localVars.tokenAmountForPresaleOld,\n        localVars.tokenAmountForAmmOld\n    ) = _tokenAmountsForLiquidityBootstrap(\n        localVars.virtualEthOld,\n        localVars.bootstrapEthOld,\n        initialLpInfo.initialWethAdded,\n        localVars.initialTokenMatchOld\n    );\n\n    // new token amount for bootstrap if no swaps would have occurred\n    (\n        localVars.tokenAmountForPresaleNew,\n        localVars.tokenAmountForAmmNew\n    ) = _tokenAmountsForLiquidityBootstrap(\n        initParams.virtualEth,\n        initParams.bootstrapEth,\n        initParams.initialEth,\n        initParams.initialTokenMatch\n    );\n\n    // team needs to add min 10% more tokens than the initial lp to take over\n    localVars.minTokenNeeded =\n        ((localVars.tokenAmountForPresaleOld + localVars.tokenAmountForAmmOld) * 11000) / 10000;\n\n    if (\n        (localVars.tokenAmountForAmmNew + localVars.tokenAmountForPresaleNew) <\n        localVars.minTokenNeeded\n    ) {\n        revert GoatErrors.InsufficientTakeoverTokenAmount();\n    }\n\n    localVars.reserveEth = _reserveEth;\n\n    // Actual token amounts needed if the reserves have updated after initial lp mint\n    (\n        localVars.tokenAmountForPresaleNew,\n        localVars.tokenAmountForAmmNew\n    ) = _tokenAmountsForLiquidityBootstrap(\n        initParams.virtualEth,\n        initParams.bootstrapEth,\n        localVars.reserveEth,\n        initParams.initialTokenMatch\n    );\n    localVars.reserveToken = _reserveToken;\n\n    // amount of tokens transferred by the new team\n    uint256 tokenAmountIn = IERC20(_token).balanceOf(address(this)) - localVars.reserveToken;\n\n    if (\n        tokenAmountIn <\n        (\n            localVars.tokenAmountForPresaleOld\n```
MEDIUM severity: The `FarmFacet` functions in the Beanstalk protocol are susceptible to a reentrancy vulnerability, w. The `FarmFacet` functions in the Beanstalk protocol are susceptible to a reentrancy vulnerability, which allows an untrusted external contract to drain the intermediate value sent by the caller. This vulnerability arises from the use of the `withEth` modifier, which is used to indicate that the func...

Vulnerable code:
```\nmodifier public withEth() {\n    if (msg.value > 0) {\n        s.isFarm = 2;\n    }\n    _;\n    if (msg.value > 0) {\n        s.isFarm = 1;\n        LibEth.refundEth();\n    }\n}\n```\n```\nfunction refundEth()\n    internal\n{\n    AppStorage storage s = LibAppStorage.diamondStorage();\n    if (address(this).balance > 0 && s.isFarm!= 2) {\n        (bool success,) = msg.sender.call{value: address(this).balance}(\n            new bytes(0)\n        );\n        require(success, "Eth transfer Failed.");\n    }\n}\n```
MEDIUM severity: The `CollateralManager#commitCollateral` function in the CollateralManager smart contract does not v. The `CollateralManager#commitCollateral` function in the CollateralManager smart contract does not verify the status of the loan before allowing users to commit collateral. This vulnerability allows an attacker to add collaterals to a loan after it has been accepted, effectively creating a denial-of...

Vulnerable code:
```\nfunction commitCollateral(\n    uint256 _bidId,\n    Collateral[] calldata _collateralInfo\n) public returns (bool validation_) {\n    address borrower = tellerV2.getLoanBorrower(_bidId);\n\n    (validation_, ) = checkBalances(borrower, _collateralInfo);\n\n    if (validation_) {\n        for (uint256 i = 0; i < _collateralInfo.length; i++) {\n            Collateral memory info = _collateralInfo[i];\n            _commitCollateral(_bidId, info);\n        }\n    }\n}\n```\n```\nfunction _withdraw(uint256 _bidId, address _receiver) internal virtual {\n    for (uint256 i; i < _bidCollaterals[_bidId].collateralAddresses.length(); i++) {\n        // Get collateral info\n        Collateral storage collateralInfo = _bidCollaterals[_bidId].collateralInfo[_bidCollaterals[_bidId].collateralAddresses[i]];\n        // Withdraw collateral from escrow and send it to bid lender\n        ICollateralEscrowV1(_escrows[_bidId]).withdraw(\n            collateralInfo._collateralAddress,\n            collateralInfo._amount,\n            _receiver\n        );\n    }\n}\n```
MEDIUM severity: The `BytesLib.toBytes32()` function in the Bitcoin SPV library contains an unnecessary logic that wa. The `BytesLib.toBytes32()` function in the Bitcoin SPV library contains an unnecessary logic that warrants attention. Specifically, the function casts the `_source` input to `bytes` and creates a temporary copy of the dynamic byte array to check its length. This redundant step can be bypassed by dir...

Vulnerable code:
```\nfunction toBytes32(bytes memory _source) pure internal returns (bytes32 result) {\n    bytes memory tempEmptyStringTest = bytes(_source);\n    if (tempEmptyStringTest.length == 0) {\n        return 0x0;\n    }\n\n    assembly {\n        result := mload(add(_source, 32))\n    }\n}\n```
MEDIUM severity: The vulnerability arises when an administrator attempts to change the toggle address of a hat, which. The vulnerability arises when an administrator attempts to change the toggle address of a hat, which is a critical component in a smart contract-based system. The `changeHatToggle` function updates the `toggle` address to a new value provided by the administrator. However, if the toggle address is a...

Vulnerable code:
```\nfunction changeHatToggle(uint256 _hatId, address _newToggle) external {\n    if (_newToggle == address(0)) {\n        revert ZeroAddress();\n    }\n\n    _checkAdmin(_hatId);\n    Hat storage hat = _hats[_hatId];\n\n    if (!_isMutable(hat)) {\n        revert Immutable();\n    }\n\n    hat.toggle = _newToggle;\n\n    emit HatToggleChanged(_hatId, _newToggle);\n}\n```
MEDIUM severity: The vulnerability allows a malicious user to exploit the `VUSD` smart contract's `processWithdrawals. The vulnerability allows a malicious user to exploit the `VUSD` smart contract's `processWithdrawals` function, which is not reentrant, to indefinitely lengthen the withdrawal queue and waste large amounts of caller gas. This is achieved by creating a smart contract that uses its `receive` function...

Vulnerable code:
```\nwhile (i < withdrawals.length && (i - start) < maxWithdrawalProcesses) {\n    Withdrawal memory withdrawal = withdrawals[i];\n    if (reserve < withdrawal.amount) {\n        break;\n    }\n\n    (bool success, bytes memory data) = withdrawal/usr.call{value: withdrawal.amount}("");\n    if (success) {\n        reserve -= withdrawal.amount;\n    }\n}\n```
MEDIUM severity: This vulnerability occurs when a contract uses the `call()` function to interact with another contra. This vulnerability occurs when a contract uses the `call()` function to interact with another contract, but does not require the returned data. In such cases, the returned data is still copied into memory, which can lead to gas griefing attacks. Gas griefing attacks occur when an attacker intentiona...

Vulnerable code:
```\n(bool sent,) = address(operatorAddress).call{value: msg.value}("");\nif (!sent) {\n    revert Unauthorized();\n}\n```\n```\n(bool sent, bytes memory data) = address(operatorAddress).call{value: msg.value}("");\nif (!sent) {\n    revert Unauthorized();\n}\n```
MEDIUM severity: The `sponsorSeries()` method is vulnerable to a critical issue when attempting to swap for stake tok. The `sponsorSeries()` method is vulnerable to a critical issue when attempting to swap for stake tokens using the `swapQuote` mechanism. Specifically, when a user tries to swap an ERC20 token for stake tokens, the `transferFrom()` function is not correctly executed, resulting in the failure to trans...

Vulnerable code:
```\nif (address(quote.sellToken)!= ETH) {\n    _transferFrom(permit, stake, stakeSize);\n}\n\nif (address(quote.sellToken)!= stake) {\n    _fillQuote(quote);\n}\n```
MEDIUM severity: The Pod's deposit mechanism is vulnerable to re-entrancy attacks, which can lead to the theft of fun. The Pod's deposit mechanism is vulnerable to re-entrancy attacks, which can lead to the theft of funds. During the deposit process, the token transfer is executed after the Pod shares are minted. Specifically, the `IERC20Upgradeable(token).transferFrom` function is called to transfer the token amoun...

Vulnerable code:
```\nuint256 shares = _deposit(to, tokenAmount);\n\nIERC20Upgradeable(token).transferFrom(\n    msg.sender,\n    address(this),\n    tokenAmount\n);\n```
MEDIUM severity: The `LIQUIDATION_IN_PROGRESS` state is unreachable, as the `startSignerAbortLiquidation` function al. The `LIQUIDATION_IN_PROGRESS` state is unreachable, as the `startSignerAbortLiquidation` function always transitions to the `FRAUD_LIQUIDATION_IN_PROGRESS` state, regardless of the reason for the liquidation. This means that any non-fraud state transitions, such as those triggered by undercollateral...

Vulnerable code:
```\nfunction startSignerAbortLiquidation(DepositUtils.Deposit storage _d) internal {\n    _d.logStartedLiquidation(false);\n    // Reclaim used state for gas savings\n    _d.redemptionTeardown();\n    _d.seizeSignerBonds();\n\n    _d.liquidationInitiated = block.timestamp;  // Store the timestamp for auction\n    _d.liquidationInitiator = msg.sender;\n    _d.setFraudLiquidationInProgress();\n}\n```
MEDIUM severity: When a collateral is paused by governance, the `collateralValid` variable is set to `false`, which h. When a collateral is paused by governance, the `collateralValid` variable is set to `false`, which has a cascading effect on the loan closure and liquidation processes. Specifically, this change prevents users with existing loans from closing their loans to recover their collateral, thereby renderin...

Vulnerable code:
```\nfunction pauseCollateralType(\n    address _collateralAddress,\n    bytes32 _currencyKey\n) external collateralExists(_collateralAddress) onlyAdmin {\n    require(_collateralAddress!= address(0));\n    require(_currencyKey == collateralProps[_collateralAddress].currencyKey, "Mismatched data");\n    collateralValid[_collateralAddress] = false;\n    collateralPaused[_collateralAddress] = true;\n}\n```
MEDIUM severity: The `defaulting` mechanism in the `CollateralManager` contract does not properly update the state of. The `defaulting` mechanism in the `CollateralManager` contract does not properly update the state of the loan, allowing the lender to continue making payments even after the loan has defaulted. This is because the `defaulted` state is not reflected in the `TellerV2` contract, which still maintains t...

Vulnerable code:
```\nFile: CollateralManager.sol\n\nelse if (tellerV2.isLoanDefaulted(_bidId)) {\n    _withdraw(_bidId, tellerV2.getLoanLender(_bidId)); // sends collateral to lender\n    emit CollateralClaimed(_bidId);\n} else {\n```
MEDIUM severity: The vulnerability in the `exitVault` function of the `VaultAccountAction` contract allows users to r. The vulnerability in the `exitVault` function of the `VaultAccountAction` contract allows users to repay debt without redeeming their vault shares/strategy tokens. This is achieved by setting the `vaultSharesToRedeem` parameter to zero, which bypasses the redemption process and directly recovers the...

Vulnerable code:
```\nFile: VaultAccountAction.sol\n\nfunction exitVault(\n    address account,\n    address vault,\n    address receiver,\n    uint256 vaultSharesToRedeem,\n    uint256 lendAmount,\n    uint32 minLendRate,\n    bytes calldata exitVaultData\n) external payable override nonReentrant returns (uint256 underlyingToReceiver) {\n    // If insufficient strategy tokens are redeemed (or if it is set to zero), then\n    // redeem with debt repayment will recover the repayment from the account's wallet\n    // directly.\n    underlyingToReceiver = underlyingToReceiver.add(vaultConfig.redeemWithDebtRepayment(\n        vaultAccount, receiver, vaultSharesToRedeem, exitVaultData\n    ));\n```\n```\nVaultAccountAction.exitVault\n  └── VaultConfiguration.redeemWithDebtRepayment\n    └── VaultConfiguration._redeem\n      └── IStrategyVault.redeemFromNotional\n        └── MetaStable2TokenAuraVault._redeemFromNotional\n          └── MetaStable2TokenAuraHelper.redeem\n            └── Balancer2TokenPoolUtils._redeem\n              └── StrategyUtils._redeemStrategyTokens\n```\n```\nfunction _redeemStrategyTokens(\n    StrategyContext memory strategyContext,\n    uint256 strategyTokens\n) internal returns (uint256 poolClaim) {\n    poolClaim = _convertStrategyTokensToPoolClaim(strategyContext, strategyTokens);\n\n    if (poolClaim == 0) {\n        revert Errors.ZeroPoolClaim();\n    }\n}\n```
MEDIUM severity: The ShortLongSpell#openPosition function in the provided code contains a critical vulnerability that. The ShortLongSpell#openPosition function in the provided code contains a critical vulnerability that can lead to unexpected liquidation of a user's position when increasing the position size. This occurs due to the function's design, which sends all collateral to the user instead of retaining it wit...

Vulnerable code:
```\n{\n    IBank.Position memory pos = bank.getCurrentPositionInfo();\n    address posCollToken = pos.collateralToken;\n    uint256 collSize = pos.collateralSize;\n    address burnToken = address(ISoftVault(strategy.vault).uToken());\n    if (collSize > 0) {\n        if (posCollToken!= address(wrapper)) {\n            revert Errors.INCORRECT_COLTOKEN(posCollToken);\n        }\n        bank.takeCollateral(collSize);\n        wrapper.burn(burnToken, collSize);\n        _doRefund(burnToken);\n    }\n}\n```
MEDIUM severity: This vulnerability allows an operator to manipulate the withdrawal process, potentially causing a de. This vulnerability allows an operator to manipulate the withdrawal process, potentially causing a denial-of-service (DoS) or increasing the cost of the withdrawal for the withdrawer. The operator can achieve this by reverting the call, thereby canceling the transaction and preventing the withdrawal...

Vulnerable code:
```\nif (operatorFee > 0) {\n    (status, data) = operator.call({\n        value: operatorFee\n    } "");\n    if (status == false) {\n        revert FeeRecipientReceiveError(data);\n    }\n}\n```
MEDIUM severity: The vulnerability occurs when the withdrawal fee is ignored during the check for skew max in the Sta. The vulnerability occurs when the withdrawal fee is ignored during the check for skew max in the Stable Withdrawal, Leverage Open, and Leverage Adjust processes. This can lead to a situation where the protocol reverts on a safe withdrawal, even though the skew fraction is below the maximum allowed t...

Vulnerable code:
```\nvault.updateStableCollateralTotal(-int256(_amountOut))\n```\n```\nif (withdrawalCount < withdrawalLimit) {\n    _withdrawFee = (stableWithdrawFee * _amountOut) / 1e18;\n}\n\nvault.checkSkewMax({additionalSkew: 0});\n```\n```\nif (amountOut < stableWithdraw.minAmountOut) {\n    revert FlatcoinErrors.HighSlippage(amountOut, stableWithdraw.minAmountOut);\n}\n\nvault.updateStableCollateralTotal(int256(withdrawFee)); // pay the withdrawal fee to stable LPs\nvault.sendCollateral({to: msg.sender, amount: order.keeperFee}); // pay the keeper their fee\nvault.sendCollateral({to: account, amount: amountOut}); // transfer remaining amount to the trader\n```\n```\nuint256 totalFee = order.keeperFee + withdrawFee;\n```\n```\nfunction test_audit_withdraw_fee_ignored_when_checks_skew_max() public {\n    uint256 skewFractionMax = vaultProxy.skewFractionMax();\n    assertEq(skewFractionMax, 120e16);\n\n    vm.prank(vaultProxy.owner());\n    stableModProxy.setStableWithdrawFee(1e16);\n\n    uint256 collateralPrice = 1000e8;\n\n    uint256 depositAmount = 100e18;\n    announceAndExecuteDeposit({\n        traderAccount: alice,\n        keeperAccount: keeper,\n        depositAmount: depositAmount,\n        oraclePrice: collateralPrice,\n        keeperFeeAmount: 0\n    });\n\n    uint256 additionalSize = 100e18;\n    announceAndExecuteLeverageOpen({\n        traderAccount: bob,\n        keeperAccount: keeper,\n        margin: 50e18,\n        additionalSize: 100e18,\n        oraclePrice: collateralPrice,\n        keeperFeeAmount: 0\n    });\n\n    int256 skewAfterLeverageOpen = vaultProxy.getCurrentSkew();\n    assertEq(skewAfterLeverageOpen, 0);\n    uint256 skewFractionAfterLeverageOpen = getLongSkewFraction();\n    assertEq(skewFractionAfterLeverageOpen, 1e18);\n\n    // Alice withdraws 16.8 collateral\n    // uint256 aliceLpBalance = stableModProxy.balanceOf(alice);\n    // announceAndExecuteWithdraw({\n    //     traderAccount: alice, \n    //     keeperAccount: keeper, \n    //     withdrawAmount: 168e17, \n    //     oraclePrice: collateralPrice, \n    //     keeperFeeAmount: 0\n    // });\n\n    // After withdrawal, the actual skew fraction is 119.9%, less than skewFractionMax\n    // uint256 skewFactionAfterWithdrawal = getLongSkewFraction();\n    // assertEq(skewFactionAfterWithdrawal, 1199501007580846367);\n\n    // console2.log(WETH.balanceOf(address(vaultProxy)));\n}\n```
MEDIUM severity: The `fulfillRandomWords()` function in the Infiltration contract is vulnerable to reverting under ce. The `fulfillRandomWords()` function in the Infiltration contract is vulnerable to reverting under certain circumstances. This function is a crucial part of the proof-of-concept (POC) and is responsible for calculating the total cost of healing wounded agents. The function uses a variable `AGENTS_TO_...

Vulnerable code:
```\nfunction test_fulfillRandomWords_revert() public {\n    _startGameAndDrawOneRound();\n\n    _drawXRounds(48);\n\n    uint256 counter = 0;\n    uint256[] memory wa = new uint256[](30);\n    uint256 totalCost = 0;\n\n    for (uint256 j = 2; j <= 6; j++) {\n        (uint256[] memory woundedAgentIds, ) = infiltration.getRoundInfo({roundId: j});\n\n        uint256[] memory costs = new uint256[](woundedAgentIds.length);\n        for (uint256 i = 0; i < woundedAgentIds.length; i++) {\n            costs[i] = HEAL_BASE_COST;\n            wa[counter] = woundedAgentIds[i];\n            counter++;\n            if (counter > 29) break;\n        }\n\n        if (counter > 29) break;\n    }\n\n    totalCost = HEAL_BASE_COST * wa.length;\n    looks.mint(user1, totalCost);\n\n    vm.startPrank(user1);\n    _grantLooksApprovals();\n    looks.approve(TRANSFER_MANAGER, totalCost);\n\n    infiltration.heal(wa);\n    vm.stopPrank();\n\n    _drawXRounds(1);\n}\n```
MEDIUM severity: The `RocketTokenRETH.sol` contract's `_beforeTokenTransfer` function implements a deposit delay mech. The `RocketTokenRETH.sol` contract's `_beforeTokenTransfer` function implements a deposit delay mechanism to prevent users from transferring or burning rETH tokens shortly after depositing. This delay is currently set to approximately 19 hours, calculated based on the number of blocks mined. The fun...

Vulnerable code:
```\nfunction _beforeTokenTransfer(address from, address, uint256) internal override {\n    // Don't run check if this is a mint transaction\n    if (from!= address(0)) {\n        bytes32 key = keccak256(abi.encodePacked("user.deposit.block", from));\n        uint256 lastDepositBlock = getUint(key);\n        if (lastDepositBlock > 0) {\n            uint256 depositDelay = getUint(keccak256(abi.encodePacked(keccak256("dao.protocol.setting.network"), "network.reth.deposit.delay")));\n            uint256 blocksPassed = block.number.sub(lastDepositBlock);\n            require(blocksPassed > depositDelay, "Not enough time has passed since deposit");\n            // Clear the state as it's no longer necessary to check this until another deposit is made\n            deleteUint(key);\n        }\n    }\n}\n```
MEDIUM severity: The "Nobody can cast for any proposal" vulnerability is a critical issue in the `GovernorBravoDelega. The "Nobody can cast for any proposal" vulnerability is a critical issue in the `GovernorBravoDelegate` contract, specifically in the `castVoteInternal` function. This function is responsible for processing votes for proposals, but it contains a logical flaw that prevents users from casting votes fo...

Vulnerable code:
```\nfunction castVoteInternal(\n    address voter,\n    uint256 proposalId,\n    uint8 support\n) internal returns (uint256) {\n    // Get the user's votes at the start of the proposal and at the time of voting. Take the minimum.\n    uint256 originalVotes = gohm.getPriorVotes(voter, proposal.startBlock);\n    uint256 currentVotes = gohm.getPriorVotes(voter, block.number);\n    uint256 votes = currentVotes > originalVotes? originalVotes : currentVotes;\n}\n```\n```\nfunction getPriorVotes(address account, uint256 blockNumber) external view returns (uint256) {\n    require(blockNumber < block.number, "gOHM::getPriorVotes: not yet determined");\n}\n```
MEDIUM severity: The `enterMarket` and `exitMarket` functions in the DeFi Saver smart contracts interact with the Com. The `enterMarket` and `exitMarket` functions in the DeFi Saver smart contracts interact with the Compound protocol's Comptroller contract, which returns error codes in case of failure. However, the DeFi Saver contracts do not properly check for these error codes, potentially leading to unexpected be...

Vulnerable code:
```\nfunction enterMarket(address _cTokenAddr) public {\n    address[] memory markets = new address[](1);\n    markets[0] = _cTokenAddr;\n\n    IComptroller(COMPTROLLER_ADDR).enterMarkets(markets);\n}\n\nfunction exitMarket(address _cTokenAddr) public {\n    IComptroller(COMPTROLLER_ADDR).exitMarket(_cTokenAddr);\n}\n```
MEDIUM severity: The vulnerability lies in the implementation of the `removeOracleSignerAfterSignal` function, which . The vulnerability lies in the implementation of the `removeOracleSignerAfterSignal` function, which is responsible for removing an Oracle Signer from the system. The function uses a two-stage process to validate the removal request. In the first stage, the `signalRemoveOracleSigner` function is call...

Vulnerable code:
```\nfunction removeOracleSignerAfterSignal(address account) external onlyTimelockAdmin nonReentrant {\n    bytes32 actionKey = _addOracleSignerActionKey(account);\n    _validateAndClearAction(actionKey, "removeOracleSigner");\n\n    oracleStore.removeSigner(account);\n\n    EventUtils.EventLogData memory eventData;\n    eventData.addressItems.initItems(1);\n    eventData.addressItems.setItem(0, "account", account);\n    eventEmitter.emitEventLog1(\n        "RemoveOracleSigner",\n        actionKey,\n        eventData\n    );\n}\n```