Anyone can deprecate a guage and call all its loans when it is offboarded by LendingTermOffboarding and reonboarded before cleanup. #697
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
downgraded by judge
Judge downgraded the risk level of this issue
duplicate-1147
edited-by-warden
satisfactory
satisfies C4 submission criteria; eligible for awards
sufficient quality report
This report is of sufficient quality
Lines of code
https://github.com/code-423n4/2023-12-ethereumcreditguild/blob/2376d9af792584e3d15ec9c32578daa33bb56b43/src/governance/LendingTermOffboarding.sol#L153-L199
Vulnerability details
Description
Lending terms can be deprecated and added back to the ECG system. This can be done through a voting process on the LendingTermOffboarding contract or by the GAUGE_REMOVE and GAUGE_ADD core roles on the Guild token contract.
LendingTermOffboarding contract also comes with a function called cleanup that is used to revoke the lending term's roles after all its loans have been repaid.
The cleanup function will revert if a term already offboarded is onboarded back before it is called. This is enforced in the third require statement of the function. It also requires
canOffboard[term]
to be true in the first require statement. The issue is that the offboard function also relies oncanOffboard[term]
to be true to offboard a loan.If a lending term is re-onboarded. before
cleanup
is called,cleanup
can no longer be called to resetcanOffboard[term]
, and anyone can calloffboard
to deprecate the loan sincecanOffboard[term]
will be true. This will allow the malicious user to call on all the loans in the term and put them up for auction.It is important to note that onboarding an offboarded term is an expected function of the protocol regardless of whether it is cleaned up or not.
Impact
All the loans in a lending term can be forcefully put up for auction.
Proof of Concept
The POC shows Bob deprecating a gauge offboarded by LendingTermOffboarding but re-onboarded before
cleanup
could be called. The test can be run in LendingTermOffboarding.t.sol.The code can be run in LendingTermOffboarding.t.sol.
Tools Used
Manual Analysis
Recommended Mitigation Steps
The
offboard
function should updatecanOffboard[term]
to false immediately after offboarding the term. It should also be updated to check if the gauge has already been deprecated and updatecanOffboard[term]
to false before returning.The
cleanup
function should be updated to rely on checking if the term to be cleaned up is deprecated and has zero issuance before cleaning it up. This also comes with the added advantage of allowing a loan to be cleaned up even if it wasn't offboarded using the LendingTermOffboarding contract.Assessed type
Access Control
The text was updated successfully, but these errors were encountered: