Farseen0/scar-pairs huggingface dataset:
MEDIUM severity: The WAuraPools smart contract contains a vulnerability in its handling of AuraStash tokens. Specific. The WAuraPools smart contract contains a vulnerability in its handling of AuraStash tokens. Specifically, when a user attempts to withdraw their rewards, the contract attempts to transfer each token to the msg.sender using the `safeTransfer` function. However, AuraStash tokens are not regular ERC20...

Vulnerable code:
```\nuint256 rewardTokensLength = rewardTokens.length;\nfor (uint256 i = 0; i < rewardTokensLength; i++) {\n    IERC20Upgradeable(rewardTokens[i]).safeTransfer(msg.sender, rewards[i]);\n}\n```
MEDIUM severity: The `repayBorrow` function in the `ICErc20` contract returns a non-zero uint value when an error occ. The `repayBorrow` function in the `ICErc20` contract returns a non-zero uint value when an error occurs. However, multiple providers fail to check for this error condition, leading to potential security vulnerabilities. This can be exploited by a malicious user to call the `paybackAndWithdraw` funct...

Vulnerable code:
```\nfunction repayBorrow(uint256 repayAmount) external returns (uint256) {\n}\n```\n```\nfunction repayBorrowInternal(uint repayAmount) internal nonReentrant returns (uint, uint) {\n    uint error = accrueInterest();\n    if (error!= uint(Error.NO_ERROR)) {\n        return (fail(Error(error), FailureInfo.REPAY_BORROW_ACCRUE_INTEREST_FAILED), 0);\n    }\n    return repayBorrowFresh(msg.sender, msg.sender, repayAmount);\n}\n```\n```\nif (allowed!= 0) {\n    return (failOpaque(Error.COMPTROLLER_REJECTION, FailureInfo.REPAY_BORROW_COMPTROLLER_REJECTION, allowed), 0);\n}\n\nif (accrualBlockNumber!= getBlockNumber()) {\n    return (fail(Error.MARKET_NOT_FRESH, FailureInfo.REPAY_BORROW_FRESHNESS_CHECK), 0);\n}\n\nRepayBorrowLocalVars memory vars;\n\nvars.borrowerIndex = accountBorrows[borrower].interestIndex;\n\n(vars.mathErr, vars.accountBorrow) = borrowBalanceStoredInternal(borrower);\nif (vars.mathErr!= MathError.NO_ERROR) {\n    return (failOpaque(Error.MATH_ERROR, FailureInfo.REPAY_BORROW_ACCUMULATED_BALANCE_CALCULATION_FAILED, uint(vars.mathErr)), 0);\n}\n```\n```\nrequire(erc20token.balanceOf(address(this)) >= _amount, "Not-enough-token");\nerc20token.univApprove(address(cyTokenAddr), _amount);\ncyToken.repayBorrow(_amount);\n```\n```\nrequire(\n    erc20token.balanceOf(address(this)) >= _amount,\n    "Not-enough-token"\n);\nerc20token.univApprove(address(cyTokenAddr), _amount);\ncyToken.repayBorrow(_amount);\n```\n```\nif (_isETH(_asset)) {\n    ICEth cToken = ICEth(cTokenAddr);\n    cToken.repayBorrow{ value: msg.value }();\n} else {\n    IERC20 erc20token = IERC20(_asset);\n    ICErc20 cToken = ICErc20(cTokenAddr);\n    require(erc20token.balanceOf(address(this)) >= _amount, "Not-enough-token");\n    erc20token.univApprove(address(cTokenAddr), _amount);\n    cToken.repayBorrow(_amount);\n}\n```
MEDIUM severity: The vulnerability in the EigenPodManager's withdrawal mechanism allows for an unfair distribution of. The vulnerability in the EigenPodManager's withdrawal mechanism allows for an unfair distribution of slashing penalties among a subset of users. When a deficit is accumulated in the `podOwnerShares` mapping due to slashing during ETH withdrawal, the penalty is unfairly paid by the next cohort to com...

