Function WildcatMarketController.setAnnualInterestBips allows for values outside the factory range
The borrower could change a market's annual interest rate outside the bounds set by the protocol because the controller function lacked validation. This allowed the borrower to set an interest rate below the minimum, violating protocol constraints.
3docSec Follow with stackachu, serial-coder and 18 others
Originally disclosed on Code4rena
Submitted by 3docSec, also found by stackachu, serial-coder, Toshii, josephdara, MiloTruck, gizzy, smiling_heretic, TrungOre, Tricko, 0xbrett8571, ZdravkoHr, deth, joaovwfreire, caventa, 0xbepresent, b0g0, ggg_ttt_hhh, Eigenvectors, cu5t0mpeo, and 0xCiphky
When a WildcatMarketController is created, it is hardcoded with a MinimumAnnualInterestBips and MaximumAnnualInterestBips range that cannot be changed; these values come from WildcatMarketControllerFactory where they are specified by the protocol owners.
When a market is created at the borrower’s request, the annual interest requested by the borrower is validated to sit within these bounds.
However, the borrower is also allowed to change this value at a later point through the WildcatMarketController.setAnnualInterestBips function. This entry point does not offer any validation, except for the downstream WildcatMarket.setAnnualInterestBips that checks for the value not to exceed BIPS.
Impact
After the creation of a market, the borrower is allowed to change its annual interest outside the bounds allowed by the protocol.
Proof of Concept
function testArbitraryInterestRate() public {
WildcatArchController archController = new WildcatArchController();
SanctionsList sanctionsList = new SanctionsList();
WildcatSanctionsSentinel sentinel = new WildcatSanctionsSentinel(
address(archController),
address(sanctionsList));
// the protocol mandates a 10% annual interest
WildcatMarketControllerFactory controllerFactory = new WildcatMarketControllerFactory(
address(archController), // _archController,
address(sentinel), // _sentinel,
MarketParameterConstraints( // constraints
uint32(0), // minimumDelinquencyGracePeriod;
uint32(0), // maximumDelinquencyGracePeriod;
uint16(0), // minimumReserveRatioBips;
uint16(0), // maximumReserveRatioBips;
uint16(0), // minimumDelinquencyFeeBips;
uint16(0), // maximumDelinquencyFeeBips;
uint32(0), // minimumWithdrawalBatchDuration;
uint32(0), // maximumWithdrawalBatchDuration;
uint16(10_00), // minimumAnnualInterestBips;
uint16(10_00) // maximumAnnualInterestBips;
)
);
address borrower = address(uint160(uint256(keccak256("borrower"))));
archController.registerBorrower(borrower);
archController.registerControllerFactory(address(controllerFactory));
MockERC20 token = new MockERC20();
vm.startPrank(borrower);
WildcatMarketController controller = WildcatMarketController(
controllerFactory.deployController());
// the borrower creates a market with 10% annual interest - all good till now
address market = controller.deployMarket(
address(token), // asset,
"3d", // namePrefix,
"3", // symbolPrefix,
type(uint128).max, // maxTotalSupply,
10_00, // annualInterestBips
0, // delinquencyFeeBips,
0, // withdrawalBatchDuration,
0, // reserveRatioBips,
0 // delinquencyGracePeriod
);
// now, the borrower is allowed to change the interest below 10%
// which is not allowed by the protocol config
controller.setAnnualInterestBips(market, 5_00);
// and get away with it
assertEq(5_00, WildcatMarket(market).annualInterestBips());
}
Tools Used
Foundry
Recommended Mitigation Steps
Consider introducing the validation of the new interest rate:
// WildcatMarketController.sol:468
function setAnnualInterestBips(
address market,
uint16 annualInterestBips
) external virtual onlyBorrower onlyControlledMarket(market) {
+ assertValueInRange(
+ annualInterestBips,
+ MinimumAnnualInterestBips,
+ MaximumAnnualInterestBips,
+ AnnualInterestBipsOutOfBounds.selector
+ );
// If borrower is reducing the interest rate, increase the reserve
// ratio for the next two weeks.
Assessed type
Invalid Validation
laurenceday (Wildcat) commented:
Mitigated here, adjusted to proposed solution with this commit.
laurenceday (Wildcat) confirmed
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
How it worked
Root cause
The setAnnualInterestBips function in WildcatMarketController did not validate the new interest rate against the MinimumAnnualInterestBips and MaximumAnnualInterestBips bounds.
What the attacker needed
Borrower role; a deployed market
How it was found
- Deploy a WildcatMarketControllerFactory with a minimum and maximum annual interest of 10%.
- Register a borrower and deploy a controller for that borrower.
- The borrower deploys a market with 10% annual interest.
- The borrower calls setAnnualInterestBips on the controller with a value of 5%.
- The market's annualInterestBips is now 5%, below the allowed minimum.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
A smart contract lets a borrower set the interest rate for their loan market, but the protocol has minimum and maximum limits. The function that changes the rate didn't check those limits, so the borrower could set a rate outside the allowed range. This breaks the rules the protocol owners intended.
What is Business logic?
The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.