Skip to content
Misconfiguration Audit finding Intermediate

Avoidable misconfiguration could lead to INVEscrow contract not minting xINV tokens

A market deployed with the INVEscrow implementation but with the deposit callback disabled would not mint xINV tokens when users deposit collateral. This misconfiguration would make the market fail to provide the expected xINV tokens, and because the setting is immutable, the market would need to be redeployed or funds migrated.

neumo Follow with minhtrng, ladboy233 and 2 others

Originally disclosed on Code4rena

Submitted by neumo, also found by minhtrng, ladboy233, BClabs, and rvierdiiev

Market.sol#L281-L283

If a user creates a market with the INVEscrow implementation as escrowImplementation and false as callOnDepositCallback, the deposits made by users in the escrow (through the market) would not mint xINV tokens for them. As callOnDepositCallback is an immutable variable set in the constructor, this mistake would make the market a failure and the user should deploy a new one (even worse, if the error is detected after any user has deposited funds, some sort of migration of funds should be needed).

Proof of Concept

Both escrowImplementation and callOnDepositCallback are immutable:

...
address public immutable escrowImplementation;
...
bool immutable callOnDepositCallback;
...

and its value is set at creation:

constructor (
        address _gov,
        address _lender,
        address _pauseGuardian,
        address _escrowImplementation,
        IDolaBorrowingRights _dbr,
        IERC20 _collateral,
        IOracle _oracle,
        uint _collateralFactorBps,
        uint _replenishmentIncentiveBps,
        uint _liquidationIncentiveBps,
        bool _callOnDepositCallback
    ) {
	...
	escrowImplementation = _escrowImplementation;
	...
	callOnDepositCallback = _callOnDepositCallback;
	...
 }

When the user deposits collateral, if callOnDepositCallback is true, there is a call to the escrow’s onDeposit callback:

function deposit(address user, uint amount) public {
	...
	if(callOnDepositCallback) {
		escrow.onDeposit();
	}
	emit Deposit(user, amount);
}

This is INVEscrow’s onDeposit function:

function onDeposit() public {
	uint invBalance = token.balanceOf(address(this));
	if(invBalance > 0) {
		xINV.mint(invBalance); // we do not check return value because we don't want errors to block this call
	}
}

The thing is if callOnDepositCallback is false, this function is never called and the user does not turn his/her collateral (INV) into xINV.

Recommended Mitigation Steps

Either make callOnDepositCallback a configurable parameter in Market.sol or always call the onDeposit callback (just get rid of the callOnDepositCallback variable) and leave it empty in case there’s no extra functionality that needs to be executed for that escrow. In the case that the same escrow has to execute the callback for some markets and not for others, this solution would imply that there should be two escrows, one with the callback to be executed and another with the callback empty.

08xmt (Inverse) acknowledged, but disagreed with severity and commented:

Fixed in https://github.com/InverseFinance/FrontierV2/pull/21/commits/0d4b01c594fb56a9f0ba944f6946874a5b335152

We acknowledge that markets can be configured incorrectly, but it should generally be assumed that markets will be configured correctly, as this will go through both internal and governance review.


The original report as published on Code4rena, by neumo. Images and videos are our own copies; raw HTML is shown as text. View it on Code4rena.

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

Likely the market contract allows an incompatible combination of an escrow implementation that requires a deposit callback and a flag that disables that callback, and the flag is immutable so the mistake cannot be corrected after deployment.

Impact

The market would fail to mint xINV tokens for depositors, and because the setting is immutable, the market would need to be redeployed or funds migrated if the error is detected after deposits.

What the attacker needed

Market deployed with INVEscrow; callOnDepositCallback set to false

The fix

The issue was fixed by making the callback behaviour configurable or always calling the onDeposit callback, as indicated by the acknowledged fix commit.

How it was found

  1. Deploy a market with INVEscrow as the escrow implementation and callOnDepositCallback set to false.
  2. A user deposits collateral into the market.
  3. Because callOnDepositCallback is false, the escrow's onDeposit function is never called.
  4. The user's INV collateral is not converted into xINV tokens.

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.

This is a smart contract configuration issue. A market contract can be set up to use a special escrow that converts deposited INV tokens into xINV tokens, but only if a flag called callOnDepositCallback is true. If that flag is false, the conversion never happens, so users lose the expected xINV tokens and the market cannot be fixed without redeploying.

What is Misconfiguration?

Settings left unsafe: exposed panels, open storage buckets, debug modes, default credentials.

More by neumo

View all

2 more disclosed reports, best first.

More from Inverse Finance contest

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Security misconfiguration

The lesson behind this report.

Settings left unsafe: exposed panels, open storage buckets, debug modes, default credentials.