Moonwell - Jorgect's results

An open lending and borrowing DeFi protocol.

General Information

Platform: Code4rena

Start Date: 24/07/2023

Pot Size: $100,000 USDC

Total HM: 18

Participants: 73

Period: 7 days

Judge: alcueca

Total Solo HM: 8

Id: 267

League: ETH

Moonwell

Findings Distribution

Researcher Performance

Rank: 54/73

Findings: 1

Award: $44.88

QA:
grade-a

🌟 Selected for report: 0

πŸš€ Solo Findings: 0

Awards

44.8793 USDC - $44.88

Labels

bug
disagree with severity
downgraded by judge
grade-a
primary issue
QA (Quality Assurance)
sponsor confirmed
Q-29

External Links

Lines of code

https://github.com/code-423n4/2023-07-moonwell/blob/fced18035107a345c31c9a9497d0da09105df4df/src/core/Comptroller.sol#L689

Vulnerability details

The comptroller contract is missing importan validation when the admin set a new close factor

Impact

Lack on validation when setting new close factor can let the contract in a position where liquidator can liquidate more than he should.

Proof of Concept

The comptroller contract is declaring in the top of the code the next staments:

// closeFactorMantissa must be strictly greater than this value uint256 internal constant closeFactorMinMantissa = 0.05e18; // 0.05 // closeFactorMantissa must not exceed this value uint256 internal constant closeFactorMaxMantissa = 0.9e18; // 0.9

however when the admin set the close factor there is no validation of the new close factor:

file:src/core/Comptroller.sol function _setCloseFactor(uint newCloseFactorMantissa) external returns (uint) { // Check caller is admin require(msg.sender == admin, "only admin can set close factor"); uint oldCloseFactorMantissa = closeFactorMantissa; closeFactorMantissa = newCloseFactorMantissa; emit NewCloseFactor(oldCloseFactorMantissa, closeFactorMantissa); return uint(Error.NO_ERROR); }

https://github.com/code-423n4/2023-07-moonwell/blob/fced18035107a345c31c9a9497d0da09105df4df/src/core/Comptroller.sol#L689

Tools Used

manual

check if the close factor is in the properly range:

function _setCloseFactor(uint newCloseFactorMantissa) external returns (uint) { // Check caller is admin require(msg.sender == admin, "only admin can set close factor"); require(newCloseFactorMantissa>=closeFactorMinMantissa); require(newCloseFactorMantissa<= closeFactorMaxMantissa); uint oldCloseFactorMantissa = closeFactorMantissa; closeFactorMantissa = newCloseFactorMantissa; emit NewCloseFactor(oldCloseFactorMantissa, closeFactorMantissa); return uint(Error.NO_ERROR); }

Assessed type

Other

#0 - c4-pre-sort

2023-08-03T13:52:37Z

0xSorryNotSorry marked the issue as primary issue

#1 - c4-sponsor

2023-08-03T22:06:53Z

ElliotFriedman marked the issue as disagree with severity

#2 - c4-sponsor

2023-08-03T22:06:56Z

ElliotFriedman marked the issue as sponsor confirmed

#3 - c4-judge

2023-08-12T20:54:50Z

alcueca changed the severity to QA (Quality Assurance)

#4 - c4-judge

2023-08-12T20:54:57Z

alcueca marked the issue as grade-a

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