Sherlock contest - cmichel's results

Decentralized exploit protection.

General Information

Platform: Code4rena

Start Date: 22/07/2021

Pot Size: $80,000 USDC

Total HM: 6

Participants: 14

Period: 7 days

Judge: ghoulsol

Total Solo HM: 3

Id: 21

League: ETH

Sherlock

Findings Distribution

Researcher Performance

Rank: 1/14

Findings: 5

Award: $19,550.14

🌟 Selected for report: 16

🚀 Solo Findings: 1

Findings Information

🌟 Selected for report: cmichel

Also found by: gpersoon, walker

Labels

bug
3 (High Risk)
sponsor acknowledged

Awards

3366.2338 USDC - $3,366.23

External Links

Handle

cmichel

Vulnerability details

The SherXERC20.payOffDebtAll function iterates over all protocols of the token. If a single project does not have enough funds to cover the premium payments, the transactions come to a halt, see _payOffDebt:

debt = _accruedDebt(ps, _protocol, _blocks); // this can revert tx ps.protocolBalance[_protocol] = ps.protocolBalance[_protocol].sub(debt);

Impact

Many core functions require paying off debt first and can therefore revert when a single protocol cannot pay the token premium:

  • setTokenPrice
  • setProtocolPremium
  • withdrawProtocolBalance
  • redeem
  • etc.

This scenario that a protocol is unable to pay a premium does not seem unlikely especially as there can be many protocols and each protocol can pay premiums in potentially many tokens and have to continuously re-deposit to their account to increase the balance. It is also rather involved to remove the protocol's coverage and remove the premium payments for the token. It requires governance interaction and potentially paying for the accumulated debt themselves.

#0 - Evert0x

2021-07-29T13:26:47Z

This was a design tradeoff. As governance we can see it coming as the balance is slowly draining. But the fact the protocols are able to withdraw the full amount at any time could surprise the governance. (and make the reverts in the functions above happening)

We are thinking to add a rule in the withdrawProtocolBalance to only allow withdrawals with at least 2 days of remaining balance. Allowing enough time for governance calls to remove the protocol.

Findings Information

🌟 Selected for report: walker

Also found by: cmichel, shw

Labels

bug
duplicate
2 (Med Risk)

Awards

1009.8701 USDC - $1,009.87

External Links

Handle

cmichel

Vulnerability details

There are ERC20 tokens that may make certain customizations to their ERC20 contracts. Some tokens charge a certain fee for every transfer() or transferFrom(). Others types are rebasing tokens that increase in value over time like Aave's aTokens (balanceOf changes over time).

Impact

The PoolBase.depositProtocolBalance() function will introduce unexpected balance inconsistencies when comparing internal asset records with external ERC20 token contracts. The protocol's protocolBalance will include the paid fees which have not been received. At some point, trying to pay out premiums will revert as the true underlying tokens are less than what's stored in protocolBalance.

One possible mitigation is to measure the asset change right before and after the asset-transferring routines

#0 - Evert0x

2021-07-30T14:56:49Z

#12

Findings Information

🌟 Selected for report: cmichel

Labels

bug
2 (Med Risk)
sponsor acknowledged

Awards

3740.2597 USDC - $3,740.26

External Links

Handle

cmichel

Vulnerability details

The _doSherX function does not attempt to pay off the accrued premiums ("pay off debt") for most tokens, only for the ones that would otherwise revert the tx:

// Expensive operation, only execute to prevent tx reverts
if (amounts[i] > ps.sherXUnderlying) {
  LibPool.payOffDebtAll(tokens[i]);
}

The amounts = LibSherX.calcUnderlying(totalSherX) array is an optimistic view assuming all outstanding, accrued premiums would indeed be paid until now. However, it could be that a protocol does not have enough balance to pay out these premiums and updating the state using LibPool.payOffDebtAll(tokens[i]); would fail for a token.

An inflated amount is then paid out to the user based on the optimistic calcUnderlying call.

#0 - Evert0x

2021-07-29T13:33:43Z

Fair point, the protocol is optimistic the protocols can payoff their debt.

AuditHub

A portfolio for auditors, a security profile for protocols, a hub for web3 security.

Built bymalatrax © 2024

Auditors

Browse

Contests

Browse

Get in touch

ContactTwitter