Open hats-bug-reporter[bot] opened 1 month ago
This is not a "sandwhich attack", this is someone providing "just in time" liquidity, which is behavior that is useful and to be rewarded, and the "attacker" is rightly getting rewarded. for that.
More precisely, the "attacker" has exactly the same risks and costs (i.e. deposit fees, impermanent loss) as all other LP providers. The "attack" will probably not be profitable anyway (as usually the cost of IL alone will be higher than the profit from the fees) The extra liquidity is good for the trader, who will have less slippage.
How about profiting from donate_admin_fees ? Attacker's liquidity has added no value to the protocol ? The reason I combined this 2 vulns into 1 report is because the root cause is the same ...
Ok, I missed that part :) So the issue here would be not about normal users losing value, but for an attacker to siphon of part of the admin fees, if these are donated to the pool. Your proposed solution does not really work here, though, both because (a) we definitely want to allow for (very) short term liquidity and (2) it would only mitage, not solve, this problem. I am not sure if an in-contract solution exists, and perhaps it is not even necessary: given that this is an admin function, it is probably called by a knowledgeable users, that can use private mempools if frontrunning becomes a problem.
I want to focus on the admin function vulnerability. You have stated that , "given that this is an admin function, it is probably called by a knowledgeable users, that can use private mempools if front-running becomes a problem." This report has stated that the donate_admin_fees is prone to front-running, therefore it is not in order to state that the admin can use private mempools IF front-running becomes a problem. It is now a known vulnerability.
"it is probably called by a knowledgeable users, that can use private mempools' - I think this statement also not in order. Your statement is an after-thought using information from the report. This contest was NOT aware of the vulnerability reported here. The list of known issues section on the contest page does not mention this vulnerability and neither do the docs nor the function's NatSpec. Any researcher would therefore fairly believe that admin would have no cause to use private mempools. The strongest reason why someone would use a private mempool would be front-running- AFTER knowing that they're prone.
I don't understand why you say that the attacker would siphon part of admin fee. Your comment suggests that there's a partition between swapping fee and tokens that have been donated by admin. I don't think the protocol works that way. The reality is that attacker would benefit from an increase in the pool fees just like any LP provider.
My suggested fix might not be a permanent solution, otherwise that would require developing more complex fee-sharing mechanisms. A suggested fix in this contest is desirable if the reporter can provide one.
My main point here was that there is no clear on-chain fix to the problem of front-running a call to donate_admin_fees
, while there are off-chain solutions, and so the problem cannot be seen as an issue with the code.
Ok. I believe that this report has served its purpose, i.e. surface a vulnerability that technically allows non-LP providers to earn from admin donations, basically stealing a share from other LP providers. As to the perfect solution, there are several possible approaches. This is a task that the protocol should consider to protect worthy LP providers.
I think I have figured out the perfect solution:
This approach ensures that only intended beneficiaries receive the rewards.
Github username: -- Twitter username: -- Submission hash (on-chain): 0xc119c58d4d3d2a6025d253b920d4a945b12a90fd3e30cb7591ae2b485893ecd9 Severity: high
Description: Description\ One factor that influences traders to use a specific platform for swapping tokens is the depth of liquidity available. The more the avalable liquidity, the better the price, less price impact and higher chances of executing high-volume trades. Many protocols incentive this behaviour while protecting it at the same time.
Thorn protocol looks to be vulnerable to this exploit, allowing providers to deposit and withdraw at will. The effect is that savvy providers can reap benefits where they have risked none.
This vulnerability is also present with the StableSwapTwoPool::donate_admin_fees method where the admin is expected to donate fee to LP providers Attack Scenario\ Consider the following scenario:
a back-run call that withdraws all coins plus rewards gained
The effect is that the savvy trader has risked none while sharing benefits with other LP providers.
Attachments