Adding liquidity can be `DoS`ed due to calculation mismatches
A rounding mismatch between the router's mint amount calculation and the vault/module's deposit calculation causes the module to request more tokens than the router holds, reverting the transaction. An attacker could repeatedly trigger this to prevent users from adding liquidity through the router.
When users add liquidity, they send tokens to the ArrakisPublicVaultRouter contract. The ValantisHOTModulePublic contract then takes the required tokens from the ArrakisPublicVaultRouter contract. However, due to a calculation mismatch, the required amount is often greater than the user-sent amount, causing the transaction to be reverted.
Vulnerability Detail
Let's consider following scenario:
The current state:
pool: reserve0 = 1e18 + 1, reserve1 = 1e18 + 1
vault: totalSupply = 1e18 + 1
Bob calls the ArrakisPublicVaultRouter.addLiquidity() function with the following parameters:
at L79, L80, it takes token0 and token1 from the router in amounts of 1e18 each
Finally, the process fails because there is only 1e18 - 1 in the router, as mentioned in step 4.
This problem occurs because the calculations in the ArrakisPublicVaultRouter._getMintAmounts() function rely on rounding down. In contrast, the proportion calculation in the ArrakisMetaVaultPublic.mint() function and the amount calculations in the ValantisHOTModulePublic.deposit() function are based on rounding up.
Impact
Adding liquidity can be DoSed due to the calculation mismatches.
The ArrakisPublicVaultRouter._getMintAmounts() function should be updated to return the accurate required amounts.
Discussion
KupiaSecAdmin
Escalate
The severity of this issue should be high, as the probability of the calculation mismatch occurring is quite high.
sherlock-admin3
Escalate
The severity of this issue should be high, as the probability of the calculation mismatch occurring is quite high.
You've created a valid escalation!
To remove the escalation from consideration: Delete your comment.
You may delete or edit your escalation comment anytime before the 48-hour escalation window closes. After that, the escalation becomes final.
WangSecurity
In Sherlock, we don't judge issues based on the probabilities. As I understand there's no material loss, but the issue has serious non-material losses, cause as I understand, it's possible that there will always be users who cannot deposit due to this issue. Hence, I agree that high severity is appropriate here, planning to accept the escalation and upgrade severity to high.
Gevarist
Valid finding, for us it's a low level finding.
CergyK
In Sherlock, we don't judge issues based on the probabilities. As I understand there's no material loss, but the issue has serious non-material losses, cause as I understand, it's possible that there will always be users who cannot deposit due to this issue. Hence, I agree that high severity is appropriate here, planning to accept the escalation and upgrade severity to high.
This should remain medium, as there is no loss of funds.
In the hypothetical case some deposit absolutely has to be carried on, the simple work-around of sending some DUST of tokens to the contract would unlock the situation.
It seems that Sherlock has a new rule to identify high issues which is cited here:
2. Inflicts serious non-material losses (doesn't include contract simply not working).
Which seems inconsistent with how to identify a medium issue:
2. Breaks core contract functionality, rendering the contract useless or leading to loss of funds.
As the rule to identify the medium issue uses a higher impact?
KupiaSecAdmin
@CergyK
In the hypothetical case some deposit absolutely has to be carried on, the simple work-around of sending some DUST of tokens to the contract would unlock the situation.
Sending DUST of tokens cann't resolve the problem.
In the _addLiquidity() function of the router contract, the contract approves tokens to the module. Subsequently, in the deposit() function of the module, the module brings those tokens from the router contract. For the transaction to succeed, the router contract must approve enough tokens to the module. Therefore, only sending tokens cannot resolve the problem.
Impossibility of deposit should be considered as a HIGH severity issue.
CergyK
@CergyK
In the hypothetical case some deposit absolutely has to be carried on, the simple work-around of sending some DUST of tokens to the contract would unlock the situation.
Sending DUST of tokens cann't resolve the problem.
In the _addLiquidity() function of the router contract, the contract approves tokens to the module. Subsequently, in the deposit() function of the module, the module brings those tokens from the router contract. For the transaction to succeed, the router contract must approve enough tokens to the module. Therefore, only sending tokens cannot resolve the problem.
Impossibility of deposit should be considered as a HIGH severity issue.
Ok I see. Indeed depositing would be impossible in that case.
Still this is a medium severity issue since it is a DOS of a core functionality, but no loss demonstrated
KupiaSecAdmin
IV. How to identify a high issue:
2. Inflicts serious non-material losses (doesn't include contract simply not working).
Based on the judging rule, I think the issue deserves high severity, because it inflicts serious non-material losses, which is not contract simply not working.
0xjuaan
@KupiaSecAdmin that rule actually says that there must be a non material loss other than the contract simply not working.
Since this bug simply causes a function to not work, I agree with @CergyK that this should be medium.
WangSecurity
@0xjuaan could you please elaborate? The rule says non-material losses, excluding the contract simply not working. Here, the contract is working, but the deposits are DOSed?
Also, another question, are the contracts upgradable and in reality could this issue be solved by updating the contract?
0xjuaan
It seems similar to this issue which is medium severity.
From what I understand, the rules say that the non-material loss must not be that a contract/function simply is not functional. However in this bug, that is the impact.
Note I did submit this so am not incentivised to disagree with the escalation, but it based on the rules I don't see any way this can be high severity.
WangSecurity
@0xjuaan could you please elaborate on what do you think includes "serious non-material losses"? So I can better understand how I can explain my decision better.
WangSecurity
The decision remains the same. I believe in that case it's not just a function simply doesn't work, but deposits into protocol are DOSed, hence, it's serious non-material losses. Planning to accept the escalation and upgrade severity to high.
0xjuaan
Honestly I still think @CergyK's stance is correct since deposits are technically not DoS'd, they can occur via the vault directly.
I do benefit from it being converted to H though so I don't mind either way.
@0xjuaan could you please elaborate on what do you think includes "serious non-material losses"? So I can better understand how I can explain my decision better.
One possible interpretation is that the line in the Sherlock rules:
Inflicts serious non-material losses (doesn't include contract simply not working).
was added to enable high severity issues in protocols which are not handling financial assets (SocialFi, data-availability). Otherwise it is too vague, and can be applicable to any valid issue (low, medium, high).
WangSecurity
Honestly I still think @CergyK's stance is correct since deposits are technically not DoS'd, they can occur via the vault directly.
Hm, I may have misunderstood that point. As I understand @CergyK talks about sending dust amounts to the contract, to mitigate the DoS. But this was answered here, which @CergyK agreed with. If I’m missing something please correct.
was added to enable high severity issues in protocols which are not handling financial assets (SocialFi, data-availability)
Fair point, but I still believe DOS of depositing into the protocol is indeed serious non-material loss.
But correct me on the first if I’m wrong.
WangSecurity
The decision remains the same. Planning to accept the escalation and upgrade severity to high.
The original report as published on Sherlock, by KupiaSec. 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.
Generating the AI write-up for this report.
This usually takes about a minute. You can read the original meanwhile; this page updates itself.
Writing the technical write-up
Writing the version for beginners
Checking every passage against the original
How it worked
Root cause
Likely the router's mint amount calculation rounds down while the vault's proportion and the module's deposit amount calculations round up, so the module requests slightly more tokens than the router received.
Impact
Adding liquidity through the router can be blocked (denial of service) because the transaction reverts; the text notes deposits may still occur via the vault directly.
What the attacker needed
Pool reserves and vault supply cause rounding mismatch; user adds liquidity through the router
The fix
The router's mint amount calculation should be updated to return the accurate required amounts; the text states the protocol team fixed this issue in a pull request.
How it was found
The pool and vault hold amounts whose total supply is one unit larger than the reserves, so rounding differs.
Bob calls the router's addLiquidity with maximum amounts equal to the reserves.
The router calculates shares and token amounts by rounding down and pulls those amounts from Bob.
The router calls the vault's mint, which recalculates the proportion and calls the module's deposit.
The module recalculates the token amounts by rounding up, requesting one more unit than the router holds.
The token transfer from the router to the module fails and the transaction reverts.
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.
Generating the AI write-up for this report.
This usually takes about a minute. You can read the original meanwhile; this page updates itself.
Writing the technical write-up
Writing the version for beginners
Checking every passage against the original
When you add money to a shared pool, the system calculates how many pool shares you get and how many tokens it needs to take from you. Here two parts of the system did that maths slightly differently: one rounded down, the other rounded up. The second part asked for one more unit of each token than the first part had collected, so the whole transaction failed and nobody could add liquidity through that route.
What is DoS?
A request that exhausts resources or crashes a component. Many programs forbid testing it; reports usually show it from code, not by attacking.