Open sherlock-admin2 opened 1 year ago
We wrote a test for this and determined that rewards do not increase with each subsequent take. As it is written this is an invalid issue. We did however discover an issue: when you take above the TP you move the TP down, this can increase the penalty to the bond holder and the borrower.
We will fix this separate issue and will memorialize the TP on kick.
Escalate
This issue is invalid as per sponsor statement and therefore should not be rewarded.
Escalate
This issue is invalid as per sponsor statement and therefore should not be rewarded.
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.
@dmitriia Can you please provide a PoC test case for this one? I have to agree with the Escalation if no further PoC is provided.
@dmitriia Can you please provide a PoC test case for this one?
Will get back shortly on this.
There is one done by Proteek.
It shows the increasing reward when auction price is within (TP / (1 - takePenalty), TP)
range:
// Reward is increased with subsequent take just above TP.
assertEq(totalBondAfterFullTake, 296.921313863332593428 * 1e18);
assertEq(totalBondAfterSubsequentTake, 299.032319479303523664 * 1e18);
assertGt(totalBondAfterSubsequentTake, totalBondAfterFullTake);
It is practical for kicker/taker to atomically split the take in the series of a smaller ones as this enhances their total reward for the price of a moderate gas cost increase.
Result: High Unique
In the future will have another way of dealing with low-effort issues. For now need to reject the escalation. I'm sorry @midori-fuse
Code changes related to this issue:
Fix looks ok, threshold price is now fixed as of time of _kick()
.
hyh
high
Subsequent takes increase next kicker reward, allowing total kicker reward to be artificially amplified by splitting take into a batch
Summary
Kicker reward is being determined as a proportion of auction price to neutral price (NP) distance to the distance between NP and threshold price (TP). The latter is determined on the fly, with the current debt and collateral, and in the presence of take penalty, actually rises with every take.
This way for any taker it will be profitable to perform many small takes atomically instead of one bigger take, bloating the kicker reward received simply due to rising TP as of time of each subsequent kick.
Vulnerability Detail
Take penalty being imposed on a borrower worsens its TP. This way a take performed on the big enough debt being auctioned increases the kicker rewards produced by the next take.
This way multiple takes done atomically increase cumulative kicker reward, so if kicker and taker are affiliated then the kicker reward can be augmented above one stated in the protocol logic.
Impact
Kicker reward can be made excessive at the expense of the reserves part.
Code Snippet
If
auctionPrice_
is fixed to bemarket_price - required_margin
then the biggerthresholdPrice
the bigger thesign
and resulting_bpf()
returned value:https://github.com/sherlock-audit/2023-09-ajna/blob/main/ajna-core/src/libraries/helpers/PoolHelper.sol#L382-L411
thresholdPrice >= int256(neutralPrice_)
will not happen on initial kick asnpTpRatio
is always above 1, but can happen if TP is raised high enough by a series of smaller takes, i.e. taker in some cases can even force kicker reward to be maximal+1 * bondFactor_
.takePenaltyFactor
is paid by the borrower in addition to auction price:https://github.com/sherlock-audit/2023-09-ajna/blob/main/ajna-core/src/libraries/external/TakerActions.sol#L724-L736
takePenaltyFactor
can be3-3.75%
forvars.bpf > 0
andbondFactor
maximized to be3%
, so if TP is above market price by a lower margin, sayTP = 1.025 * market_price
, then the removal of3-3.75%
part will worsen it off.The opposite will happen when TP is greater than that, but this calls for the singular executions and doesn't look exploitable.
Tool used
Manual Review
Recommendation
Consider limiting the take penalty so it won't worsen the collaterization of the auctioned loan, e.g. limiting
takePenaltyFactor
toTP / market_price - 1
.