Overlay Protocol contest - hyh's results

A protocol for trading #DeFi data streams.

General Information

Platform: Code4rena

Start Date: 16/11/2021

Pot Size: $50,000 ETH

Total HM: 11

Participants: 17

Period: 7 days

Judge: LSDan

Total Solo HM: 8

Id: 49

League: ETH

Overlay Protocol

Findings Distribution

Researcher Performance

Rank: 5/17

Findings: 3

Award: $3,191.56

🌟 Selected for report: 4

🚀 Solo Findings: 1

Findings Information

🌟 Selected for report: hyh

Labels

bug
2 (Med Risk)
sponsor confirmed

Awards

0.4973 ETH - $2,297.86

External Links

Handle

hyh

Vulnerability details

Impact

Actual available fees are less than recorded. That's because a part of them corresponds to underwater positions, and will not have the correct amount stored with the contract: when calculation happens the fee is recorded first, then there is a check for position health, and the funds are channeled to cover the debt firsthand. This way in a case of unfunded position the fee is recorded, but cannot be allocated, so the fees accounted can be greater than value of fees stored.

This can lead to fee withdrawal malfunction, i.e. disburse() will burn more and attempt to transfer more than needed. This leads either to inability to withdraw fees when disburse be failing due to lack of funds, or funds leakage to fees and then inability to perform other withdrawals because of lack of funds.

Proof of Concept

The fees are accounted for before position health check and aren't corrected thereafter when there is a shortage of funds.

https://github.com/code-423n4/2021-11-overlay/blob/main/contracts/collateral/OverlayV1OVLCollateral.sol#L311

Adjust fees after position health check: accrue fees only on a remaining part of position that is available after taking debt into account.

Now:

uint _feeAmount = _userNotional.mulUp(mothership.fee()); uint _userValueAdjusted = _userNotional - _feeAmount; if (_userValueAdjusted > _userDebt) _userValueAdjusted -= _userDebt; else _userValueAdjusted = 0;

To be:

uint _feeAmount = _userNotional.mulUp(mothership.fee()); uint _userValueAdjusted = _userNotional - _feeAmount; if (_userValueAdjusted > _userDebt) { _userValueAdjusted -= _userDebt; } else { _userValueAdjusted = 0; _feeAmount = _userNotional > _userDebt ? _userNotional - _userDebt : 0; }
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