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
Rank: 22/132
Findings: 2
Award: $501.24
🌟 Selected for report: 0
🚀 Solo Findings: 0
🌟 Selected for report: 0xnev
Also found by: 0xRobocop, 0xbrett8571, 0xkazim, 0xnacho, 3agle, 8olidity, ABAIKUNANBAEV, Bauchibred, Co0nan, CrypticShepherd, D_Auditor, DelerRH, HE1M, Iurii3, Kaysoft, MrPotatoMagic, RedOneN, RedTiger, Rolezn, SanketKogekar, Sathish9098, Timenov, Toshii, Vagner, bart1e, bytes032, codetilda, devival, halden, hals, kutugu, m_Rassska, naman1778, nonseodion, seth_lawson, solsaver, squeaky_cactus, totomanov, y51r, yudan, zaevlad
9.931 USDC - $9.93
https://github.com/code-423n4/2023-06-lybra/blob/7b73ef2fbb542b569e182d9abf79be643ca883ee/contracts/lybra/miner/esLBRBoost.sol#L33-L35 https://github.com/code-423n4/2023-06-lybra/blob/7b73ef2fbb542b569e182d9abf79be643ca883ee/contracts/lybra/miner/esLBRBoost.sol#L7-L35
This vulnerability allows an attacker to set a miningBoost
value that is significantly smaller than intended. This can result in incorrect calculations and rewards related to the miningBoost
for affected users. The miningBoost
value is used to calculate the user's mining boost based on their lock status. With a smaller miningBoost
value, users may receive lower rewards or benefits than expected.
In the addLockSetting
function:
The vulnerability lies in the addLockSetting
function of the esLBRBoost
contract. Specifically, it allows the assignment of a miningBoost value that is outside the valid range of a uint256
.
I will demonstrate in a test, the largeValue
variable set to ethers.BigNumber.from(2).pow(255)
, which is a large number that exceeds the valid range. When this value is passed to the addLockSetting
function, it will successfully modifies the miningBoost
value of the contract, indicating an integer overflow vulnerability.
const { ethers } = require("hardhat"); describe("Exploit", function () { it("should demonstrate the integer overflow vulnerability", async function () { // Deploy the contract const esLBRBoost = await ethers.getContractFactory("esLBRBoost"); const contract = await esLBRBoost.deploy(); // Exploit the integer overflow vulnerability const largeValue = ethers.BigNumber.from(2).pow(255); // Use 2^255 instead of 2^256 // Modify the contract's miningBoost value with the largeValue await contract.addLockSetting({ duration: 30 * 24 * 60 * 60, miningBoost: largeValue }); // Confirm the modification const lockSettings = await contract.esLBRLockSettings(0); console.log("Modified miningBoost value:", lockSettings.miningBoost.toString()); }); });
brett@DESKTOP-9BNO25A:~$ npx hardhat test Exploit Modified miningBoost value: 20000000000000000000 ✔ should demonstrate the integer overflow vulnerability (807ms) 1 passing (812ms)
I use ethers.BigNumber.from(2).pow(255)
instead of ethers.BigNumber.from(2).pow(256)
for the miningBoost
value. This ensures that the value is within the valid range and can be encoded properly.
Hardhat
Ensure that the miningBoost
value passed to the addLockSetting
function is within the valid range of a uint256
. You can add appropriate checks and validations to prevent the assignment of out-of-range values.
Under/Overflow
#0 - c4-pre-sort
2023-07-10T20:02:19Z
JeffCX marked the issue as duplicate of #628
#1 - c4-judge
2023-07-26T13:10:09Z
0xean changed the severity to QA (Quality Assurance)
🌟 Selected for report: Sathish9098
Also found by: 0x3b, 0xbrett8571, ABAIKUNANBAEV, K42, MrPotatoMagic, hl_, ktg, peanuts, solsaver
491.3125 USDC - $491.31
The approach taken in evaluating the codebase was systematic and comprehensive. The following steps were taken:
In addition to these steps, feedback from other developers who had evaluated the codebase was also considered.
The following criteria were used to evaluate the codebase:
The overall approach to evaluating the codebase was systematic and comprehensive, while also considering the feedback from other developers.
I learned a few things from evaluating the codebase. Here are some of the key things I learned:
Overall, I learned that the Lybra Finance codebase is a promising project with the potential to be a major player in the DeFi ecosystem. However, the protocol is still under development, and it is important to monitor its development and to assess its risks.
Here are some additional things that I learned from evaluating the codebase:
I believe that the Lybra Finance codebase has the potential to be a valuable tool for the DeFi ecosystem. However, it is important to continue to monitor the project and to assess its risks as it continues to develop.
Here are some comments for the judge to contextualize my findings:
I believe that the Lybra Finance codebase has the potential to be a valuable tool for the DeFi ecosystem. However, it is important to continue to monitor the project and to assess its risks as it continues to develop.
Here are some specific comments that I would make to the judge:
I believe that the Lybra Finance codebase has the potential to be a valuable tool for the DeFi ecosystem. However, it is important to take a cautious approach to its development and to monitor its risks closely. I am confident that the Lybra Finance team is committed to building a secure and reliable protocol, and I look forward to seeing the project continue to develop.
Here are some specific recommendations for the Lybra Finance codebase:
I believe that these architecture recommendations would help to make the Lybra Finance codebase more secure, reliable, and scalable. I hope this helps!
Some potential centralization risks for the Lybra Finance:
Centralization risks can have a number of negative consequences. These include:
Here are some specific examples of how centralization risks could manifest in the Lybra Finance protocol:
It is important to be aware of centralization risks and to take steps to mitigate them. This will help to ensure that the Lybra Finance protocol remains decentralized and secure.
The Lybra Finance protocol uses a number of mechanisms to ensure its security and stability. These mechanisms include:
The Lybra Finance protocol has a number of potential benefits. These benefits include:
However, the Lybra Finance protocol also has some potential risks. These risks include:
Overall, the Lybra Finance protocol has the potential to be a valuable tool for the DeFi ecosystem. However, it is important to be aware of the potential risks associated with the protocol before using it.
These are just some of the potential systemic risks for the Lybra Finance. Overall, the Lybra Finance protocol has the potential to be a valuable tool for the DeFi ecosystem.
Thank you.
168 hours
#0 - c4-sponsor
2023-07-27T08:40:22Z
LybraFinance marked the issue as sponsor confirmed
#1 - c4-judge
2023-07-28T17:08:33Z
0xean marked the issue as grade-a
#2 - c4-judge
2023-07-28T17:11:23Z
0xean marked the issue as satisfactory