Platform: Code4rena
Start Date: 24/10/2023
Pot Size: $36,500 USDC
Total HM: 4
Participants: 147
Period: 6 days
Judge: 0xDjango
Id: 299
League: ETH
Rank: 64/147
Findings: 1
Award: $88.73
🌟 Selected for report: 0
🚀 Solo Findings: 0
🌟 Selected for report: radev_sw
Also found by: 0xSmartContract, 0xweb3boy, Al-Qa-qa, Bauchibred, Bulletprime, D_Auditor, J4X, JCK, K42, Kral01, Sathish9098, ZanyBonzy, albahaca, catellatech, clara, digitizeworx, fouzantanveer, hunter_w3b, invitedtea, jauvany, oakcobalt, pavankv, peanuts, xiao
88.7348 USDC - $88.73
By InvitedTea | @invitedTea | Oct 28 2023
List | Head | Details |
---|---|---|
1 | Overview of Ethena | Ethena is a DeFi platform that offers a "delta-neutral stablecoin" named USDe. It provides users with the dual benefit of minting or redeeming USDe and earning a sustainable yield. |
2 | Approach taken in evaluating the codebase | The evaluation involves a preliminary analysis by reading the README.md and Gitbook doc, a high-level overview of the codebase, a review of documentation, and a detailed line-by-line analysis of the code. |
3 | Architecture recommendations | Suggestions for optimizing contract interactions, enhancing security measures, and improving data handling. |
4 | Codebase quality analysis | Recommendations for improving code readability, input validation, and gas optimization. |
5 | Mechanism review | An evaluation of the design and implementation of various mechanisms, such as staking, minting, and redemption. |
6 | Systemic risks | Identified risks include potential vulnerabilities in the minting and redemption mechanisms, the complexity of staking contracts, and the centralized nature of access control. |
7 | Time spent on analysis | The report does not specify the time spent on the analysis. |
A delta-neutral stablecoin protocol with sustainable yield
Ethena
is a DeFi platform that introduces a delta-neutral stablecoin
named USDe. It offers users the dual benefit of minting or redeeming USDe and simultaneously earning a sustainable yield through mechanisms like Ethereum staking and perpetual position hedging.
Through its distinctive approach, Ethena
bridges the space between traditional stablecoin systems and yield generation in the DeFi landscape. Leveraging the power of the EIP712 signature system and a robust backend infrastructure, it ensures that users can transact securely while maintaining the integrity of their funds and rewards.
Preliminary analysis
: I read the Ethena README.md
file and took the following notes:
The Ethena
learnings:
delta-neutral stablecoin
named USDe.mint
and redeem
USDe, and also earn a sustainable yield
through various mechanisms.EIP712 signatures
and backend checks to ensure secure transactions.Areas to focus:
High-level overview
: I analyzed the overall codebase
in one iteration to obtain a high-level understanding of the code structure
and functionality
.
Documentation review
: I studied the documentation
to comprehend the purpose of each function
, its functionality
, and how it interacts with other parts of the system.
Literature review
: I read previous audits
and known findings
to understand any historical vulnerabilities or issues.
Testing setup
: I set up my testing environment
and ran preliminary tests to confirm that all tests passed
. I utilized tooling specific to Ethereum contracts for testing.
Detailed analysis
: I initiated a detailed analysis
of the codebase, examining it line by line
. I meticulously took notes to formulate questions for the development team
. I utilized @audit
tags to identify and flag potentially vulnerable or weak parts
in the codebase. I then proceeded with in-depth analyses, performing all necessary unit
and fuzz tests
to ensure the protocol operates as intended.
Ethena
emerges as a pioneering DeFi platform with its focus on offering a delta-neutral stablecoin
named USDe. It not only allows users to mint and redeem this stablecoin but also provides them with a sustainable yield. Ethena's unique contributions to the DeFi space include:
Delta-Neutral Stablecoin
: Ethena's innovation is in its delta-neutral stablecoin, USDe, which aims to bring stability and yield to the DeFi ecosystem. This unique feature marks a new avenue in stablecoin design, merging the worlds of stability and yield generation.
Secure Minting and Redeeming
: Ethena's use of EIP712 signatures and backend checks ensure that minting and redeeming operations are secure and reliable. This signifies Ethena's commitment to maintaining a robust and secure transactional environment for its users.
Sustainable Yield Generation
: Ethena's USDe allows users to earn a sustainable yield through mechanisms like Ethereum staking and perpetual position hedging. This balances the need for stability with the desire for yield, encapsulating Ethena's vision of a DeFi ecosystem that offers the best of both worlds.
Delegated Signers and Governance
: The system allows for delegated signers, making it flexible for users who trade via smart contracts. The governance model, controlled by Ethena DAO, ensures that the protocol can evolve and adapt to the community's needs.
USDe.sol
: This is the main USDe token stablecoin contract. It grants another specified contract the ability to mint USDe. It uses libraries like @openzeppelin/ERC20Burnable.sol
, @openzeppelin/ERC20Permit.sol
, and @openzeppelin/Ownable2Step.sol
.
EthenaMinting.sol
: This contract handles both the minting and redemption of USDe tokens. The USDe.sol contract grants this contract the ability to mint the stablecoin. It uses the @openzeppelin/ReentrancyGuard.sol
library for added security against re-entrancy attacks.
StakedUSDe.sol
: An extension of ERC4626, this contract allows users to stake USDe tokens and receive stUSDe, which increases in value as Ethena deposits protocol yield into the contract. Libraries used include @openzeppelin/ReentrancyGuard.sol
, @openzeppelin/ERC20Permit.sol
, and @openzeppelin/ERC4626.sol
.
StakedUSDeV2.sol
: This contract extends StakedUSDe and adds a redemption cooldown feature, enhancing the security and operation of redemptions.
USDeSilo.sol
: This is a simple contract used to temporarily hold USDe tokens during the redemption cooldown period, ensuring that the tokens are secure and isolated during this time.
SingleAdminAccessControl.sol
: EthenaMinting uses this for access control instead of the standard OpenZeppelin AccessControl. This contract manages the permissions for admin functionalities within the EthenaMinting contract.
After a comprehensive review of the Ethena codebase and its underlying architecture, I propose the following architectural improvement recommendations:
The EthenaMinting.sol
contract is central to minting and redeeming USDe tokens. To optimize:
The contracts StakedUSDe.sol
and StakedUSDeV2.sol
focus on staking and yield generation.
With the use of SingleAdminAccessControl.sol
for access management, it's crucial to ensure robust security.
Given that Ethena is a pioneering platform in the DeFi space, it might look to add more features in the future, such as:
Due to the complex and interconnected nature of the contracts—especially those related to minting, redeeming, and staking—a comprehensive third-party audit would greatly enhance the protocol's security posture. This audit should focus particularly on these core components and any potential vulnerabilities related to them.
require
statements in the contracts include error messages, but these could be more descriptive to provide better insights for both users and developers.ReentrancyGuard
is good for security, but further gas optimization, especially in functions like staking and minting, could be beneficial.EthenaMinting.sol
, have multiple responsibilities. Breaking these down into smaller, specialized contracts could make the codebase more maintainable.SingleAdminAccessControl.sol
contract handles access control. More granular, role-based access control could enhance the system's security.StakedUSDeV2.sol
suggests that the staking mechanism has undergone iterations. Ensuring backward compatibility and smooth upgrades will be crucial.ReentrancyGuard
to protect against reentrancy attacks. This should be consistently applied across all contracts where needed.Ethena distinguishes itself as a highly specialized DeFi platform, focusing on minting, staking, and yield generation. The platform appears to have been designed with several unique mechanisms to ensure a seamless and secure user experience.
Utilizing a simplified access control mechanism through SingleAdminAccessControl.sol
, Ethena makes sure that access to crucial contract functionalities is tightly controlled, enhancing the system's security.
The EthenaMinting.sol
contract serves as the core of the platform's minting and redeeming functionalities. Its design seems to prioritize both security and efficiency, providing a robust foundation for the protocol.
With contracts like StakedUSDe.sol
and StakedUSDeV2.sol
, Ethena has introduced an innovative approach to staking and yield generation. These contracts aim to provide users with a dynamic way to earn returns on their staked assets.
By leveraging well-known libraries like OpenZeppelin for standard functionalities, the protocol keeps external dependencies minimal. This reduces the attack surface and minimizes the impact of vulnerabilities in third-party code.
The contracts employ rigorous input validation and make use of OpenZeppelin's ReentrancyGuard
to protect against reentrancy attacks, highlighting the protocol's focus on security.
The introduction of StakedUSDeV2.sol
suggests that the protocol is designed with upgradability in mind, allowing for the implementation of new features or improvements without disrupting existing functionalities.
After an in-depth analysis of Ethena's codebase, several potential vulnerabilities and risks have been identified. These concerns could affect both the technical and operational aspects of the protocol.
The EthenaMinting.sol
contract is pivotal for the platform's minting and redeeming functionalities. Any security vulnerabilities in this contract could have severe implications. Additionally, the protocol's limited collateral for hot redemptions ($100k-$200k) could pose liquidity risks. On-chain mint and redeem limitations, along with the introduction of GATEKEEPER
roles, add another layer of complexity and potential risks, such as centralization and monitoring effectiveness.
Contracts like StakedUSDe.sol
and StakedUSDeV2.sol
introduce complexity with their staking mechanisms. Vulnerabilities in these contracts could jeopardize staked assets.
The SingleAdminAccessControl.sol
and GATEKEEPER
roles manage crucial access controls and monitoring. Their centralized nature makes them single points of failure, putting the entire system at risk if compromised. Specifically, the SingleAdminAccessControl.sol
contract could be a risk factor due to its sole control over key functionalities.
The presence of StakedUSDeV2.sol
suggests plans for future upgrades. Ensuring seamless backward compatibility during such transitions will be crucial.
The protocol employs custom access control logic, which needs thorough scrutiny to ensure its robustness and security.
The SingleAdminAccessControl.sol
contract and GATEKEEPER
roles could be potential risk factors due to their central roles in access control and monitoring. Their permissions and functionalities should be carefully reviewed.
Contrary to earlier observations, the protocol does have emergency mechanisms through the GATEKEEPER
roles, but these introduce their own set of risks related to centralization and effective monitoring.
None of the contracts have a fallback or receive function to manage unexpected or accidental Ether transfers, resulting in the risk of trapped Ether.
The protocol's dependency on external services like AWS for its GATEKEEPER
roles could introduce additional vulnerabilities and dependencies.
24 Hours
24 hours
#0 - c4-pre-sort
2023-11-01T14:50:22Z
raymondfam marked the issue as sufficient quality report
#1 - c4-judge
2023-11-10T19:14:27Z
fatherGoose1 marked the issue as grade-a