-
Notifications
You must be signed in to change notification settings - Fork 11
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
Can manipulate the debt ceiling to borrow beyond it #307
Comments
It looks like this is the intended behaviour as the total debt ceiling is the same during these actions. |
0xSorryNotSorry marked the issue as insufficient quality report |
Invalid statement. It's intended design and debt ceiling can be less than issuance by multiple reasons. |
Trumpero marked the issue as unsatisfactory: |
This is falsely marked as invalid.
While it's true we can reasonably end up in this state, this should only be causable by gauge voters, who are essentially lenders. It's reasonable for a lender to limit the terms of a loan as they're the party that's affected if the loan goes under. As described, the borrower can continually increase the debt ceiling by increasing the totalBorrowedCredit, allowing them to borrow effectively as much as they would like. This is especially problematic considering the whole purpose of the debtCeiling is to limit the amount that users can borrow. This can of course also be used as a griefing attack against gauge voters, causing them to be unable to exit their positions. |
@kadenzipfel I still don't see any issue here. Issuance is limited by the |
Lines of code
https://github.com/code-423n4/2023-12-ethereumcreditguild/blob/2376d9af792584e3d15ec9c32578daa33bb56b43/src/loan/LendingTerm.sol#L383
Vulnerability details
Impact
The debt ceiling can be manipulated by temporarily increasing totalBorrowedCredit, allowing for attackers to borrow well beyond the intended debt ceiling, DoS'ing gauge voters as a result.
Proof of Concept
In
LendingTerm._borrow
, we compute the debt ceiling by calculating the gauge allocation for the term with aquantity
oftotalBorrowedCredit + borrowAmount
.We can see below in
calculateGaugeAllocation
that since thequantity
param is the numerator, as it increases, the return value increases.We can see in the ProfitManager that
totalBorrowedCredit
is computed as follows.So if we want to increase the debt ceiling, we can increase the Credit token supply without increasing the SimplePSM balance.
If we have a term (term B) which has a lot of room until its debt ceiling and a term (term A) which we want to borrow beyond the debt ceiling, we can do so as follows:
Since we don't need to redeem our credit from term B in the SimplePSM, the totalBorrowedCredit increases which gives us a higher debt ceiling for the term we actually want to borrow from.
The result of this attack is the attacker getting much more liquidity than intended, increasing the risk of the term beyond its intended limit. This also results in the gauge voters for term A having their gauge weight stuck since they can't decrement their gauge weight if it results in the debt ceiling being less than the issuance.
Tools Used
Recommended Mitigation Steps
It's unsafe to use totalBorrowedCredit to determine a safe debt ceiling as it can always be manipulated in some way. Instead, I would recommend using a Governor controlled fixed total debt ceiling in which the individual term debt ceilings are just computed based on their share of the total gauge weight.
Assessed type
Math
The text was updated successfully, but these errors were encountered: