Farseen0/scar-pairs huggingface dataset:
MEDIUM severity: The `IchiVaultSpell.sol` contract's withdrawal functionality is vulnerable to a critical issue where. The `IchiVaultSpell.sol` contract's withdrawal functionality is vulnerable to a critical issue where LP tokens are not sent back to the withdrawing user. When a user initiates a withdrawal, the contract unwinds their position and sends back their assets, but fails to return the requested LP tokens,...

Vulnerable code:
```\ndoTakeCollateral(\n    strategies[strategyId].vault,\n    lpTakeAmt\n)\n```\n```\nuint256 amtLPToRemove = vault.balanceOf(address(this)) - amountLpWithdraw;\nvault.withdraw(amtLPToRemove, address(this));\n```\n```\ndoWithdraw(collToken, amountShareWithdraw);\n```\n```\ndoRepay(\n    borrowToken,\n    amountRepay\n);\n```\n```\n_validateMaxLTV(strategyId)\n```\n```\ndoRefund(borrowToken);\ndoRefund(collToken);\n```
MEDIUM severity: The codebase exhibits signs of being incomplete and not production-ready, as evident from the presen. The codebase exhibits signs of being incomplete and not production-ready, as evident from the presence of commented-out functions and narrow test scenarios that do not cover the actual production code flow. Specifically, the `isNotStartedAuction` and `inAcceptingBidsPeriod` functions, which are cruc...

Vulnerable code:
```\nfunction isNotStartedAuction(bytes32 auctionID) public virtual override returns (bool) {\n    uint256 closingTime = _auctionClosingTime[auctionID];\n    return closingTime == 0;\n}\n\nfunction inAcceptingBidsPeriod(bytes32 auctionID) public virtual override returns (bool) {\n    uint256 closingTime = _auctionClosingTime[auctionID];\n```\n```\nfunction isNotStartedAuction(bytes32 auctionID)\n    public\n    virtual\n    override\n    returns (bool)\n{\n    return true;\n}\n\nfunction inAcceptingBidsPeriod(bytes32 auctionID)\n```\n```\nrequire(\n    inRevealingValuationPeriod(auctionID),\n    "it is not the time to reveal the value of bids"\n);\n```
MEDIUM severity: The vulnerability allows an attacker to manipulate the initial share price by front-running the `tra. The vulnerability allows an attacker to manipulate the initial share price by front-running the `training` block, which is intended to ensure the early depositor's address is whitelisted. This manipulation enables the attacker to inflate the share price, thereby affecting the share distribution amon...

Vulnerable code:
```\nFile: MainVault.sol\n\nfunction deposit(\n    uint256 _amount,\n    address _receiver\n) external nonReentrant onlyWhenVaultIsOn returns (uint256 shares) {\n    if (training) {\n        require(whitelist[msg.sender]);\n        uint256 balanceSender = (balanceOf(msg.sender) * exchangeRate) / (10 ** decimals());\n        require(_amount + balanceSender <= maxTrainingDeposit);\n    }\n```\n```\nFile: MainVault.sol\n\nexchangeRate = _uScale;\n\nfunction setXChainAllocationInt(\n    uint256 _amountToSend,\n    uint256 _exchangeRate,\n    bool _receivingFunds\n) internal {\n    amountToSendXChain = _amountToSend;\n    exchangeRate = _exchangeRate;\n\n    if (_amountToSend == 0 &&!_receivingFunds) {\n        settleReservedFunds();\n    } else if (_amountToSend == 0 && _receivingFunds) {\n        state = State.WaitingForFunds;\n    } else {\n        state = State.SendingFundsXChain;\n    }\n}\n\nFile: XChainController.sol\n\nuint256 totalUnderlying = getTotalUnderlyingVault(_vaultNumber) - totalWithdrawalRequests;\nuint256 totalSupply = getTotalSupply(_vaultNumber);\n\nuint256 decimals = xProvider.getDecimals(vault);\nuint256 newExchangeRate = (totalUnderlying * (10 ** decimals)) / totalSupply;\n```
MEDIUM severity: The `withdraw()` function in the `DepositVault` contract exhibits nonstandard usage of the `nonce` p. The `withdraw()` function in the `DepositVault` contract exhibits nonstandard usage of the `nonce` parameter. In its current implementation, `nonce` is used as an index to retrieve a specific deposit from the `deposits` array, rather than its conventional purpose of tracking the latest transaction f...

Vulnerable code:
```\nDepositVault.sol\nfunction withdraw(uint256 amount, uint256 nonce, bytes memory signature, address payable recipient) public {\n    require(nonce < deposits.length, "Invalid deposit index");\n    Deposit storage depositToWithdraw = deposits[nonce];\n    bytes32 withdrawalHash = getWithdrawalHash(Withdrawal(amount, nonce));\n    address signer = withdrawalHash.recover(signature);\n    require(signer == depositToWithdraw.depositor, "Invalid signature");\n    require(!usedWithdrawalHashes[withdrawalHash], "Withdrawal has already been executed");\n    require(amount == depositToWithdraw.amount, "Withdrawal amount must match deposit amount");\n    usedWithdrawalHashes[withdrawalHash] = true;\n    depositToWithdraw.amount = 0;\n    if (depositToWithdraw.tokenAddress == address(0)) {\n        recipient.transfer(amount);\n    } else {\n        IERC20 token = IERC20(depositToWithdraw.tokenAddress);\n        token.safeTransfer(recipient, amount);\n    }\n    emit WithdrawalMade(recipient, amount);\n```
MEDIUM severity: The `Axis-Finance` protocol's Fixed Price Auction (FPAM) mechanism allows sellers to create auctions. The `Axis-Finance` protocol's Fixed Price Auction (FPAM) mechanism allows sellers to create auctions with a prefunded supply. When an FPAM auction is created, the seller can cancel it while it is still active, and if the auction is prefunded, the remaining funds will be transferred back to the selle...

Vulnerable code:
```\nfunction _revertIfLotConcluded(uint96 lotId_) internal view virtual {\n    if (lotData[lotId_].conclusion < uint48(block.timestamp)) {\n        revert Auction_MarketNotActive(lotId_);\n    }\n\n    if (lotData[lotId_].capacity == 0) {\n        revert Auction_MarketNotActive(lotId_);\n    }\n}\n```\n```\nfunction test_FundedPriceAuctionStuckFunds() public {\n    vm.startPrank(alice);\n\n    Veecode veecode = fixedPriceAuctionModule.VEECODE();\n    Keycode keycode = keycodeFromVeecode(veecode);\n\n    bytes memory _derivativeParams = "";\n\n    uint96 lotCapacity = 75_000_000_000e18; // this is 75 billion tokens\n    mockBaseToken.mint(alice, lotCapacity);\n    mockBaseToken.approve(address(auctionHouse), type(uint256).max);\n\n    FixedPriceAuctionModule.FixedPriceParams memory myStruct = FixedPriceAuctionModule.FixedPriceParams({\n        price: uint96(1e18),\n        maxPayoutPercent: uint24(1e5)\n    });\n\n    Auctioneer.RoutingParams memory routingA = Auctioneer.RoutingParams({\n        auctionType: keycode,\n        baseToken: mockBaseToken,\n        quoteToken: mockQuoteToken,\n        curator: curator,\n        callbacks: ICallback(address(0)),\n        callbackData: abi.encode(""),\n        derivativeType: toKeycode(""),\n        derivativeParams: _derivativeParams,\n        wrapDerivative: false,\n        prefunded: true\n    });\n\n    Auction.AuctionParams memory paramsA = Auction.AuctionParams({\n        start: 0,\n        duration: 1 days,\n        capacityInQuote: false,\n        capacity: lotCapacity,\n        implParams: abi.encode(myStruct)\n    });\n\n    string memory infoHashA;\n    auctionHouse.auction(routingA, paramsA, infoHashA);\n\n    vm.stopPrank();\n\n    vm.startPrank(bob);\n\n    uint96 fundingBeforePurchase;\n    uint96 fundingAfterPurchase;\n    (, fundingBeforePurchase,,,,,,,) = auctionHouse.lotRouting(0);\n    console2.log("Here is the funding normalized before purchase: ", fundingBeforePurchase / 1e18);\n\n    mockQuoteToken.mint(bob, 10_000_000_000e18);\n    mockQuoteToken.approve(address(auctionHouse), type(uint256).max);\n\n    Router.PurchaseParams memory purchaseParams = Router.PurchaseParams({\n        recipient: bob,\n        referrer: address(0),\n        lotId: 0,\n        amount: 10_000_000_000e18,\n        minAmountOut: 10_000_000_000e18,\n        auctionData: abi.encode(0),\n        permit\n```\n```\nLogs:\n    Here is the funding normalized before purchase: 75000000000\n    Here is the funding normalized after purchase: 65000000000\n    Balance of seller of quote tokens: 10000000000\n    Balance of bob in base token: 10000000000\n    Balance of auction house in base token: 65000000000\n```
MEDIUM severity: The vulnerability lies in the potential for a uint overflow in the `require` statement, which can oc. The vulnerability lies in the potential for a uint overflow in the `require` statement, which can occur when the `amount` parameter passed by a user is close to the maximum value of a uint. This can happen when a user attempts to create a delegation with a very large amount of tokens, exceeding the...

Vulnerable code:
```\nuint holderBalance = SkaleToken(contractManager.getContract("SkaleToken")).balanceOf(holder);\nuint lockedToDelegate = tokenState.getLockedCount(holder) - tokenState.getPurchasedAmount(holder);\n\nrequire(holderBalance >= amount + lockedToDelegate, "Delegator hasn't enough tokens to delegate");\n```
MEDIUM severity: The `collateralFactor()` function in the smart contract is responsible for calculating the collatera. The `collateralFactor()` function in the smart contract is responsible for calculating the collateral factor for the protocol. This calculation is critical as it determines the proportion of collateral assets to be bought or sold during rebalancing. However, the function fails to account for the rem...

Vulnerable code:
```\nfunction collateralFactor() public view override returns (uint256) {\n    uint256 totalAssetsUSD = 0;\n    for (uint256 i = 0; i < collateral.length; i++) {\n        totalAssetsUSD += (\n            (\n                (\n                    IERC20Upgradeable(collateral[i].token).balanceOf(address(this)) * 1e18\n                ) /\n                (10 ** IERC20MetadataUpgradeable(collateral[i].token).decimals())\n            ) *\n            collateral[i].oracle.getPriceUSD()\n        ) / 1e18;\n    }\n    return (totalAssetsUSD * 1e6) / totalSupply();\n}\n```\n```\nfunction removeCollateral(uint256 _index) public onlyControl {\n    collateral[_index] = collateral[collateral.length - 1];\n    collateral.pop();\n```
MEDIUM severity: The `PerpDespository#reblance` and `rebalanceLite` functions in the PerpDespository contract allow a. The `PerpDespository#reblance` and `rebalanceLite` functions in the PerpDespository contract allow an attacker to specify the account that pays the quote token, which can be exploited to drain funds from any user who has approved the PerpDespository. The `rebalance` function is particularly vulnerab...

Vulnerable code:
```\nfunction rebalance(\n    uint256 amount,\n    uint256 amountOutMinimum,\n    uint160 sqrtPriceLimitX96,\n    uint24 swapPoolFee,\n    int8 polarity,\n    address account\n) external nonReentrant returns (uint256, uint256) {\n    if (polarity == -1) {\n        return (\n            _rebalanceNegativePnlWithSwap(\n                amount,\n                amountOutMinimum,\n                sqrtPriceLimitX96,\n                swapPoolFee,\n                account\n            )\n        );\n    } else if (polarity == 1) {\n        revert PositivePnlRebalanceDisabled(msg.sender);\n    } else {\n        revert InvalidRebalance(polarity);\n    }\n}\n```\n```\nfunction _rebalanceNegativePnlWithSwap(\n    uint256 amount,\n    uint256 amountOutMinimum,\n    uint160 sqrtPriceLimitX96,\n    uint24 swapPoolFee,\n    address account\n) private returns (uint256, uint256) {\n    SwapParams memory params = SwapParams({\n        tokenIn: assetToken,\n        tokenOut: quoteToken,\n        amountIn: amount,\n        amountOutMinimum: amountOutMinimum,\n        sqrtPriceLimitX96: sqrtPriceLimitX96,\n        poolFee: swapPoolFee\n    });\n    uint256 quoteAmountOut = spotSwapper.swapExactInput(params);\n    int256 shortFall = int256(\n        quoteAmount.fromDecimalToDecimal(18, ERC20(quoteToken).decimals())\n    ) - int256(quoteAmountOut);\n    if (shortFall > 0) {\n        IERC20(quoteToken).transferFrom(\n            account,\n            address(this),\n            uint256(shortFall)\n        );\n    } else if (shortFall < 0) {\n    }\n    vault.deposit(quoteToken, quoteAmount);\n\n    emit Rebalanced(amount, quoteAmount, shortFall);\n    return (amount, quoteAmount);\n}\n```
MEDIUM severity: The vulnerability arises from the use of the `mint` function instead of `safeMint` in the ERC721 imp. The vulnerability arises from the use of the `mint` function instead of `safeMint` in the ERC721 implementation. Specifically, when the `_stakeToken()` function is called, the `msg.sender` is minted as a proof of staking NFT. However, if the `msg.sender` is a contract address that does not support E...

Vulnerable code:
```\nfunction _mint(address to, uint256 tokenId) internal virtual {\n    /**\n     * @dev Mints `tokenId` and transfers it to `to`.\n     *\n     * Requirements:\n     *\n     * - `tokenId` must not exist.\n     * - `to` cannot be the zero address.\n     *\n     * Emits a {Transfer} event.\n     */\n}\n```
MEDIUM severity: The vulnerability lies in the fact that the admin of the Swell protocol, which is marked as "Restric. The vulnerability lies in the fact that the admin of the Swell protocol, which is marked as "Restricted" (Not Trusted), has the ability to upgrade the swETH contract code. This allows them to manipulate the `swETHToETHRate` function, which is used by Tokemak to determine the price of the swETH Liqui...

Vulnerable code:
```\nFile: SwEthEthOracle.sol\n\nfunction getPriceInEth(address token) external view returns (uint256 price) {\n    if (token!= address(swEth)) revert Errors.InvalidToken(token);\n\n    price = swEth.swETHToETHRate();\n}\n```
MEDIUM severity: The `_hashLeaf` method in the TokenDistributor contract is responsible for verifying the correctness. The `_hashLeaf` method in the TokenDistributor contract is responsible for verifying the correctness of user claims by comparing the hash of the user's ID and claim amount with a provided leaf hash. The method uses the `abi.encodePacked` function to concatenate the `user_id` and `user_amount` argume...

Vulnerable code:
```\nrequire(_hashLeaf(user_id, user_amount, leaf), 'TokenDistributor: Leaf Hash Mismatch.')\n```\n```\n/**\n * @notice hash user_id + claim amount together & compare results to leaf hash\n * @return boolean true on match\n*/\nfunction _hashLeaf(uint32 user_id, uint256 user_amount, bytes32 leaf) private returns (bool) {\n```\n```\nbytes32 leaf_hash = keccak256(abi.encodePacked(keccak256(abi.encodePacked(user_id, user_amount))));\n```\n```\nreturn leaf == leaf_hash;\n```\n```\nlibrary Encode {\n    function encode32Plus256(uint32 _a, uint256 _b) public pure returns (bytes memory) {\n        return abi.encodePacked(_a, _b);\n    }\n\n    function encode256Plus32(uint256 _a, uint32 _b) public pure returns (bytes memory) {\n        return abi.encodePacked(_a, _b);\n    }\n}\n\ncontract Hash {\n    function checkEqual() public pure returns (bytes32, bytes32) {\n        uint32 a1 = 0x12345678;\n        uint256 b1 = 0x99999999999999999999999999999999999999999999999999999999FFFFFFFF;\n\n        uint256 a2 = 0x1234567899999999999999999999999999999999999999999999999999999999;\n        uint32 b2 = 0xFFFFFFFF;\n\n        bytes memory packed1 = Encode.encode32Plus256(a1, b1);\n        bytes memory packed2 = Encode.encode256Plus32(a2, b2);\n\n        require(keccak256(packed1) == keccak256(packed2), "Hash of representation should match");\n\n        return (\n            keccak256(packed1),\n            keccak256(packed2)\n        );\n    }\n}\n```
MEDIUM severity: The vulnerability allows malicious users to lock up all leverage vaults offered by Notional, causing. The vulnerability allows malicious users to lock up all leverage vaults offered by Notional, causing a denial-of-service (DoS) by bypassing the BPT threshold and subsequently triggering an emergency settlement against the vaults. This is achieved by exploiting the BPT threshold calculation, which is...

Vulnerable code:
```\nFile: BalancerEnvironment.py\n\n"oracleWindowInSeconds": 3600,\n"maxBalancerPoolShare": 2e3,  # 20%\n"settlementSlippageLimitPercent": 5e6,  # 5%\n```\n```\nFile: BalancerVaultStorage.sol\n\nfunction _bptThreshold(\n    StrategyVaultSettings memory strategyVaultSettings,\n    uint256 totalBPTSupply\n) \n    internal \n    pure \n    returns (uint256) {\n    return (totalBPTSupply * strategyVaultSettings.maxBalancerPoolShare) / BalancerConstants.VAULT_PERCENT_BASIS;\n}\n```\n```\nFile: TwoTokenPoolUtils.sol\n\nfunction _joinPoolAndStake(\n    TwoTokenPoolContext memory poolContext,\n    StrategyContext memory strategyContext,\n    AuraStakingContext memory stakingContext,\n    uint256 primaryAmount,\n    uint256 secondaryAmount,\n    uint256 minBPT\n) internal returns (uint256 bptMinted) {\n    PoolParams memory poolParams = poolContext._getPoolParams(\n        primaryAmount,\n        secondaryAmount,\n        true // isJoin\n    );\n\n    bptMinted = BalancerUtils._joinPoolExactTokensIn({\n        context: poolContext.basePool,\n        params: poolParams,\n        minBPT: minBPT\n    });\n\n    uint256 bptThreshold = strategyContext.vaultSettings._bptThreshold(\n        poolContext.basePool.pool.totalSupply()\n    );\n    uint256 bptHeldAfterJoin = strategyContext.totalBPTHeld + bptMinted;\n    if (bptHeldAfterJoin > bptThreshold)\n        revert Errors.BalancerPoolShareTooHigh(bptHeldAfterJoin, bptThreshold);\n\n    stakingContext.auraBooster.deposit(stakingContext.auraPoolId, bptMinted, true); // stake = true\n}\n```\n```\nFile: VaultState.sol\n\nfunction enterMaturity(\n    VaultState memory vaultState,\n    VaultAccount memory vaultAccount,\n    VaultConfig memory vaultConfig,\n    uint256 strategyTokenDeposit,\n    uint256 additionalUnderlyingExternal,\n    bytes calldata vaultData\n) internal returns (uint256 strategyTokensAdded) {\n    require(vaultState.totalAssetCash == 0);\n}\n```
MEDIUM severity: The `supportsInterface` function is a critical component of a smart contract, responsible for determ. The `supportsInterface` function is a critical component of a smart contract, responsible for determining whether the contract supports a specific interface. This function is designed to return a boolean value indicating whether the contract implements a particular interface, identified by its inter...

Vulnerable code:
```\nfunction supportsInterface(bytes4 interfaceID) public returns (bool) {\n    return interfaceID == ERC20ID || interfaceID == ERC165ID;\n}\n```
MEDIUM severity: The `FujiVaultFTM` contract's balance-changing functions, specifically `withdraw` and `withdrawLiq`,. The `FujiVaultFTM` contract's balance-changing functions, specifically `withdraw` and `withdrawLiq`, demonstrate a lack of separation of concerns and consistency in their implementation. The `withdraw` function, for instance, accepts an `int256` denoted `amount` parameter, which can result in unexpe...

Vulnerable code:
```\nfunction withdraw(int256 _withdrawAmount) public override nonReentrant {\n    updateF1155Balances();\n    _internalWithdraw(_withdrawAmount);\n}\n```\n```\nuint256 amountToWithdraw = _withdrawAmount < 0\n   ? providedCollateral - neededCollateral\n    : uint256(_withdrawAmount);\n```\n```\nfunction withdrawLiq(uint256 _withdrawAmount) external override nonReentrant onlyFliquidator {\n    _withdraw(_withdrawAmount, address(activeProvider));\n    IERC20Upgradeable(vAssets.collateralAsset).transfer(\n        payable(msg.sender),\n        _withdrawAmount\n    );\n}\n```
MEDIUM severity: The `Perpetual` contract inherits from `PerpetualGovernance` and `Collateral`, which declare state v. The `Perpetual` contract inherits from `PerpetualGovernance` and `Collateral`, which declare state variables that are not properly distinguished from local constructor arguments in the `Perpetual` constructor. Specifically, the constructor arguments `globalConfig`, `devAddress`, and `collateral` sha...

Vulnerable code:
```\nconstructor(address globalConfig, address devAddress, address collateral, uint256 collateralDecimals)\n    public\n    Position(collateral, collateralDecimals)\n{\n    setGovernanceAddress("globalConfig", globalConfig);\n    setGovernanceAddress("dev", devAddress);\n    emit CreatePerpetual();\n}\n```
MEDIUM severity: When a user deposits additional funds into their Ichi farming position using the `openPositionFarm(). When a user deposits additional funds into their Ichi farming position using the `openPositionFarm()` function, the existing farming position is closed, and a new one is opened. As part of this process, the ICHI rewards are sent to the `IchiVaultSpell.sol` contract, but they are not distributed to t...

Vulnerable code:
```\nfunction mint(uint256 pid, uint256 amount)\n    external\n    nonReentrant\n    returns (uint256)\n{\n    address lpToken = ichiFarm.lpToken(pid);\n    IERC20Upgradeable(lpToken).safeTransferFrom(\n        msg.sender,\n        address(this),\n        amount\n    );\n\n    if (\n        IERC20Upgradeable(lpToken).allowance(\n            address(this),\n            address(ichiFarm)\n        )!= type(uint256).max\n    ) {\n        IERC20Upgradeable(lpToken).safeApprove(\n            address(ichiFarm),\n            type(uint256).max\n        );\n    }\n\n    ichiFarm.deposit(pid, amount, address(this));\n    uint256 ichiPerShare,, ) = ichiFarm.poolInfo(pid);\n    uint256 id = encodeId(pid, ichiPerShare);\n    _mint(msg.sender, id, amount, "");\n    return id;\n}\n```\n```\nfunction burn(uint256 id, uint256 amount)\n    external\n    nonReentrant\n    returns (uint256)\n{\n    if (amount == type(uint256).max) {\n        amount = balanceOf(msg.sender, id);\n    }\n    (\n        uint256 pid,\n        uint256 stIchiPerShare\n    ) = decodeId(id);\n    _burn(msg.sender, id, amount);\n\n    uint256 ichiRewards = ichiFarm.pendingIchi(pid, address(this));\n    ichiFarm.harvest(pid, address(this));\n    ichiFarm.withdraw(pid, amount, address(this));\n\n    if (ichiRewards > 0) {\n        ICHIv1.safeApprove(address(ICHI), ichiRewards);\n        ICHI.convertToV2(ichiRewards);\n    }\n\n    address lpToken = ichiFarm.lpToken(pid);\n    IERC20Upgradeable(lpToken).safeTransfer(msg.sender, amount);\n\n    (\n        uint256 enIchiPerShare,\n       ,\n       ,\n    ) = ichiFarm.poolInfo(pid);\n    uint256 stIchi = (stIchiPerShare * amount).divCeil(1e18);\n    uint256 enIchi = (enIchiPerShare * amount) / 1e18;\n\n    if (enIchi > stIchi) {\n        ICHI.safeTransfer(msg.sender, enIchi - stIchi);\n    }\n    return pid;\n}\n```\n```\ndoRefund(ICHI);\n```
MEDIUM severity: The `HatsSignerGate` module can be deployed to a Gnosis Safe with an existing number of modules. Whe. The `HatsSignerGate` module can be deployed to a Gnosis Safe with an existing number of modules. When deployed to an existing safe, it retrieves the first five modules from the safe using the `getModulesPaginated` function, which returns a maximum of five modules due to the paginated request. This r...

Vulnerable code:
```\n(address[] memory modules) = GnosisSafe(payable(_safe)).getModulesPaginated(SENTINEL_MODULES, 5);\nuint256 existingModuleCount = modules.length;\n```\n```\n(address[] memory modules) = safe.getModulesPaginated(SENTINEL_OWNERS, enabledModuleCount);\n_existingModulesHash = keccak256(abi.encode(modules));\n```\n```\n(address[] memory modules) = safe.getModulesPaginated(SENTINEL_OWNERS, enabledModuleCount + 1);\n\nif (keccak256(abi.encode(modules))!= _existingModulesHash) {\n    revert SignersCannotChangeModules();\n}\n```