Grieving attack by failing user's transactions #92
Labels
2 (Med Risk)
Assets not at direct risk, but function/availability of the protocol could be impacted or leak value
bug
Something isn't working
edited-by-warden
M-03
primary issue
Highest quality submission among a set of duplicates
satisfactory
satisfies C4 submission criteria; eligible for awards
selected for report
This submission will be included/highlighted in the audit report
sponsor confirmed
Sponsor agrees this is a problem and intends to fix it (OK to use w/ "disagree with severity")
Lines of code
https://github.com/with-backed/papr/blob/9528f2711ff0c1522076b9f93fba13f88d5bd5e6/src/PaprController.sol#L486
Vulnerability details
Impact
An attacker can apply grieving attack by preventing users from interacting with some of the protocol functions. In other words whenever a user is going to reduce his debt, or buy and reduce his debt in one tx, it can be failed by the attacker.
Proof of Concept
In the following scenario, I am explaining how it is possible to fail user's transaction to reduce their debt fully. Failing other transaction (buy and reduce the debt in one tx) can be done similarly.
PaprToken
and she intends to repay her debt fully:reduceDebt
with the following parameters:account
: Alice's addressasset
: The NFT which was used as collateralamount
: 1000 * 10**18 (decimal ofPaprToken
is 18).https://github.com/with-backed/papr/blob/9528f2711ff0c1522076b9f93fba13f88d5bd5e6/src/PaprController.sol#L148
PaprToken
) notices Alice's transaction in the Mempool. So, Bob applies front-run attack and calls the functionreduceDebt
with the following parameters:account
: Alice's addressasset
: The NFT which was used as collateralamount
: 1PaprToken
on behalf of Alice, so Alice's debt becomes1000 * 10**18 - 1
.https://github.com/with-backed/papr/blob/9528f2711ff0c1522076b9f93fba13f88d5bd5e6/src/PaprController.sol#L481
https://github.com/with-backed/papr/blob/9528f2711ff0c1522076b9f93fba13f88d5bd5e6/src/PaprController.sol#L486
Underflow Error
. Since Alice's debt is1000 * 10**18 - 1
while Alice's transaction was going to repay1000 * 10**18
.https://github.com/with-backed/papr/blob/9528f2711ff0c1522076b9f93fba13f88d5bd5e6/src/PaprController.sol#L487
PaprToken
(consider that the decimal is 18) to apply this grieving attack.In summary, Bob could prevent the user from paying her debt fully by just repaying a very small amount of the user's debt in advance and as a result causing underflow error. Bob can apply this attack for all other users who are going to repay their debt fully. Please note that if a user is going to repay her debt partially, the attack can be expensive and not financially reasonable, but in case of full repayment of debt, it is very cheap to apply this grieving attack.
This attack can be applied on the transactions that are going to interact with the function
_reduceDebt
. The transactions interacting with this specific function are:buyAndReduceDebt(...)
https://github.com/with-backed/papr/blob/9528f2711ff0c1522076b9f93fba13f88d5bd5e6/src/PaprController.sol#L229
reduceDebt(...)
https://github.com/with-backed/papr/blob/9528f2711ff0c1522076b9f93fba13f88d5bd5e6/src/PaprController.sol#L149
It means that the attacker can prevent users from calling the functions above.
Tools Used
Recommended Mitigation Steps
The following condition should be added to the function
_reduceDebtWithoutBurn
:https://github.com/with-backed/papr/blob/9528f2711ff0c1522076b9f93fba13f88d5bd5e6/src/PaprController.sol#L486
The text was updated successfully, but these errors were encountered: