Lybra Finance - azhar's results

A protocol building the first interest-bearing omnichain stablecoin backed by LSD.

General Information

Platform: Code4rena

Start Date: 23/06/2023

Pot Size: $60,500 USDC

Total HM: 31

Participants: 132

Period: 10 days

Judge: 0xean

Total Solo HM: 10

Id: 254

League: ETH

Lybra Finance

Findings Distribution

Researcher Performance

Rank: 53/132

Findings: 2

Award: $144.81

🌟 Selected for report: 0

🚀 Solo Findings: 0

Findings Information

🌟 Selected for report: Neon2835

Also found by: 0xRobocop, 0xcm, Arz, DedOhWale, HE1M, MohammedRizwan, azhar, kankodu, zaevlad

Labels

bug
3 (High Risk)
satisfactory
duplicate-769

Awards

143.4901 USDC - $143.49

External Links

Lines of code

https://github.com/code-423n4/2023-06-lybra/blob/7b73ef2fbb542b569e182d9abf79be643ca883ee/contracts/lybra/token/PeUSDMainnetStableVision.sol#L133 https://github.com/code-423n4/2023-06-lybra/blob/7b73ef2fbb542b569e182d9abf79be643ca883ee/contracts/lybra/token/PeUSDMainnetStableVision.sol#L137

Vulnerability details

Impact

PeUSDMainnetStableVision.sol contract's executeFlashloan function does not have proper access control. Therefore anyone can put any user's flashborrow contract address and execute the flashloan and the PeUSDMainnetStableVision.sol will take a fee as well, if they gave unlimited EUSD approval or even a limited amount of approval to the PeUSDMainnetStableVision contract. An attacker can repeat this setup until the user's entire contract is drained.

Proof of Concept

https://github.com/code-423n4/2023-06-lybra/blob/7b73ef2fbb542b569e182d9abf79be643ca883ee/contracts/lybra/token/PeUSDMainnetStableVision.sol#L133 https://github.com/code-423n4/2023-06-lybra/blob/7b73ef2fbb542b569e182d9abf79be643ca883ee/contracts/lybra/token/PeUSDMainnetStableVision.sol#L137

Tools Used

Manual Review

under the executeFlashloan's function check this access control to prevent this attack.

function executeFlashloan(FlashBorrower receiver, uint256 eusdAmount, bytes calldata data) public payable { require(address(receiver) == msg.sender, "Not allowed"); ...

Assessed type

Access Control

#0 - c4-pre-sort

2023-07-09T02:03:18Z

JeffCX marked the issue as duplicate of #280

#1 - c4-judge

2023-07-28T15:30:19Z

0xean marked the issue as satisfactory

Awards

1.3247 USDC - $1.32

Labels

bug
2 (Med Risk)
satisfactory
duplicate-27

External Links

Lines of code

https://github.com/code-423n4/2023-06-lybra/blob/7b73ef2fbb542b569e182d9abf79be643ca883ee/contracts/lybra/pools/LybraWbETHVault.sol#L35 https://github.com/code-423n4/2023-06-lybra/blob/7b73ef2fbb542b569e182d9abf79be643ca883ee/contracts/lybra/pools/LybraWbETHVault.sol#L10

Vulnerability details

Impact

LybraWbETHVault contract using WBETH's interface and get the asset price in getAssetPrice() function. Inside that getAssetPrice() it's calling exchangeRatio() from the WBETH contract. but current on-chain WBETH contract is having exchangeRate() function only. Therefore, depositEtherToMint() function will fail forever and brick the contract permanently.

Proof of Concept

https://github.com/code-423n4/2023-06-lybra/blob/7b73ef2fbb542b569e182d9abf79be643ca883ee/contracts/lybra/pools/LybraWbETHVault.sol#L35

https://github.com/code-423n4/2023-06-lybra/blob/7b73ef2fbb542b569e182d9abf79be643ca883ee/contracts/lybra/pools/LybraWbETHVault.sol#L10

https://etherscan.io/token/0xa2e3356610840701bdf5611a53974510ae27e2e1#readProxyContract#F13

Tools Used

Manual Review

Change the interface from function exchangeRatio() external view returns (uint256); to function exchangeRate() external view returns (uint256); and inside the getAssetPrice() function implement like this to mitigate the issue.

function getAssetPrice() public override returns (uint256) { return (_etherPrice() * IWBETH(address(collateralAsset)).exchangeRate()) / 1e18; }

Assessed type

DoS

#0 - c4-pre-sort

2023-07-04T02:34:43Z

JeffCX marked the issue as duplicate of #129

#1 - c4-pre-sort

2023-07-04T13:29:31Z

JeffCX marked the issue as duplicate of #27

#2 - c4-judge

2023-07-28T17:15:21Z

0xean 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