Skip to content
Access control Audit finding Intermediate

A malicious admin can steal all users collateral

The admin could update the price oracle for any collateral without a timelock, allowing a malicious admin to set a fake oracle that returns a very low price and then liquidate all user positions at negligible cost. This contradicts the stated trust model that the admin should not be able to drain user collateral.

J4de Follow with KingNFT

Originally disclosed on Sherlock

Source: https://github.com/sherlock-audit/2023-03-taurus-judging/issues/43

Found by

J4de, KingNFT

Summary

According to Taurus contest details, all roles, including the admin Multisig, should not be able to drain users collateral.

Solidity
2. Multisig. Trusted with essentially everything but user collateral. 

https://app.sherlock.xyz/audits/contests/45 But the current implementation allows admin to update price feed without any restriction, such as timelock. This leads to an attack vector that a malicious admin can steal all users collateral.

Vulnerability Detail

As shown of updateWrapper() function of PriceOracleManager.sol, the admin (onlyOwner) can update any price oracle _wrapperAddress for any _underlying collateral without any restrictions (such as timelock).

Solidity
File: taurus-contracts\contracts\Oracle\PriceOracleManager.sol
36:     function updateWrapper(address _underlying, address _wrapperAddress) external override onlyOwner {
37:         if (!_wrapperAddress.isContract()) revert notContract();
38:         if (wrapperAddressMap[_underlying] == address(0)) revert wrapperNotRegistered(_wrapperAddress);
39: 
40:         wrapperAddressMap[_underlying] = _wrapperAddress;
41: 
42:         emit WrapperUpdated(_underlying, _wrapperAddress);
43:     }

Hence, admin can set a malicious price oracle like

Solidity
contract AttackOracleWrapper is IOracleWrapper, Ownable {
    address public attacker;
    IGLPManager public glpManager;

    constructor(address _attacker, address glp) {
        attacker = _attacker;
        glpManager = IGLPManager(glp);
    }

    function getExternalPrice(
        address _underlying,
        bytes calldata _flags
    ) external view returns (uint256 price, uint8 decimals, bool success) {
        if (tx.origin == attacker) {
            return (1, 18, true); // @audit a really low price resulting in the liquidation of all positions
        } else {
            uint256 price = glpManager.getPrice();
            return (price, 18, true);
        }
    }
}

Then call liquidate() to drain out users collateral with negligible $TAU cost.

Solidity
File: taurus-contracts\contracts\Vault\BaseVault.sol
342:     function liquidate(
343:         address _account,
344:         uint256 _debtAmount,
345:         uint256 _minExchangeRate
346:     ) external onlyLiquidator whenNotPaused updateReward(_account) returns (bool) {
347:         if (_debtAmount == 0) revert wrongLiquidationAmount();
348: 
349:         UserDetails memory accDetails = userDetails[_account];
350: 
351:         // Since Taurus accounts' debt continuously decreases, liquidators may pass in an arbitrarily large number in order to
352:         // request to liquidate the entire account.
353:         if (_debtAmount > accDetails.debt) {
354:             _debtAmount = accDetails.debt;
355:         }
356: 
357:         // Get total fee charged to the user for this liquidation. Collateral equal to (liquidated taurus debt value * feeMultiplier) will be deducted from the user's account.
358:         // This call reverts if the account is healthy or if the liquidation amount is too large.
359:         (uint256 collateralToLiquidate, uint256 liquidationSurcharge) = _calcLiquidation(
360:             accDetails.collateral,
361:             accDetails.debt,
362:             _debtAmount
363:         );
364: 
365:         // Check that collateral received is sufficient for liquidator
366:         uint256 collateralToLiquidator = collateralToLiquidate - liquidationSurcharge;
367:         if (collateralToLiquidator < (_debtAmount * _minExchangeRate) / Constants.PRECISION) {
368:             revert insufficientCollateralLiquidated(_debtAmount, collateralToLiquidator);
369:         }
370: 
371:         // Update user info
372:         userDetails[_account].collateral = accDetails.collateral - collateralToLiquidate;
373:         userDetails[_account].debt = accDetails.debt - _debtAmount;
374: 
375:         // Burn liquidator's Tau
376:         TAU(tau).burnFrom(msg.sender, _debtAmount);
377: 
378:         // Transfer part of _debtAmount to liquidator and Taurus as fees for liquidation
379:         IERC20(collateralToken).safeTransfer(msg.sender, collateralToLiquidator);
380:         IERC20(collateralToken).safeTransfer(
381:             Controller(controller).addressMapper(Constants.FEE_SPLITTER),
382:             liquidationSurcharge
383:         );
384: 
385:         emit AccountLiquidated(msg.sender, _account, collateralToLiquidate, liquidationSurcharge);
386: 
387:         return true;
388:     }

