Skip to content
Business logic Audit finding Intermediate

Loss of funds with high liquidExitPenalty

The TrueFi yield strategy can incur a withdrawal fee of up to 10%, and if the owner calls liquidExit at a time when this fee is high, user funds are lost. This can happen intentionally by a rogue admin or benignly when many users withdraw at once and USDC must be made available regardless of the penalty.

defsec Follow with Chom and sirhashalot

Originally disclosed on Sherlock

Source: https://github.com/sherlock-audit/2022-09-sherlock-judging/tree/main/012-M

Found by

defsec, Chom, sirhashalot

Summary

A high liquidExitPenalty fee percentage in the TrueFi protocol can result in a loss of user funds. The issue is that only the Sherlock contract owner can set the yieldStrategy in use and call liquidExit to withdraw funds from TrueFi. A withdrawal from the TrueFi yield strategy with unfavorable withdrawal fees can occur in the event that yieldStrategy is set to TrueFi and liquidExit is called with high withdrawal fees. This could be done intentionally by a rogue admin (centralization risk) but it can also happen in a benign manner when many users want to withdraw funds at the same time and USDC must be made available to them, regardless of the exit penalty fee.

Vulnerability Detail

TrueFi has a variable withdrawal fee. The specific numbers are in this spreadsheet, with a maximum fee of 10%. There is a large comment block in the TrueFi strategy explaining how this strategy will keep the withdrawal fee small. The problem underlying this strategy as it is coded is that a withdrawal at the wrong time can result in substantial loss of user funds. In a worse case scenario, it could lead to a bank run where some users are unable to get their deposits back because so much is lost to fee.

There is another substantial risk in lending to the TrueFi protocol. The risk is that TrueFi borrowers do not pay back their undercollateralized loans. This risk is clearly identified in the TrueFi documentation. While this risk may be unlikely with the current list of TrueFi borrowers, Sherlock must monitor new borrowers in the TrueFi ecosystem over time to assure that the risk level remains low.

Impact

The TrueFi strategy can result in loss of user deposits in certain circumstances.

Code Snippet

The function that the owner can use to set the yield strategy https://github.com/sherlock-protocol/sherlock-v2-core/blob/355c70df23aa9aa7d46567c9540a6d15be93fcab/contracts/Sherlock.sol#L272-L280

The function that the owner can use to withdraw funds from TrueFi https://github.com/sherlock-protocol/sherlock-v2-core/blob/355c70df23aa9aa7d46567c9540a6d15be93fcab/contracts/strategy/TrueFiStrategy.sol#L155-L185

Tool used

Manual Review

Recommendation

The TrueFi strategy is higher risk than other strategies for Sherlock staking. This level of risk may not be acceptable to some users because of the risk of loss of funds. If this strategy is to be used, Sherlock must insure its deposits in TrueFi to avoid losing user's deposits because Sherlock's reputation is on the line.

The original report as published on Sherlock, by defsec. Images and videos are our own copies; raw HTML is shown as text. View it on Sherlock.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

How it worked

Root cause

Likely the strategy does not guard against withdrawing from TrueFi when the variable exit penalty is high, and only the contract owner can trigger the withdrawal.

Impact

The TrueFi strategy can result in loss of user deposits in certain circumstances, potentially causing a bank run where some users cannot get their deposits back.

What the attacker needed

YieldStrategy set to TrueFi; owner calls liquidExit; high withdrawal fee at that time

The fix

The report recommends that if the TrueFi strategy is used, Sherlock should insure its deposits in TrueFi to avoid losing user deposits.

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

A yield strategy is a way for a protocol to put idle money to work to earn interest. TrueFi charges a fee when money is taken out, and that fee can be as high as 10%. If the person who controls the strategy withdraws at a bad time, part of the users' money is lost to that fee.

What is Business logic?

The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.

More by defsec

View all

16 more disclosed reports, best first.

More from Sherlock

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Business logic flaws

The lesson behind this report.

The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.