Open howlbot-integration[bot] opened 2 months ago
Please see https://github.com/code-423n4/2024-08-wildcat-findings/issues/20#issuecomment-2359438506 for initial context on repay
(repayOutstandingDebt
is simply a further refinement of the same mechanism). This is precisely the issue that made us aware that we were probably going to get grief over it, which is mildly frustrating.
We do not consider this finding valid, nor is it a change that we are interested in making, as it would be a waste of gas for something can be sidestepped simply by performing an ERC-20 transfer and a state update. repay
is somewhat unique compared to other functions that do have the sanction-check in that it doesn't impact the market token supply and -- as mentioned in the comment -- is simply a macro for ease of UX.
If there is an original sin here on our part, it is that the invariant didn't state that the market state changes we're actually concerned with involve market token supply, rather than the scale factor and liquid reserve updates. In any event, even if pedantry dictates that the finding must stand because of the wording, it is not a high (there are literally no funds at risk here, and in practice no one that is sanctioned is going to be interacting with a credit contract anyway since they'll very likely be KYC'd).
More generally, we flagged this warden early on as leaning on LLMs to bug-hunt, to the point where we decided to cease engaging with them after they asked a bunch of questions that indicated minimal familiarity with Solidity and noticed that their Discord account was created two days before the Wildcat audit started.
We'd happily accept this as a QA (and I accepted as much in our thread with them): however, calling it a high or medium because of wordplay games [he readily said he was just playing the game] would be taking the mick out of the efforts of other wardens.
Contract does not follow the spec. I get that a "key invariant" is quoted, but I see no relation to the C4 severity categorization, I agree with QA.
3docSec changed the severity to QA (Quality Assurance)
3docSec marked the issue as grade-b
Lines of code
https://github.com/code-423n4/2024-08-wildcat/blob/fe746cc0fbedc4447a981a50e6ba4c95f98b9fe1/src/market/WildcatMarket.sol#L202
Vulnerability details
Description
The WildcatMarket in its current implementation, contract allows sanctioned addresses to repay debt, violating the sponsor's invariant that sanctioned accounts should not modify the market state. The
repay()
andrepayOutstandingDebt()
functions lacks a sanction check, contrary to other state-modifying functions likeborrow()
.Let's take a look at the
repay()
andrepayOutstandingDebt()
implementations fromWildcatMarket.sol
:Also in
repayOutstandingDebt()
:What matters is that sanctioned entities are not receiving or sending funds to the market, as this could put other lenders in a precarious legal situation. However, as seen in the implementation above, there is no restriction preventing sanctioned addresses from calling these functions and sending funds into the market directly.
Impact
The lack of restrictions allows sanctioned addresses to, in fact, interact with the market, modify its state, and essentially circumvent financial regulations. This violates the key invariant stated in the guidelines: "Accounts which are flagged as sanctioned on Chainalysis should never be able to successfully modify the state of the market unless the borrower specifically overrides their sanctioned status in the sentinel (other than token approvals, or through their tokens being withdrawn & escrowed in nukeFromOrbit and executeWithdrawal)."
Also worth noting is that this was completely missed in the v1 audit competition last year (though I did not participate in the contest).
Proof of Concept
Unlike the
deposit()
andborrow()
functions, which include the necessary check, a sanctioned address can bypass the sanction check by directly calling therepay()
orrepayOutstandingDebt()
functions.‹‹Test output logs›› :
Create a new NewTest.t.sol file under ./test to run the POC code below with
forge test --match-path test/NewTest.t.sol -vvvv
Tools used
Foundry
Recommendation:
Implement a sanction check in the
repay()
andrepayOutstandingDebt()
functions, similar to the check in the borrow function.Assessed type
Access Control