Olympus DAO contest - djxploit's results

Version 3 of Olympus protocol, a decentralized floating currency.

General Information

Platform: Code4rena

Start Date: 25/08/2022

Pot Size: $75,000 USDC

Total HM: 35

Participants: 147

Period: 7 days

Judge: 0xean

Total Solo HM: 15

Id: 156

League: ETH

Olympus DAO

Findings Distribution

Researcher Performance

Rank: 26/147

Findings: 3

Award: $944.33

🌟 Selected for report: 1

🚀 Solo Findings: 0

Findings Information

🌟 Selected for report: djxploit

Also found by: brgltd

Labels

bug
2 (Med Risk)
sponsor confirmed
old-submission-method

Awards

857.4359 DAI - $857.44

External Links

Lines of code

https://github.com/code-423n4/2022-08-olympus/blob/main/src/modules/TRSRY.sol#L110 https://github.com/code-423n4/2022-08-olympus/blob/main/src/modules/TRSRY.sol#L99

Vulnerability details

Impact

In getloan() and replayloan(), the safetransfer and safetransferfrom doesn't check the existence of code at the token address. This is a known issue while using solmate's libraries. Hence this may lead to miscalculation of funds and may lead to loss of funds , because if safetransfer() and safetransferfrom() are called on a token address that doesn't have contract in it, it will always return success, bypassing the return value check. Due to this protocol will think that funds has been transferred and successful , and records will be accordingly calculated, but in reality funds were never transferred. So this will lead to miscalculation and possibly loss of funds

Proof of Concept

https://github.com/code-423n4/2022-08-olympus/blob/main/src/modules/TRSRY.sol#L110 https://github.com/code-423n4/2022-08-olympus/blob/main/src/modules/TRSRY.sol#L99

Tools Used

Manual code review

Use openzeppelin's safeERC20 or implement a code existence check

#0 - ind-igo

2022-09-07T23:33:11Z

Confirmed. Will implement this. Thank you.

Use of block.timestamp

https://github.com/code-423n4/2022-08-olympus/blob/main/src/modules/RANGE.sol#L85 https://github.com/code-423n4/2022-08-olympus/blob/main/src/modules/RANGE.sol#L92 https://github.com/code-423n4/2022-08-olympus/blob/main/src/modules/RANGE.sol#L136 https://github.com/code-423n4/2022-08-olympus/blob/main/src/modules/RANGE.sol#L138 https://github.com/code-423n4/2022-08-olympus/blob/main/src/modules/RANGE.sol#L148 https://github.com/code-423n4/2022-08-olympus/blob/main/src/modules/RANGE.sol#L150 https://github.com/code-423n4/2022-08-olympus/blob/main/src/modules/RANGE.sol#L191 https://github.com/code-423n4/2022-08-olympus/blob/main/src/modules/RANGE.sol#L200 https://github.com/code-423n4/2022-08-olympus/blob/main/src/modules/RANGE.sol#L207 https://github.com/code-423n4/2022-08-olympus/blob/main/src/modules/RANGE.sol#L231 https://github.com/code-423n4/2022-08-olympus/blob/main/src/modules/RANGE.sol#L233 https://github.com/code-423n4/2022-08-olympus/blob/main/src/modules/PRICE.sol#L143 https://github.com/code-423n4/2022-08-olympus/blob/main/src/modules/PRICE.sol#L146 https://github.com/code-423n4/2022-08-olympus/blob/main/src/modules/PRICE.sol#L165 https://github.com/code-423n4/2022-08-olympus/blob/main/src/modules/PRICE.sol#L171 https://github.com/code-423n4/2022-08-olympus/blob/main/src/modules/PRICE.sol#L215

Missing 0 address check

https://github.com/code-423n4/2022-08-olympus/blob/main/src/Kernel.sol#L439 https://github.com/code-423n4/2022-08-olympus/blob/main/src/Kernel.sol#L451 https://github.com/code-423n4/2022-08-olympus/blob/main/src/modules/TRSRY.sol#L64 https://github.com/code-423n4/2022-08-olympus/blob/main/src/modules/TRSRY.sol#L75 https://github.com/code-423n4/2022-08-olympus/blob/main/src/modules/TRSRY.sol#L75 https://github.com/code-423n4/2022-08-olympus/blob/main/src/modules/TRSRY.sol#L137

Unnecessary initialization

In line https://github.com/code-423n4/2022-08-olympus/blob/main/src/Kernel.sol#L397, initialization of i to 0 is not necessary, as the default value of uint256 is always 0.

For loop optimization

In loop , https://github.com/code-423n4/2022-08-olympus/blob/main/src/utils/KernelUtils.sol#L43, the for loop can be optimized by removing unnecessary initialization and using ++i instead of i++

for(uint256 i; i<5;) { ... unchecked { ++i; } }

Similar optimizations can also be done at : https://github.com/code-423n4/2022-08-olympus/blob/main/src/utils/KernelUtils.sol#L58

Use >= or <= instead of > or < :

https://github.com/code-423n4/2022-08-olympus/blob/main/src/utils/KernelUtils.sol#L46 https://github.com/code-423n4/2022-08-olympus/blob/main/src/utils/KernelUtils.sol#L60 https://github.com/code-423n4/2022-08-olympus/blob/main/src/modules/TRSRY.sol#L131 https://github.com/code-423n4/2022-08-olympus/blob/main/src/modules/TRSRY.sol#L144 https://github.com/code-423n4/2022-08-olympus/blob/main/src/modules/RANGE.sol#L133 https://github.com/code-423n4/2022-08-olympus/blob/main/src/modules/RANGE.sol#L145 https://github.com/code-423n4/2022-08-olympus/blob/main/src/modules/RANGE.sol#L245 https://github.com/code-423n4/2022-08-olympus/blob/main/src/modules/RANGE.sol#L247 https://github.com/code-423n4/2022-08-olympus/blob/main/src/modules/RANGE.sol#L248 https://github.com/code-423n4/2022-08-olympus/blob/main/src/modules/RANGE.sol#L249 https://github.com/code-423n4/2022-08-olympus/blob/main/src/modules/RANGE.sol#L264 https://github.com/code-423n4/2022-08-olympus/blob/main/src/modules/PRICE.sol#L90 https://github.com/code-423n4/2022-08-olympus/blob/main/src/modules/PRICE.sol#L135

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