Impact

A malicious admin can steal all users collateral

Code Snippet

https://github.com/sherlock-audit/2023-03-taurus/blob/main/taurus-contracts/contracts/Vault/BaseVault.sol#L342

Tool used

Manual Review

Recommendation

update of price oracle should be restricted with a timelock.

Discussion

iHarishKumar

https://github.com/protokol/taurus-contracts/pull/128

spyrosonic10

Escalate for 10 USDC

PriceOracleManger is Ownable contract so yes it has owner param and not governor param. So here owner can be governor, timelock and multisig. Also when it come to calling updateWrapper multisig can be trusted as it can be trusted to not set deposit fee to max and loot all users. So with that being said this is info/low issue and does not qualify for medium. It may be possible that is entirely out of scope as it is related to admin controlled param.

sherlock-admin

Escalate for 10 USDC

PriceOracleManger is Ownable contract so yes it has owner param and not governor param. So here owner can be governor, timelock and multisig. Also when it come to calling updateWrapper multisig can be trusted as it can be trusted to not set deposit fee to max and loot all users. So with that being said this is info/low issue and does not qualify for medium. It may be possible that is entirely out of scope as it is related to admin controlled param.

You've created a valid escalation for 10 USDC!

To remove the escalation from consideration: Delete your comment.

You may delete or edit your escalation comment anytime before the 48-hour escalation window closes. After that, the escalation becomes final.

hrishibhat

Escalation rejected

Given that the protocol clearly mentions that admin should be restricted whenever possible from affecting the user collateral adding the restriction makes sense. Considering this issue a valid medium.

sherlock-admin

Escalation rejected

Given that the protocol clearly mentions that admin should be restricted whenever possible from affecting the user collateral adding the restriction makes sense. Considering this issue a valid medium.

This issue's escalations have been rejected!

Watsons who escalated this issue will have their escalation amount deducted from their next payout.

MLON33

https://github.com/protokol/taurus-contracts/pull/128

Fixed here

IAm0x52

Fix looks good. Timelocker will now be set as owner of oracle manager adding a timelock to any oracle change

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

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 updateWrapper function in PriceOracleManager.sol allows the owner to change the price oracle for any collateral without a timelock or other restriction.

What the attacker needed

Malicious admin (owner of PriceOracleManager)

The fix

The fix was to set a timelock as the owner of the oracle manager, adding a delay to any oracle change.

How it was found

  1. The admin deploys a malicious oracle contract that returns a very low price when called by the attacker.
  2. The admin calls updateWrapper to set this malicious oracle for a collateral asset.
  3. The attacker calls liquidate on a user's position, which now appears unhealthy due to the low price.
  4. The liquidation transfers the user's collateral to the attacker at a negligible cost.

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.

In this system, an admin can change the contract that provides the price of collateral. If that admin is malicious, they can point to a fake price source that says the collateral is almost worthless. Then they can trigger liquidations and take the collateral cheaply. The report argues that such a powerful action should be delayed by a timelock so users have time to react.

What is Access control?

A user can do something their role should not allow: reach an admin function, act on a feature they have not paid for, or skip a permission check. IDOR is the special case where the object belongs to someone else.

More by J4de

View all

4 more disclosed reports, best first.

More from Taurus

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Broken access control

The lesson behind this report.

A user can do something their role should not allow: reach an admin function, act on a feature they have not paid for, or skip a permission check. IDOR is the special case where the object belongs to someone else.