Closed howlbot-integration[bot] closed 1 month ago
I kind of respect the level of confidence it must take to report 3 separate highs for the same issue that clearly does not result in loss of funds or disable major protocol functionality in any way.
3docSec marked the issue as duplicate of #70
3docSec changed the severity to QA (Quality Assurance)
3docSec marked the issue as grade-b
Lines of code
https://github.com/0xastronatey/2024-08-wildcat/blob/fe746cc0fbedc4447a981a50e6ba4c95f98b9fe1/src/market/WildcatMarketWithdrawals.sol#L283
Vulnerability details
Description
The WildcatMarketWithdrawals contract in its current implementation, allows sanctioned addresses to repay debt and process unpaid withdrawal batches, violating the sponsor's invariant that sanctioned accounts should not modify the market state.
The
repayAndProcessUnpaidWithdrawalBatches
function lacks a sanction restriction check, contrary to other state-modifying functions like the executeWithdrawal() in the WildcatMarketWithdrawals contract.Vulnerable code snippet from
WildcatMarketWithdrawals.sol
: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 this function 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 brief: "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)."
Proof of Concept
The issue can be demonstrated by a sanctioned address successfully calling the
repayAndProcessUnpaidWithdrawalBatches()
, which modifies the market state by reducing total debt and processing withdrawal batches. This action is currently allowed in theWildcatMarketWithdrawals
contract!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
repayAndProcessUnpaidWithdrawalBatches()
function.function repayAndProcessUnpaidWithdrawalBatches( uint256 repayAmount, uint256 maxBatches ) public nonReentrant sphereXGuardExternal { // @audit add a sanction check to prevent sanctioned addresses from calling this function if (_isFlaggedByChainalysis(msg.sender)) { revert_repayAndProcessUnpaidWithdrawalBatchesWhileSanctioned(); }
}
Assessed type
Access Control