Venus Prime - 0xblackskull's results

Earn, borrow & lend on the #1 Decentralized Money Market on the BNB chain.

General Information

Platform: Code4rena

Start Date: 28/09/2023

Pot Size: $36,500 USDC

Total HM: 5

Participants: 115

Period: 6 days

Judge: 0xDjango

Total Solo HM: 1

Id: 290

League: ETH

Venus Protocol

Findings Distribution

Researcher Performance

Rank: 57/115

Findings: 1

Award: $32.27

🌟 Selected for report: 0

🚀 Solo Findings: 0

Awards

32.2731 USDC - $32.27

Labels

bug
2 (Med Risk)
satisfactory
duplicate-556

External Links

Lines of code

https://github.com/code-423n4/2023-09-venus/blob/main/contracts/Tokens/Prime/Prime.sol#L200-L230

Vulnerability details

Impact

This will persistently cause DOS on updateScores() function. Depending on how big the deficiency is.

Proof of Concept

After writing test case in foundry is show continuously

[â °] Compiling... No files changed, compilation skipped

Because continue comes before ++i, this non-incremented iteration is repeatedly executed till gas is run out, after refactored the code (you can see in Recommended Mitigation Steps code) it work perfectly.

Here is another example https://github.com/sherlock-audit/2023-02-olympus-judging/issues/125

Tools Used

Code review and solodit

Consider having the affected code logic refactored as follows:

-       for (uint256 i = 0; i < users.length; ) {
+       for (uint256 i = 0; i < users.length; ++i) {
            address user = users[i];

            if (!tokens[user].exists) revert UserHasNoPrimeToken();
            if (isScoreUpdated[nextScoreUpdateRoundId][user]) continue;

            address[] storage _allMarkets = allMarkets;
            for (uint256 j = 0; j < _allMarkets.length; ) {
                address market = _allMarkets[j];
                _executeBoost(user, market);
                _updateScore(user, market);

                unchecked {
                    j++;
                }
            }

            pendingScoreUpdates--;
            isScoreUpdated[nextScoreUpdateRoundId][user] = true;

-            unchecked {
-                i++;
-            }

            emit UserScoreUpdated(user);
        }

Assessed type

Context

#0 - c4-pre-sort

2023-10-05T20:07:07Z

0xRobocop marked the issue as duplicate of #556

#1 - c4-judge

2023-11-01T20:21:52Z

fatherGoose1 marked the issue as satisfactory

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