bunker.finance contest - throttle's results

The easiest way to borrow against your NFTs.

General Information

Platform: Code4rena

Start Date: 03/05/2022

Pot Size: $50,000 USDC

Total HM: 4

Participants: 46

Period: 5 days

Judge: gzeon

Total Solo HM: 2

Id: 117

League: ETH

bunker.finance

Findings Distribution

Researcher Performance

Rank: 10/46

Findings: 3

Award: $439.72

๐ŸŒŸ Selected for report: 0

๐Ÿš€ Solo Findings: 0

Findings Information

๐ŸŒŸ Selected for report: cccz

Also found by: 0x1f8b, 0xNazgul, GimelSec, IllIllI, Ruhum, hake, kebabsec, oyc_109, sorrynotsorry, throttle, tintin

Labels

bug
duplicate
2 (Med Risk)

Awards

298.5767 USDC - $298.58

External Links

Lines of code

https://github.com/bunkerfinance/bunker-protocol/blob/main/contracts/PriceOracleImplementation.sol#L29

Vulnerability details

Impact

Deprecated Chainlink oracle API. API might stop working. Prices could be outdated. Protocol might need to be redeployed or false prices might lead to users losing funds.

Proof of Concept

https://github.com/bunkerfinance/bunker-protocol/blob/main/contracts/PriceOracleImplementation.sol#L29

The contracts use Chainlinkโ€™s deprecated API latestAnswer(). Such functions might suddenly stop working if Chainlink stopped supporting deprecated APIs.

Additionally, one cannot check if the returned price is fresh. The price might by stale (old historical price).

Tools Used

Manual review

Use the latestRoundData() function to get the price instead. Add checks on the return data with proper revert messages if the price is stale or the round is uncomplete, for example:

(uint80 roundID, int256 price, , uint256 timeStamp, uint80 answeredInRound) = oracle.latestRoundData();
require(answeredInRound >= roundID, "...");
require(timeStamp != 0, "...");

#0 - bunkerfinance-dev

2022-05-09T18:19:43Z

Duplicate of #1

Awards

93.5794 USDC - $93.58

Labels

bug
QA (Quality Assurance)

External Links

[L-01] No event emission for new nft price oracle

Description

https://github.com/bunkerfinance/bunker-protocol/blob/752126094691e7457d08fc62a6a5006df59bd2fe/contracts/Comptroller.sol#L764

Consider emitting an event

-----------------------------------------------------------------

[L-02] Missing 0 address check

Description

https://github.com/bunkerfinance/bunker-protocol/blob/752126094691e7457d08fc62a6a5006df59bd2fe/contracts/Comptroller.sol#L731

New admin is not checked against 0 value.

Consider checking if new admin address is not 0

-----------------------------------------------------------------

Awards

47.5594 USDC - $47.56

Labels

bug
G (Gas Optimization)

External Links

[G-01] Function redeemAllowed() could be simplified.

Description

Function redeemAllowed() could be simplified.

function redeemAllowed(address cAsset, address redeemer, uint redeemTokens) external returns (uint) {
    uint allowed = redeemAllowedInternal(cAsset, redeemer, redeemTokens);
    if (allowed != uint(Error.NO_ERROR)) {
        return allowed;
    }

    // Keep the flywheel moving
    // updateCompSupplyIndex(cAsset);
    // distributeSupplierComp(cAsset, redeemer);

    return uint(Error.NO_ERROR);
}

could be rewritten to

function redeemAllowed(address cAsset, address redeemer, uint redeemTokens) external returns (uint) {
    return redeemAllowedInternal(cAsset, redeemer, redeemTokens);
}

Consider rewriting

-----------------------------------------------------------------

[G-02] Cheaper for loop

Description

This:

for (uint256 i = 0; i < len; i++) {
    ...
}

can be optimized to

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

Consider rewriting

-----------------------------------------------------------------

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