Platform: Code4rena
Start Date: 10/11/2023
Pot Size: $28,000 USDC
Total HM: 5
Participants: 185
Period: 5 days
Judge: 0xDjango
Id: 305
League: ETH
Rank: 36/185
Findings: 3
Award: $137.31
🌟 Selected for report: 0
🚀 Solo Findings: 0
🌟 Selected for report: T1MOH
Also found by: 0x1337, 0xNaN, 0xepley, 0xluckhu, 0xmystery, 7siech, Aamir, AlexCzm, Aymen0909, DanielArmstrong, GREY-HAWK-REACH, HChang26, Jiamin, Juntao, QiuhaoLi, Ruhum, SBSecurity, Varun_05, Weed0607, adam-idarrha, adriro, ast3ros, ayden, circlelooper, crack-the-kelp, crunch, cryptothemex, deepplus, mahdirostami, max10afternoon, osmanozdemir1, rouhsamad, rvierdiiev, trachev, xAriextz, zhaojie
36.0335 USDC - $36.03
https://github.com/code-423n4/2023-11-kelp/blob/main/src/LRTOracle.sol#L52-L79
While auditing the getRSETHPrice
function i've indicated a dynamic but non-linear relationship between the supply of the RSETH token and its price.An increase in RSETH supply is associated with an increase in the price of RSETH.
Let's consider a scenario where the relationship between RSETH supply and the rstETH price is not strictly exponential but exhibits non-linear behavior.
Initial State:
Moderate Increase in Supply with Significant Deposits:
Large Increase in Supply with Even Larger Deposits:
Subsequent Increment in Supply with Moderate Deposits:
when the function depositAsset
is called it first deposit the money into the smart contract and then call _mintRsETH
function which then further calls for getRsETHAmountToMint
function, Now before getRsETHAmountToMint
is called the money should be transferred into the contract and getRsETHAmountToMint
calls for getTotalAssetDeposits
function which will be updated.
Manual Review
Math
#0 - c4-pre-sort
2023-11-17T00:02:58Z
raymondfam marked the issue as sufficient quality report
#1 - c4-pre-sort
2023-11-17T00:03:15Z
raymondfam marked the issue as duplicate of #62
#2 - c4-judge
2023-11-29T21:26:51Z
fatherGoose1 marked the issue as satisfactory
#3 - c4-judge
2023-12-04T15:31:41Z
fatherGoose1 changed the severity to 3 (High Risk)
🌟 Selected for report: m_Rassska
Also found by: 0x1337, 0xAadi, 0xHelium, 0xLeveler, 0xblackskull, 0xbrett8571, 0xepley, 0xffchain, 0xluckhu, 0xmystery, 0xrugpull_detector, 0xvj, ABAIKUNANBAEV, Aamir, AerialRaider, Amithuddar, Bauchibred, Bauer, CatsSecurity, Cryptor, Daniel526, Draiakoo, Eigenvectors, ElCid, GREY-HAWK-REACH, Inspecktor, Juntao, King_, LinKenji, Madalad, MaslarovK, Matin, MatricksDeCoder, McToady, Noro, PENGUN, Pechenite, Phantasmagoria, RaoulSchaffranek, SBSecurity, SandNallani, Shaheen, Soul22, Stormreckson, T1MOH, Tadev, TeamSS, TheSchnilch, Topmark, Tumelo_Crypto, Udsen, Yanchuan, ZanyBonzy, _thanos1, adeolu, adriro, alexfilippov314, almurhasan, amaechieth, anarcheuz, ayden, baice, bareli, boredpukar, bronze_pickaxe, btk, cartlex_, catellatech, chaduke, cheatc0d3, circlelooper, codynhat, crack-the-kelp, critical-or-high, debo, deepkin, desaperh, dipp, eeshenggoh, evmboi32, ge6a, gesha17, glcanvas, gumgumzum, hals, hihen, hunter_w3b, jasonxiale, joaovwfreire, ke1caM, leegh, lsaudit, marchev, merlinboii, niser93, osmanozdemir1, paritomarrr, passion, pep7siup, phoenixV110, pipidu83, poneta, ro1sharkm, rouhsamad, rvierdiiev, sakshamguruji, seerether, shealtielanz, soliditytaker, spark, squeaky_cactus, stackachu, supersizer0x, tallo, taner2344, turvy_fuzz, twcctop, ubl4nk, wisdomn_, xAriextz, zach, zhaojie, zhaojohnson, ziyou-
2.7592 USDC - $2.76
In the function depositAssetIntoStrategy
of NodeDelegator
the event
emit AssetDepositIntoStrategy(asset, strategy, balance);
is being emitted but the location of this event emission is wrong, the event is emitted before the tokens are being deposited into the strategy
so make sure to correct it and emit the event after the assets are being deposited into the strategy
The function maxApproveToEigenStrategyManager
is approving max (uint256
) to eigen layer strategy which is really dangerous if the strategy is malicious so it is better to approve it according to the needs
nodeDelegatorQueue
can be DOSThe smart contract is storing all the node Delegators into an array, although the initial limit is 10 delegators but it can be increase so an uin256.max
amount and storing such an amount in an array is dangerous as the code is alliterating over the array and the array can be DOS.
https://github.com/code-423n4/2023-11-kelp/blob/main/src/LRTDepositPool.sol#L202-L205
In the function transferAssetToNodeDelegator
onlyLRTManager
is transfering the money deposited into the node Delegator but there isn't any check on the amount he passed, it could be zero or could be more then what the contract is currently holding, so it is recommended to add a check for this purpose
https://github.com/code-423n4/2023-11-kelp/blob/main/src/LRTDepositPool.sol#L183-L197
#0 - c4-pre-sort
2023-11-17T23:05:39Z
raymondfam marked the issue as insufficient quality report
#1 - c4-judge
2023-12-01T16:48:43Z
fatherGoose1 marked the issue as grade-b
🌟 Selected for report: CatsSecurity
Also found by: 0xSmartContract, 0xbrett8571, 0xepley, Bauchibred, KeyKiril, Myd, SAAJ, SBSecurity, Sathish9098, ZanyBonzy, albahaca, clara, digitizeworx, fouzantanveer, foxb868, glcanvas, hunter_w3b, invitedtea, sakshamguruji, unique
98.52 USDC - $98.52
Upon thorough examination of the presented smart contracts constituting the decentralized finance (DeFi) project, I discerned an intricately designed system that adeptly manages assets, incorporates oracle functionalities for price feeds, and implements a secure access control mechanism. The adoption of OpenZeppelin libraries is commendable, underscoring the commitment to industry best practices and substantially contributing to the overall reliability and security of the system. Nevertheless, it is imperative to underscore the necessity of a comprehensive security audit tailored specifically to the dynamic landscape of DeFi. This is crucial given the considerable financial implications and potential risks associated with decentralized financial transactions. Furthermore, the optimization of gas usage warrants careful consideration to augment the overall efficiency of contract execution. This becomes especially pertinent in decentralized environments where transaction costs wield significant influence.
Embarking on a meticulous examination of the project's codebase, my approach was comprehensive and multi-faceted, ensuring a thorough exploration of critical facets. The primary focus was on scrutinizing the overarching smart contract architecture, emphasizing modularity and adherence to best practices. A significant highlight was the implementation of upgradeable contracts, such as OpenZeppelin's ERC20Upgradeable, signifying a forward-thinking approach to contract evolution and maintenance.
Smart Contract Architecture Analysis:
import { ERC20Upgradeable } from "@openzeppelin/contracts-upgradeable/token/ERC20/ERC20Upgradeable.sol";
Security Considerations:
import { AccessControlUpgradeable } from "@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol";
Asset Management and Strategies:
function depositAssetIntoStrategy(address asset) external onlySupportedAsset(asset) onlyLRTManager { // Implementation... }
Oracle Integration:
function updatePriceFeedFor(address asset, address priceFeed) external onlyLRTManager onlySupportedAsset(asset) { // Implementation... }
Gas Optimization:
function getAssetPrice(address asset) external view onlySupportedAsset(asset) returns (uint256) { return AggregatorInterface(assetPriceFeed[asset]).latestAnswer(); }
Contract Initialization and Upgrades:
initialize
function in upgradeable contracts.function initialize(address admin, address lrtConfigAddr) external initializer { // Initialization logic... }
Role-Based Access Control (RBAC):
bytes32 public constant MINTER_ROLE = keccak256("MINTER_ROLE");
Pausing and Unpausing Functionality:
function pause() external onlyLRTManager { _pause(); }
Configurability and Flexibility:
function updateLRTConfig(address lrtConfigAddr) external override onlyRole(DEFAULT_ADMIN_ROLE) { // Implementation... }
This holistic evaluation framework ensures a deep understanding of the project's intricacies, addressing critical aspects ranging from contract initialization to gas optimization, and fortifying the codebase against potential vulnerabilities while promoting flexibility and scalability.
In optimizing the architecture of the presented DeFi project, a few key considerations emerge to enhance efficiency, security, and user experience. Firstly, implementing a modular approach to smart contract development can significantly streamline maintenance and upgrades. Each distinct functionality, such as asset management, oracle integration, and access control, should be encapsulated within separate contracts, allowing for more straightforward upgrades and targeted optimizations. Moreover, gas optimization techniques should be explored, leveraging mechanisms like function modifiers and storage layout adjustments to minimize transaction costs. The introduction of event-driven programming practices can also enhance the overall responsiveness of the system, ensuring real-time updates for users. Lastly, a comprehensive test suite should be established to validate the functionality of each smart contract, mitigating the risk of potential vulnerabilities.
Modular Development:
// Example of Modular Development contract AssetManagement { // Asset-related functions and storage } contract OracleIntegration { // Oracle-related functions and storage } contract AccessControl { // Access control-related functions and storage }
Gas Optimization:
Event-Driven Programming:
// Example of Event-Driven Programming event AssetPriceFeedUpdate(address indexed asset, address indexed priceFeed); function updatePriceFeedFor(address asset, address priceFeed) external onlyLRTManager onlySupportedAsset(asset) { UtilLib.checkNonZeroAddress(priceFeed); assetPriceFeed[asset] = priceFeed; emit AssetPriceFeedUpdate(asset, priceFeed); }
Security Measures:
Documentation:
These recommendations collectively aim to enhance the overall robustness, security, and maintainability of the project. By following these best practices, the smart contracts can effectively adapt to changing requirements and emerging challenges in the decentralized finance landscape.
The smart contract codebase exhibits commendable organization and modularity. Utilizing OpenZeppelin libraries such as ERC20Upgradeable and AccessControlUpgradeable enhances the code's robustness and aligns with industry best practices. The code structure, with separate contracts for distinct functionalities, promotes readability and scalability. However, there is a need for a DeFi-specific security audit to comprehensively assess potential vulnerabilities. While security measures are present, the financial nature of the project demands a tailored evaluation. Gas optimization strategies should also be explored for improved efficiency in decentralized transactions.
// Example of Modular Structure import { UtilLib } from "./utils/UtilLib.sol"; import { LRTConfigRoleChecker, ILRTConfig } from "./utils/LRTConfigRoleChecker.sol";
// Example of OpenZeppelin Library Usage import { ERC20Upgradeable, Initializable } from "@openzeppelin/contracts-upgradeable/token/ERC20/ERC20Upgradeable.sol";
// Example Comment Highlighting Security Consideration // TODO: Perform a DeFi-specific security audit for comprehensive vulnerability assessment.
// Example of Gas Optimization Comment // TODO: Explore gas optimization strategies to enhance contract efficiency.
The implementation of an access control mechanism using OpenZeppelin's AccessControlUpgradeable contract is a positive aspect, mitigating unauthorized access risks. However, a thorough analysis of role assignments is crucial to prevent unintended centralization. The reliance on external oracles introduces a degree of centralization risk; considering decentralized oracle solutions or implementing failure mitigation mechanisms is advisable. The admin role, while necessary, should be scrutinized to prevent it from becoming a single point of failure. Distributing admin roles judiciously can help avoid unnecessary centralization. Addressing these points contributes to ongoing efforts in enhancing the codebase and minimizing centralization risks within the presented DeFi project.
Centralization Risks:
// Example of Role Assignment bytes32 public constant MINTER_ROLE = keccak256("MINTER_ROLE");
// Example Comment Addressing Oracle Centralization Risk // TODO: Evaluate decentralized oracle solutions to mitigate centralization risk associated with external oracles.
// Example Comment on Admin Role Distribution // TODO: Distribute admin roles judiciously to prevent unnecessary centralization risks.
In examining the mechanisms embedded within the provided smart contracts of the decentralized finance (DeFi) project, I've identified several key components that intricately govern the system's functionality. The utilization of OpenZeppelin libraries ensures a solid foundation for essential functionalities, such as asset management, role-based access control, and pausability features. The contracts employ an upgradeable pattern, allowing for future improvements without compromising the integrity of existing data and functionalities. The inclusion of an oracle system, facilitated by Chainlink and other interfaces, enhances the reliability of asset pricing. Additionally, the access control roles, such as MINTER_ROLE and BURNER_ROLE in the RSETH contract, ensure that only authorized entities can mint or burn tokens. Overall, the mechanism review indicates a thoughtful design that prioritizes security, extensibility, and efficient asset management.
Mechanism Review Points:
OpenZeppelin Libraries Integration:
Upgradeable Pattern:
Oracle Integration:
Role-Based Access Control:
This mechanism review affirms a well-thought-out design that prioritizes security, scalability, and effective asset management within the DeFi project.
In evaluating the presented DeFi project, several systemic risks have come to light that necessitates careful consideration. The complexity of the system, while a strength, also poses inherent risks that demand proactive mitigation strategies. The interplay between various smart contracts and the reliance on external oracles introduce vulnerabilities that could potentially lead to unexpected behavior or exploitation. Moreover, the gas optimization strategies should be meticulously fine-tuned to prevent potential bottlenecks, ensuring that transaction costs remain reasonable for users. A crucial aspect is the need for a comprehensive security audit, tailored specifically to the dynamics of decentralized finance, to identify and rectify potential vulnerabilities before they can be exploited.
Price Oracle Manipulation: As the project relies on price oracles, there exists a risk of manipulation or corruption of these oracles. Continuous monitoring and integration of decentralized oracle solutions can mitigate this risk.
Gas Optimization Bottlenecks: Inadequate gas optimization may lead to transaction bottlenecks, affecting the efficiency of contract execution and increasing costs for users.
Smart Contract Upgradability Risks: The ability to upgrade smart contracts, while providing flexibility, introduces risks if not executed cautiously.
Note: I didn't tracked time while auditing the codebase, so using just a random time
4 hours
#0 - c4-pre-sort
2023-11-17T03:17:52Z
raymondfam marked the issue as sufficient quality report
#1 - c4-judge
2023-11-29T18:56:30Z
fatherGoose1 marked the issue as grade-a