-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
0x37 - Healthy positions may be liquidated because of inappropriate judgment #17
Comments
Escalate Issue should be low/info. It only covers an extreme edge case where |
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. |
The impact is high even if the likelihood is low(Not extremely low). Therefore it is submitted as medium. You can't say it is going to be liquidated in the next block anyway by simply ignoring other possibilities. How do you certain of that? How about if the user wants to add liquidity and protect his position when it is close to threshold?or if the price goes towards the direction of user's position when exact time equal to pnl.remaining? If the point being questioned here is the low probability, There are accepted reports with different roots which include similar edge case in previous contests. Here is an example:code-423n4/2023-10-nextgen-findings#1323 . Here is another one in recent contest accepted by the judge:https://codehawks.cyfrin.io/c/2024-08-fjord/results?lt=contest&page=1&sc=xp&sj=score&t=report. |
I agree, the issue is a low at best, even the impact is not a high as when being on such fine edge is synonym for liquidatable, I agree with spacegliderr comment as this means it'll be liquidated in the next block due to fees |
The code allows to this edge case happen. Even if it happens only once, there is loss for users, hence making the impact high. Beside the tx can be observed by the malicious actors and manipulated based on this case. Therefore it deserves M and a fix |
Extremely unlikely edge case on the P&L? that isnt true.
Due to fees? That isnt the same scenario the round down of the healthy position here will be considerable plus the total liquidated amount. edit: i suspect you have misunderstood the reason being if the position is liquidated wrong they cannot re-liquidate it again or not during the next block even if the position theoretically is still healthy for how long after false liquidation then any given position then if they do liquidated some position 'by fees' during the next block I doubt it will still be the same position. The auditors here have clearly specified code-423n4/2023-07-tapioca-findings#1164 |
After confirming, this comment is outdated:
The code works as intended and the position should be liquidated when PnL equals |
@WangSecurity what of issue validity rules; "If the protocol team provides specific information in the README or CODE COMMENTS, that information stands above all judging rules. In case of contradictions between the README and CODE COMMENTS, the README is the chosen source of truth." Hence this is valid. For example iamnmt Why is the rule "List of Issue categories that are not considered valid" applied but not this rule? finding was awarded for 2024-06-magicsea-judging and was rewarded and many additional findings only just recently for 2024 findings. The comments that are provided during the contest code will prioritised according to the rules. Thus we will validate this finding regardless. |
@WangSecurity logically if the remaining value is equal to the required value, the position should not be liquidated. I do not think it is reasonable simply invalidate that a submission based on the comment. The comment, the function names and docs can lie, what is important is that what the code allows. In this case the code allows the user to be liquidated while it shouldn't , because the user has enough collateral. Besides the user may protect their position towards the threshold, but current implementation takes this chance from user. On the other hand, as ı said above it is not logical to invalidate/validate based on the comments provided, however for a second let's focus on "outdated" concept and look at a more critical example. If an outdate concept is enough to invalidate a bug, how about if an outdated function left in the code that leads to a critical exploit? Is it reasonable to invalidate the all reports that are submitted in this case? Based on your reasoning, we should be able to invalidate this case as well. But It is protocol's responsibility to remove the outdated function before the contest in this case. What auditor or judges should pay attention is that does the provided code allows an exploit or not? if yes, then it should be valid. |
@sabatha7
Here, the comment is outdated. Hence, the rules apply. About other findings, firstly, historical decisions are not sources of truth. Secondly, it's hard to understand exactly what you mean by that since there's no reference (i.e. link).
The key part is that the current behaviour is intended and the user should be liquidatable when remaining == required. Hence, here the protocol works as expected.
I don't see how this part provides any value to the discussion and it's not relevant here.
This is a completely different protocol, completely different issue and here we have nothing to do with "deprecated function".
This is not a loss of funds because the user has to be liquidatable at this point. It's not the mistake in the code and it works as intended here.
The issue you referenced is completely different, it was validate on a completely different rule and is irrelevant here. Also, don't forget that historical decisions are not sources of truth. Planning to accept the escalation and invalidate the issue. |
That can be said if you accept that the comment is outdated and current implementation is intended, which was not known to auditors during the contest. Also, I would appreciate it if you could provide any information on how you determined the comment was outdated. Was this simply communicated by the protocol after submissions?
This is pointing out that it is unreasonable to validate or invalidate an issue while ignoring the code and focusing on the outdated comment. It aligns with what is stated here:
The example shows that the code is more important than the comments.
Again, it is not considered a loss of funds because it is regarded as intended behavior, based on the claim of an "outdated comment," which was likely made by the protocol after the contest. This was neither mentioned in the README nor publicly discussed in the Discord during the contest. Please correct me if I am wrong on this. In conclusion, if your reasoning for invalidation is still simply based on the 'outdated comment,' I have nothing further to discuss. |
@WangSecurity Thank you for announcing these valid suggestions.
|
Yes, I've clarified with the sponsor if the code comment was correct and the code worked incorrectly. It ended up the opposite and the code works correctly. But that's sufficient contextual evidence to apply the rule about outdated code comments that I've shared in the previous comment. Any Watson could do the same during the contest.
It doesn't necessarily mean that the code is more important than code comments. And I don't validate/invalidate the finding based on the code comment being outdated or not. I invalidate this finding based on the fact that the code works as intended and it's only a recommendation to consider changing from
As said above, it's the contextual evidence that makes the comment outdated. @sabatha7 Thank you for elaborating on the finding here, but, unfortunately, the code works correctly here and it's only a recommendation, as said above. Planning to accept the escalation and invalidate the issue. |
Thank you. How could one have audited a Black Box context. Please clarify on the context. Clearly an additional amount is being subtracted from the remaining pnl prematurely. To say rounding down a healthy position is the intended behavior context even if that rounding down breaches 1% lost is that what we are justifying i.e are we suggesting that a jump from remain equals requaired to remain < required can not greater than 1% movement? Please observe your response since a movement < 1% can generate a loss of 100% of the remaining position also pnl is allowed to float and tokens are allowed to dump or hike greatly there is absolutely no reason to liquidated the position here regardless of the final bias of the judgement . |
Again kindly show how it is; "working correctly" . The formula is hardcoded to show that the position is still healthy when remaining is equal to required kindly show how this isn't true. #12 was given valid high. The poc refers to negative p&l please accurately define negative p&l. also #12 is invalid and highly unlikely and works as intended there is no guarantee and incentive for anyone to do that . This #17 is the 0x37 finding that is valid tbh. |
pleading for fair treatment and neutral biases. |
This issue is not about "additional amount is being subtracted from the remaining pnl prematurely" or rounding down. The issue is solely about using
The formula is not
#12 is a completely different issue with nothing to do with this.
The judgement is not biased and is fair. I honestly see this issue as invalid and not biased towards any of the outcomes. The decision remains: accept the escalation and invalidate the issue. |
I honestly trust you are right. See what I was referring The formula is kinda hardcoded to show that the position is still healthy when remaining is equal to required I was referring to the valuation operations (liquidatable function will accept the result of the best valuation of the position given as pnl remaining at which point losses fees are accounted already thus pnl remaining == required is healthy)
We are to try our best effort that will be to unpin #17 as the main finding and try to pin #67 in its place such as #67 refers better to the matters of the pnl remaining balance, and prematurely subtracting in the root cause. If that would be in the best interest. |
Unfortunately, it doesn't change the fact that
#67 doesn't refer to anything like this. #67 just pasted the My decision remains, accept the escalation and invalidate the issue. |
Glad to be on your side. Edit:
in terms of #67 I was looking at the portion where #67 goes In other words for each different movement of price we are accounting 1% each time . In other words #67 was suggesting the threshold is already configuring some floor level and the threshold is as balanced as it needed to be in terms of as far as the threshold is concerned then there was non actual need to reach into the healthy amount at this point considering that pnl remaining == required is alright and saying that it isn't alright will actually forces a 1% movement (might as well be paying an additional fees or forcefully paying a 1% tips toward the protocol at the expense of the position without any actual consent / I wish to alleviate that the 1% is not on the position valuation when we reconcile rather the 1% entails the different movements or if you could possibly have len(n)*1% movements then len(n-1)*1% robs you an allocated movement or there is a round down it would have been an issue of wrong logistics (wrong liquidation) rather than an issue of wrong parcel (a position missing 1% in the contents) thus a parcel being delivered to a wrong pointer address causing unexpected consequences (the position is wrongfully lost altogether).
#58 also referred to the concern for proper balancing of the amounts where Inappropriate additional amounts / deductions are concerned. |
#67 doesn't identify any issues as I've said before. #67 just lists the function and says the position is liquidatable if remaining==required. Hence, my decision is as was previously stated: accept the escalation and invalidate the reports because there's no issue. The decision will be applied in a couple of hours. |
Now kindly asking for the 3rd, or 4th time for the context. If there isn't any valid context how are we defaulted to invalidating the finding if the decision of the judge truthfully finds it to be valid and we have given all the valid understanding. To my own understanding they have taken a non existing context plus a timout of the escalation duration to overpower a valid find whilst invalid finding such as #12 were used to sponge the dishonest creation of the excess value within the reward pool.
The amounts that are being earned by the lp at this liquidation should ideally be taken from the protocol if the protocol wants to donate and not be taken from healthy position since truthfully there was a wrong liquidation then we can say the pnl.remaining is locked away and the lp earned a fabricated amount that was blamed on the healthy position. The protocol must [edit:shift] the blame of the fabrication to their own accounts. KINDLY asking the escalations to raise documented or substantiated proofs rightfully due to the underlying concern that they have not yet done so. should we either upgrade this finding to high or leave as medium tbh will be fair and in the best interests. |
@WangSecurity |
Also the core team should kindly not treat my comments as if I am representing everyone who was tagged on this finding I am merely driving 1 points . Perhaps everyone else should be given a fair go 🎠 |
As I've said previously, the judging here is based on the fact that the code here works as it should be working. It cannot be a valid finding, because it's not an issue. The Watsons could ask the sponsor questions about how the protocol is intended to work or if these comments express how the code should work, but if the Watsons didn't, it's not grounds for validating the issue. The decision remains, accept the escalation and leave the issue as it is. The decision will be applied in a couple of hours. If the comments repeat the same arguments, the escalation will be resolved without a reply. |
I made an edit on the previous commment Wanted to text |
What is should be fair or unfair? The rules for issue validity are usually for fairness so I don't know how are we being exempted. |
Should be means the code is working as intended, expected. In other words, the position is liquidatable at "remaining == required" and it's intended to be like that. |
@WangSecurity |
Seems as if you indeed are saying; should be unfair. I can understand if the calculations are saying the position was sitting at pnl remaining == required since the previous block then fees will liquidated the position since some time has elapsed (fees are due to time elapsed). However, time had already elapsed and fees are already included in the calculation of pnl remaining by the time we want to reference pnl remaining in the is liquidatable function we know this since it is documented in the code. For context under the same sherlock rules similar findings to this have been rewarded without initially griefing . |
#98 includes a PoC where a healthy position is shown to be liquidatable |
No, it doesn't work like that, and there's no need for the team to say that.
None of the reports explain this, the reports just state that the position is liquidatable when The decision remains, accept the escalation and invalidate the issue. |
Result: |
Escalations have been resolved successfully! Escalation status:
|
0x37
Medium
Healthy positions may be liquidated because of inappropriate judgment
Summary
Healthy positions may be liquidated in one special case
Vulnerability Detail
In
is_liquidatable()
, there are some comments about the position's health.A position becomes liquidatable when its current value is less than a configurable fraction of the initial collateral
.The problem is that when
pnl.remaining
equalsrequired
, this position should be healthy and cannot be liquidated. But this edge case will be though as unhealthy and can be liquidated.Impact
Healthy positions may be liquidated and take some loss.
Code Snippet
https://github.com/sherlock-audit/2024-08-velar-artha/blob/main/gl-sherlock/contracts/params.vy#L117-L138
Tool used
Manual Review
Recommendation
The text was updated successfully, but these errors were encountered: