Skip to content

Sherlock

Elfi

Every publicly disclosed report for Elfi and what kind of bugs they were.

disclosed reports
57
most reported class
Business logic
bug classes found
4
first disclosure
2024
Find Elfi on bugbounty.fyi Current scope, rewards and status, if it runs a public program.

Disclosed reports

Newest first. Only what Elfi chose to make public.

Misconfiguration

Future upgrades may be difficult or impossible

The protocol stores data in nested structs within a Diamond proxy storage scheme, which could make future upgrades difficult or impossible without corrupting existing data. An attacker cannot directly exploit this, but future upgrades could lead to data inconsistency and improper system operation.

Elfi

Medium
Business logic

The USer will receive less amount than user expected

The redemption function checks the minimum redeem amount before deducting the fee, so the user can receive less than the specified minimum. An attacker could exploit this to receive a smaller payout than expected.

Elfi

Medium
Business logic

Closing partial positions miscounts the settled fees

When a user partially closes a leveraged position, the settled fees are divided by the decrease quantity twice, leading to incorrect calculation of settled margin and profit/loss. This makes partial closes more profitable when fees are positive and full closes more profitable when fees are negative.

Elfi

High
Business logic

Position net value is using outdated fees

The protocol calculates a position's net value using fee values that are only updated when someone interacts with the market, so the net value can be stale. An attacker could exploit this delay to cause late liquidations, potentially leading to protocol insolvency in extreme cases.

Elfi

High
Business logic

Increasing leverage can make the position have "0" `initialMargin`

Increasing leverage on a cross-margin position can reduce the position's initial margin to zero because the margin reduction is calculated using the current token price, which may have dropped. This allows the position to avoid paying borrowing fees and, in another case, lets isolated accounts close losing positions to recover their initial margin.

Elfi

High
Business logic

Pool value calculation skips accounting for stable token losses and short uPnL

The pool's total value calculation skips stable token losses and unrealised profit and loss (uPnL) when both the stable token amount and unsettled amount are zero, which can happen after closing an isolated short position in profit. This leads to an incorrect pool value, causing unfair share minting and redemption.

Elfi

High
Business logic

Incorrect settleFee process for cross-margin account

The settle fee for cross-margin positions is processed twice in `_settleCrossAccount`, once by subtracting it and then adding it back when PnL is positive, so traders do not pay the fee. Additionally, a negative sum of PnL and settle fee can cause a cast failure and revert the decrease order.

Elfi

Medium
Business logic

If stable tokens depeg, short funding fees will not be accounted properly

The protocol calculates short position funding fees in USD terms but settles them using the current token price, so if a stablecoin depegs the fees are not fairly accrued. An attacker could exploit this by closing or holding positions to gain an unfair advantage when the peg fluctuates.

Elfi

Medium
Business logic

LpPool's can become insolvent if shorters are in huge profits

The pool's available liquidity calculation ignores unrealised losses from profitable short positions, so it can lend out more than it actually has. An attacker could open long positions that the pool cannot cover, leading to insolvency when shorters realise profits.

Elfi

High
Business logic

Traders may decrease the loss via decrease the position's margin

The margin reduction function did not account for the position's current profit and loss, allowing a trader to withdraw more margin than they should when the position was near liquidation. This let the trader recover funds that would otherwise be lost, reducing the expected profits of liquidity providers.

Elfi

High
DoS

Lack of oracle setting in autoReducePositions

The autoReducePositions function lacks a call to set the oracle price, so it always reverts with PriceIsZero when trying to close positions. An attacker could not directly exploit this, but the risk control mechanism fails, increasing system risk in extreme market conditions.

Elfi

Medium
Business logic

Unbacked tokens can be used for opening positions

The protocol's pool liquidity calculation incorrectly includes unsettled funding fees, allowing a user to open a leveraged position that exceeds the pool's actual available liquidity. An attacker could exploit this to borrow more than the pool truly has, potentially causing a shortfall when positions are closed.

Elfi

Medium
Business logic

Users can use weth to replace any margin token in createUpdatePositionMarginRequest()

The createUpdatePositionMarginRequest function lacks validation that when a user pays with native ETH (isNativeToken true), the margin token must be WETH. An attacker can deposit ETH but have the request recorded with a different margin token, causing the system to later transfer that other token from the trade vault, potentially profiting or blocking other users' requests.

Elfi

High
Business logic

Keepers can open positions that are already liquidatable

The protocol does not check whether a newly opened position would be immediately liquidatable. An attacker could open a position that is already liquidatable, potentially causing protocol insolvency if the liquidation loss exceeds the collateral.

Elfi

High
Business logic

Incorrect implementation of the `PositionMarginProcess.updatePositionFromBalanceMargin()` function

The function `updatePositionFromBalanceMargin()` incorrectly returns early when the position's initial margin equals the margin from balance and the amount is negative, so it fails to reduce the margin from balance. This allows users to withdraw assets without reducing their position margin, enabling them to utilise more tokens than they deposited.

Elfi

High
Business logic

Pool value does not consider the open funding fees

The pool's value calculation omits accrued but unsettled funding fees, so when a position is closed and those fees are added to the pool's unsettled amount, the pool value spikes without a corresponding change in share supply. An attacker could sandwich a closing position to exploit the temporarily inflated pool value when minting or redeeming shares.

Elfi

High
DoS

redeem stake token may be Dos because there is not enough balance in stake pool

The stake pool's LP vault may not hold enough tokens to cover redemptions because deposits made with isCollateral=true are sent to the portfolio vault instead. An attacker can deposit with isCollateral=true to inflate their LP share, then redeem from the LP vault, causing other LP holders' redemptions to revert due to insufficient balance.

Elfi

High
Business logic

`updateAllPositionFromBalanceMargin` function mistakenly increments positions "fromBalance"

The function that updates the 'from balance' margin of other positions when one is closed incorrectly uses the original amount for each position instead of the remaining amount, causing over-increment of 'from balance' values. This can make cross-account values incorrect, reducing available margin or increasing borrowing power.

Elfi

High
Business logic

Attacker can inflate stake rewards as he wants

The reward calculation used the account's token balance instead of the staked amount, so an attacker could transfer stake tokens between accounts to inflate rewards. This allowed claiming rewards multiple times for the same stake.

Elfi

High
Business logic

Keepers loss gas is never accounted

The gas fee processing function incorrectly calculates the loss fee when the actual execution fee exceeds the user's provided fee, always resulting in zero loss fee. This means keepers' excess gas losses are never recorded, causing them to lose funds over time.

Elfi

Medium
Business logic

Contract will reach a point where users will not be able to call `deposit`

The contract tracks total collateral per token by only increasing it on deposits and never decreasing it on withdrawals, so the tracked total eventually exceeds the collateral cap and blocks further deposits of that token. An attacker could not directly exploit this, but normal usage would cause a denial of service for deposits.

Elfi

Medium