Vulnerable code:
```\nuint256 balanceBefore = asset.getSelfBalance();\n\naddress[] memory assets = asset.toArray();\nbytes32[] memory roots = new bytes32[](queuedWithdrawalCount);\n\nIDelegationManager.Withdrawal memory queuedWithdrawal;\nfor (uint256 i; i < queuedWithdrawalCount; ++i) {\n    queuedWithdrawal = queuedWithdrawals[i];\n\n    roots[i] = _computeWithdrawalRoot(queuedWithdrawal);\n    delegationManager.completeQueuedWithdrawal(queuedWithdrawal, assets, middlewareTimesIndexes[i], true);\n\n    if (asset == ETH_ADDRESS) {\n        IRioLRTOperatorDelegator(queuedWithdrawal.staker).decreaseETHQueuedForUserSettlement(queuedWithdrawal.shares[0]);\n    }\n}\n\nif (epochWithdrawals.aggregateRoot!= keccak256(abi.encode(roots))) {\n    revert INVALID_AGGREGATE_WITHDRAWAL_ROOT();\n}\n\nepochWithdrawals.shareValueOfAssetsReceived = SafeCast.toUint120(epochWithdrawals.sharesOwed);\n\nuint256 assetsReceived = asset.getSelfBalance() - balanceBefore;\nepochWithdrawals.assetsReceived += SafeCast.toUint120(assetsReceived);\n```\n```\nelse {\n    podOwnerShares[podOwner] += int256(shares);\n    emit PodSharesUpdated(podOwner, int256(shares));\n    return;\n```
MEDIUM severity: The `uniTransferFrom` function in the `UniERC20` contract is designed to facilitate the transfer of . The `uniTransferFrom` function in the `UniERC20` contract is designed to facilitate the transfer of both ERC-20 tokens and ETH. This function accepts four parameters: `token`, `from`, `to`, and `amount`. The function checks if the `amount` is greater than zero and, if so, determines whether the `tok...

Vulnerable code:
```\nfunction uniTransferFrom(IERC20 token, address payable from, address to, uint256 amount) internal {\n    if (amount > 0) {\n        if (isETH(token)) {\n            require(msg.value >= amount, "UniERC20: not enough value");\n            if (msg.value > amount) {\n                from.transfer(msg.value.sub(amount));\n            }\n        } else {\n            token.safeTransferFrom(from, to, amount);\n        }\n    }\n}\n```
MEDIUM severity: This vulnerability is characterized by the presence of methods that return values that are never uti. This vulnerability is characterized by the presence of methods that return values that are never utilized. Specifically, the `investDAI` function internally calls three methods: `_updateTopUsers()`, `_updateLeaderboard(_userTeamInfo.teamAddr)`, and `_updateGroupLeaders(_userTeamInfo.teamAddr)`, whic...

Vulnerable code:
```\n_updateTopUsers()\n_updateLeaderboard(_userTeamInfo.teamAddr)\n_updateGroupLeaders(_userTeamInfo.teamAddr)\n```
MEDIUM severity: The `_calcLiquidation()` method in the contract is responsible for calculating the total liquidation. The `_calcLiquidation()` method in the contract is responsible for calculating the total liquidation discount, collateral to liquidate, and liquidation surcharge. While the calculations appear to be correct in normal scenarios, there is an edge case where the liquidation fails when the price crashes...

Vulnerable code:
```\nuint256 collateralToLiquidateWithoutDiscount = (_debtToLiquidate * (10 ** decimals)) / price;\ncollateralToLiquidate = (collateralToLiquidateWithoutDiscount * totalLiquidationDiscount) / Constants.PRECISION;\n\nif (collateralToLiquidate > _accountCollateral) {\n    collateralToLiquidate = _accountCollateral;\n}\n\nuint256 liquidationSurcharge = (collateralToLiquidateWithoutDiscount * LIQUIDATION_SURCHARGE) / Constants.PRECISION;\n```\n```\nuint256 collateralToLiquidator = collateralToLiquidate - liquidationSurcharge;\n```
MEDIUM severity: The vulnerability lies in the fact that several fields within the `Amp` and `FlexaCollateralManager`. The vulnerability lies in the fact that several fields within the `Amp` and `FlexaCollateralManager` contracts are declared as public, potentially exposing sensitive information. Specifically, the `swapToken`, `swapTokenGraveyard`, `collateralManagers`, and `partitionStrategies` fields in `Amp` are...

Vulnerable code:
```\nISwapToken public swapToken;\n```\n```\naddress public constant swapTokenGraveyard = 0x000000000000000000000000000000000000dEaD;\n```\n```\npublic address[] collateralManagers;\n```\n```\nbytes4[] public partitionStrategies;\n```\n```\nmapping(bytes32 => bool) public partitions;\n```\n```\nmapping (uint256 => Supply) public nonceToSupply;\n```\n```\nmapping(bytes32 => uint256) public withdrawalRootToNonce;\n```
MEDIUM severity: The vulnerability lies in the lack of existence checks for assimilators in the `Loihi` system. Speci. The vulnerability lies in the lack of existence checks for assimilators in the `Loihi` system. Specifically, when a user attempts to withdraw, deposit, or swap tokens, they can specify the addresses of the assimilators for those tokens. The system then performs a lookup in the `assimilators` mapping...

Vulnerable code:
```\nfunction viewNumeraireAmount(address _assim, uint256 _amt) internal returns (int128 amt_) {\n    bytes memory data = abi.encodeWithSelector(iAsmltr.viewNumeraireAmount.selector, _amt);\n    amt_ = abi.decode(_assim.call(data), (int128));\n}\n```
MEDIUM severity: The `Goldigovernor.cancel()` function is vulnerable to incorrect validation, specifically in the che. The `Goldigovernor.cancel()` function is vulnerable to incorrect validation, specifically in the check `if(GovLocks(govlocks).getPriorVotes(proposal.proposer, block.number - 1) > proposalThreshold) revert AboveThreshold();`. This check is intended to ensure that the proposer does not have more votes...

Vulnerable code:
```\nfunction cancel(uint256 proposalId) external {\n    if (_getProposalState(proposalId) == ProposalState.Executed) {\n        revert InvalidProposalState();\n    }\n    Proposal storage proposal = proposals[proposalId];\n    if (msg.sender!= proposal.proposer) {\n        revert NotProposer();\n    }\n    if (GovLocks(govlocks).getPriorVotes(proposal.proposer, block.number - 1) > proposalThreshold) {\n        revert AboveThreshold();\n    }\n    proposal.cancelled = true;\n    uint256 targetsLength = proposal.targets.length;\n    for (uint256 i = 0; i < targetsLength; i++) {\n        Timelock(timelock).cancelTransaction(\n            proposal.targets[i],\n            proposal.eta,\n            proposal.values[i],\n            proposal.calldatas[i],\n            proposal.signatures[i]\n        );\n    }\n    emit ProposalCanceled(proposalId);\n```
MEDIUM severity: The `blacklistProtocol` function in the `Vault` contract is vulnerable to potential issues when atte. The `blacklistProtocol` function in the `Vault` contract is vulnerable to potential issues when attempting to withdraw the underlying balance from the protocol. This function is designed to set a protocol as blacklisted, which involves updating the `currentAllocations` mapping and removing the proto...

Vulnerable code:
```\nfunction blacklistProtocol(uint256 _protocolNum) external onlyGuardian {\n    uint256 balanceProtocol = balanceUnderlying(_protocolNum);\n    currentAllocations[_protocolNum] = 0;\n    controller.setProtocolBlacklist(vaultNumber, _protocolNum);\n    savedTotalUnderlying -= balanceProtocol;\n    withdrawFromProtocol(_protocolNum, balanceProtocol);\n}\n```
MEDIUM severity: The `updateTrust()` function is vulnerable to a potential denial-of-service (DoS) attack due to the . The `updateTrust()` function is vulnerable to a potential denial-of-service (DoS) attack due to the lack of a check on the `vouchers` array. The `maxVouchers` variable is intended to prevent the `vouchees` array from growing excessively and causing a gas explosion issue. However, the `vouchers` arra...

Vulnerable code:
```\nfunction updateTrust(address borrower, uint96 trustAmount) external onlyMember(msg.sender) whenNotPaused {\n    uint256 voucheesLength = vouchees[staker].length;\n    if (voucheesLength >= maxVouchers) {\n        revert MaxVouchees();\n    }\n\n    uint256 voucherIndex = vouchers[borrower].length;\n    voucherIndexes[borrower][staker] = Index(true, uint128(voucherIndex));\n    vouchers[borrower].push(Vouch(staker, trustAmount, 0, 0));\n```
MEDIUM severity: The Teller contract's reclaim functionality allows a malicious receiver to drain all funds from the . The Teller contract's reclaim functionality allows a malicious receiver to drain all funds from the contract by repeatedly calling the reclaim function. This vulnerability arises from the fact that when a receiver calls reclaim, the corresponding option is not burnt, leaving the contract holding mul...

Vulnerable code:
```\nif (msg.sender!= receiver) {\n    revert Teller_NotAuthorized();\n}\n\nif (call) {\n    uint256 amount = optionToken.totalSupply();\n    payoutToken.safeTransfer(receiver, amount);\n} else {\n    uint256 amount = optionToken.totalSupply();\n    uint256 quoteAmount = amount.mulDiv(strikePrice, 10 ** payoutToken.decimals());\n    quoteToken.safeTransfer(receiver, quoteAmount);\n}\n```
MEDIUM severity: The Fixed Term Teller feature in the `BondFixedTermTeller.sol` contract is designed to prevent the c. The Fixed Term Teller feature in the `BondFixedTermTeller.sol` contract is designed to prevent the creation of tokens with an expiry date in the past. This is a fundamental assumption that protocols using this feature rely on, as they build their systems around this constraint. However, a vulnerabil...

Vulnerable code:
```\nif (expiry_ < block.timestamp) {\n    revert Teller_InvalidParams();\n}\n```
MEDIUM severity: The `checkTransaction()` function is responsible for enforcing the Hierarchical Signature Governance. The `checkTransaction()` function is responsible for enforcing the Hierarchical Signature Governance (HSG) logic, ensuring that signers are authorized wearers of hats and meeting the required threshold. The function counts the number of valid signatures (`validSigCount`) and compares it to the safe'...

Vulnerable code:
```\nuint256 validSigCount = countValidSignatures(txHash, signatures, signatures.length / 65);\n\nif (validSigCount < safe.getThreshold()) {\n    revert InvalidSigners();\n}\n```
MEDIUM severity: The vulnerability in the Celer Bridge's refund mechanism allows an attacker to potentially steal fun. The vulnerability in the Celer Bridge's refund mechanism allows an attacker to potentially steal funds from the gateway contract. The issue arises when a refund is processed, and the gateway contract temporarily holds the funds. The attacker can exploit this by calling functions that consume the gat...

Vulnerable code:
```\nif (!router.withdraws(transferId)) {\n    router.withdraw(_request, _sigs, _signers, _powers);\n}\n```\n```\nif (delayThreshold > 0 && wdmsg.amount > delayThreshold) {\n    _addDelayedTransfer(wdId, wdmsg.receiver, wdmsg.token, wdmsg.amount);\n} else {\n    _sendToken(wdmsg.receiver, wdmsg.token, wdmsg.amount);\n}\n```\n```\nfunction bridgeAfterSwap(\n    uint256 amount,\n    bytes calldata bridgeData\n) external payable override {\n    CelerBridgeData memory celerBridgeData = abi.decode(\n        bridgeData,\n        (CelerBridgeData)\n    );\n```\n```\nfunction swapAndBridge(\n    uint32 swapId,\n    bytes calldata swapData,\n    StargateBridgeDataNoToken calldata stargateBridgeData)\n```
MEDIUM severity: The `getImageURIForHat` function is responsible for retrieving the most relevant image URI for a giv. The `getImageURIForHat` function is responsible for retrieving the most relevant image URI for a given `hatId`. The function iterates through the hat's administrative levels, starting from the current level and moving backwards to level 0. If an image URI is found for any of the levels, it is return...

Vulnerable code:
```\nfunction getImageURIForHat(uint256 _hatId) public view returns (string memory) {\n    Hat memory hat = _hats[_hatId];\n    string memory imageURI = hat.imageURI; // save 1 SLOAD\n\n    if (bytes(imageURI).length > 0) {\n        return imageURI;\n    }\n\n    uint256 level = getHatLevel(_hatId);\n\n    if (level == 0) {\n        return baseImageURI;\n    }\n\n    uint256 id;\n    for (uint256 i = level - 1; i > 0; ) {\n        id = getAdminAtLevel(_hatId, uint8(i));\n        hat = _hats[id];\n        imageURI = hat.imageURI;\n        if (bytes(imageURI).length > 0) {\n            return imageURI;\n        }\n        unchecked {\n            --i;\n        }\n    }\n\n    return baseImageURI;\n}\n```
MEDIUM severity: The Ether send function in question is responsible for distributing Ether to multiple recipients whi. The Ether send function in question is responsible for distributing Ether to multiple recipients while ensuring that any remaining balance is refunded to the sender. The function utilizes the `assert` keyword to verify that each recipient's Ether transfer is successful, and also employs the `SafeMat...

Vulnerable code:
```\nfunction sendEth(address payable[] memory _to, uint256[] memory _value) public restrictedToOwner payable returns (bool _success) {\n    require(_to.length == _value.length);\n    require(_to.length <= 255);\n\n    uint256 beforeValue = msg.value;\n    uint256 afterValue = 0;\n\n    for (uint8 i = 0; i < _to.length; i++) {\n        afterValue = afterValue.add(_value[i]);\n        _to[i].send(_value[i]);\n    }\n\n    uint256 remainingValue = beforeValue.sub(afterValue);\n    if (remainingValue > 0) {\n        msg.sender.send(remainingValue);\n    }\n    return true;\n}\n```
MEDIUM severity: The SAVE contract's interest collection mechanism is vulnerable to manipulation, allowing users to e. The SAVE contract's interest collection mechanism is vulnerable to manipulation, allowing users to exploit the system by momentarily staking mAssets and collecting interest at a stale rate. This occurs when a user deposits mAssets shortly before the 30-minute timeframe for interest rate updates expi...

Vulnerable code:
```\nuint256 timeSinceLastCollection = now.sub(previousCollection);\n\nif (timeSinceLastCollection > THIRTY_MINUTES) {\n    // 2. Calculate interest\n    uint256 interest = principal * interestRate * timeSinceLastCollection / (10**18);\n    // 3. Add interest to principal\n    principal += interest;\n    // 4. Update previous collection time\n    previousCollection = now;\n}\n```
MEDIUM severity: The FujiOracle's `_getUSDPrice` function relies on the Chainlink oracle to provide index price infor. The FujiOracle's `_getUSDPrice` function relies on the Chainlink oracle to provide index price information, which introduces inherent risks due to its dependency on a third-party data source. This reliance can lead to outdated data being fed into the index price calculations, potentially crippling t...

Vulnerable code:
```\n/**\n * @dev Calculates the USD price of asset.\n * @param _asset: the asset address.\n * Returns the USD price of the given asset\n */\nfunction _getUSDPrice(address _asset) internal view returns (uint256 price) {\n    require(usdPriceFeeds[_asset]!= address(0), Errors.ORACLE_NONE_PRICE_FEED);\n\n    (, int256 latestPrice,,, ) = AggregatorV3Interface(usdPriceFeeds[_asset]).latestRoundData();\n\n    price = uint256(latestPrice);\n}\n```\n```\n@return updatedAt is the timestamp when the round last was updated (i.e. answer was last computed)\n```
MEDIUM severity: The vulnerability arises from the fact that the reserve ratio calculation in the protocol takes into. The vulnerability arises from the fact that the reserve ratio calculation in the protocol takes into account the portfolio, which is a strategic investment amount that is not available for redemption. This means that even when the reserve ratio is above 100%, users may not be able to fully redeem th...

Vulnerable code:
```\nreserveRatio = ScalingUtils.scaleByBases(\n    allReserves * valueBase / liabilities,\n    valueBase,\n    tokenManager.RESERVE_RATIO_BASE()\n)\n```\n```\nfor (uint256 i; i < tokenCount; i++) {\n    address token = tokenManager.tokenByIndex(tokenTypeValue, i);\n    uint256 tokenReserve = _getBalance(token);\n    uint256 tokenCollateral = IInsurancePool(insurancePool).getCollateral(token);\n\n    if (tokenReserve > 0 || tokenCollateral > 0) {\n        uint256 price = oracle.getLatestPrice(token);\n\n        reserves += _convert(\n            token,\n            baseToken,\n            tokenReserve,\n            MathUpgradeable.Rounding.Down,\n            price,\n            priceBase,\n            token\n        );\n\n        collaterals += _convert(\n            token,\n            baseToken,\n            tokenCollateral,\n            MathUpgradeable.Rounding.Down,\n            price,\n            priceBase,\n            token\n        );\n    }\n}\n```\n```\nfor (uint256 i; i < tokenCount; i++) {\n    address token = tokenManager.tokenByIndex(tokenTypeValue, i);\n    uint256 tokenSupply = IERC20Token(token).totalSupply();\n\n    if (token == baseToken) {\n        liabilities += tokenSupply;\n    } else if (tokenSupply > 0) {\n        uint256 price = oracle.getLatestPrice(token);\n\n        liabilities += _convert(\n            token,\n            baseToken,\n            tokenSupply,\n            MathUpgradeable.Rounding.Down,\n            price,\n            priceBase,\n            token\n        );\n    }\n}\n```
MEDIUM severity: The `TxFinalizationVerifier` abstraction, which is used in the plasma exit game contracts, is a comp. The `TxFinalizationVerifier` abstraction, which is used in the plasma exit game contracts, is a complex and convoluted implementation that introduces unnecessary branching logic and requires multiple files to be understood. The abstraction is centered around the `TxFinalizationModel` struct, which i...

Vulnerable code:
```\n/**\n * @notice Checks whether a transaction is "standard finalized"\n * @dev MVP: requires that both inclusion proof and confirm signature is checked\n */\nfunction isStandardFinalized(Model.Data memory data) public view returns (bool) {\n    if (data.protocol == Protocol.MORE_VP()) {\n        return checkInclusionProof(data);\n    } else if (data.protocol == Protocol.MVP()) {\n        revert("MVP is not yet supported");\n    } else {\n        revert("Invalid protocol value");\n    }\n}\n```\n```\n/**\n * @notice Checks whether a transaction is "protocol finalized"\n */\nfunction isProtocolFinalized(Model.Data memory data) public view returns (bool) {\n    if (data.protocol == Protocol.MORE_VP()) {\n        return data.txBytes.length > 0;\n    } else if (data.protocol == Protocol.MVP()) {\n        revert("MVP is not yet supported");\n    } else {\n        revert("Invalid protocol value");\n    }\n}\n```\n```\nfunction checkInclusionProof(Model.Data memory data) private view returns (bool) {\n    if (data.inclusionProof.length == 0) {\n        return false;\n    }\n\n    (bytes32 root,) = data.framework.blocks(data.txPos.blockNum());\n    bytes32 leafData = keccak256(data.txBytes);\n    return Merkle.checkMembership(\n        leafData,\n        data.txPos.txIndex(),\n        root,\n        data.inclusionProof\n    );\n}\n```\n```\nfunction verifyAndDeterminePositionOfTransactionIncludedInBlock(\n    bytes memory txbytes,\n    UtxoPosLib.UtxoPos memory utxoPos,\n    bytes32 root,\n    bytes memory inclusionProof\n)\n    private\n    pure\n    returns (uint256)\n{\n    bytes32 leaf = keccak256(txbytes);\n    require(\n        Merkle.checkMembership(leaf, utxoPos.txIndex(), root, inclusionProof),\n        "Transaction is not included in block of Plasma chain"\n    );\n\n    return utxoPos.value;\n}\n```
MEDIUM severity: The vulnerability arises from the ability to manipulate the `expectedRewards` variable in the `close. The vulnerability arises from the ability to manipulate the `expectedRewards` variable in the `closePositionFarm` function of the AuraSpell contract. This variable is used to determine the amount of tokens to be swapped in a specific order. However, the function does not properly validate the `expec...

Vulnerable code:
```\nif (\n    expectedRewards[i]!= 0 &&\n   !PSwapLib.swap(\n        augustusSwapper,\n        tokenTransferProxy,\n        sellToken,\n        expectedRewards[i],\n        swapDatas[i]\n    )\n) {\n    revert Errors.SWAP_FAILED(sellToken);\n}\n_doCutRewardsFee(sellToken);\n```