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: 62/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
Ethena Labs aims to create a permissionless stablecoin called USDe, which offers yield to users in the DeFi ecosystem. Unlike USDC, where Circle captures the yield, USDe holders can stake their USDe to receive stUSDe, which increases in value as the protocol earns yield, similar to rETH relative to ETH.
USDe is minted through an RFQ process, where users agree to a price and sign an EIP712 signature. stETH is traded for newly minted USDe at the specified rate, and a short ETH perps position is created to maintain delta neutrality.
Yield generated from the long stETH and short ETH perps positions is sent to an insurance fund and staking contract.
Security measures are in place to prevent abuse, such as limiting minting and redeeming to 100k USDe per block, gatekeeper roles, and external organizations potentially having gatekeeper roles.
Ethena's goal extends beyond the technical aspects; it strives to provide users with a high degree of trust and security in the DeFi ecosystem. This involves strict control over asset freezing and repossessing, and maintaining a robust, transparent, and trustworthy operational framework.
The EthenaMinting contract defines some privilege roles that control who can perform specific actions within the contract:
This role allows the creation of USDe from assets. Holders of this role can generate new USDe.
/// @notice role enabling to invoke mint bytes32 private constant MINTER_ROLE = keccak256("MINTER_ROLE");
Permits the redemption of USDe for assets. Holders of this role can redeem USDe for assets.
/// @notice role enabling to invoke redeem bytes32 private constant REDEEMER_ROLE = keccak256("REDEEMER_ROLE");
This role has the power to enable or disable the ability to mint and redeem USDe, as well as remove minters and redeemers in emergency situations.
/// @notice role enabling to disable mint and redeem and remove minters and redeemers in an emergency bytes32 private constant GATEKEEPER_ROLE = keccak256("GATEKEEPER_ROLE");
Allows for administrative actions, such as managing supported assets and custody addresses, setting minting and redeeming limits, and other general contract configurations.
_grantRole(DEFAULT_ADMIN_ROLE, msg.sender);
IMPORTATN ‼️‼️: The ownership of smart contracts is held in a Gnosis Safe multisig with cold wallet keys, requiring 7/10 confirmations for transactions. Additionally, there are restrictions on staking for specific addresses and the ability to freeze and repossess funds for legal and security reasons.
Given the level of control that these roles
possess within the system, users must place full trust in the fact that the entities overseeing these roles
will always act correctly and in the best interest of the system
and its users
.
High-level overview : I analyzed the overall codebase in one iteration to get a high-level understanding of the code structure and functionality.
Documentation review : I studied the documentation to understand the purpose of each contract, its functionality, and how it is connected with other contracts.
Literature review : I read old audits and known findings, as well as the bot races findings.
Testing setup : I set up my testing environment and ran the tests to ensure that all tests passed. Used yarn and hardhat to test this protocol or foundry as well.
Detailed analysis : I started with the detailed analysis of the code base, line by line. I took the necessary notes to ask some questions to the sponsors.
The Ethena protocol comprises three main components: USDe.sol, EthenaMinting.sol, and StakedUSDeV2.sol. These components work together to facilitate the functioning of the protocol:
In general, the architecture focuses on providing a stable token, enabling secure minting and redemption, and offering user participation and yield opportunities. Security is a central consideration, with roles and controls thoughtfully designed to mitigate risks.
See the following diagram to see how the users interact with the protocol
Ethena Labs could face some risks of centralization and systemic issues within its architecture.
Centralized Control Risk: Ethena Labs rely on a number of central roles and authorities, such as the USDe minter, EthenaMinting admin, GATEKEEPER_ROLE, among others. This could lead to centralized control in the hands of a few entities or individuals, which goes against the decentralized spirit of blockchain technology.
Censorship Risk: The ability of GATEKEEPER_ROLE to disable the minting and redeeming function of USDe and remove roles from authorized accounts could lead to censorship issues. If these capabilities are misused or employed maliciously, users may face difficulties in accessing their assets.
Security Risk: Since Ethena Labs uses a role-based permission structure, any security breach that allows malicious actors to gain access to important roles like MINTER_ROLE or REDEEMER_ROLE could have severe consequences for the platform and its users.
Systemic Risk: Ethena Labs has a business model where it benefits from differences in asset yields. Any systemic events in the underlying markets could significantly affect the stability and performance of USDe and stUSDe.
Overall, Ethena Labs should be aware of these risks and take appropriate measures to address them and protect the interests of its users. Security, decentralization, and transparency are key considerations in the DeFi ecosystem.
Our new insights from this Ethena Labs audit have been exponential. We have learned about the introduction of its stablecoin, USDe, and unique yield opportunities for users within its ecosystem. Key takeaways from their approach include a strong emphasis on security through role-based controls and risk management mechanisms. They utilize a network of smart contracts for USDe minting and staking, highlighting the importance of a well-structured DeFi architecture. User engagement is a central focus, allowing users to actively participate and earn yields. Additionally, Ethena Labs addresses regulatory compliance with roles tailored to specific jurisdictions. Their model underscores the complexity and challenges inherent in DeFi platforms, emphasizing the need for effective implementation and adaptability in the ever-evolving DeFi landscape.
What the project can add in the understanding of Security;
By distributing the project to testnets, ensuring that the audits are carried out in onchain audit.
Pause Mechanism This is a chaotic situation, which can be thought of as a choice between decentralization and security.
Add On-Chain Monitoring System; If On-Chain Monitoring systems such as Forta are added to the project, its security will increase.
For example ; This bot tracks any DEFI transactions in which wrapping, unwrapping, swapping, depositing, or withdrawals occur over a threshold amount. If transactions occur with unusually high token amounts, the bot sends out an alert. https://app.forta.network/bot/0x7f9afc392329ed5a473bcf304565adf9c2588ba4bc060f7d215519005b8303e3
The audit scope of the contracts to be reviewed is 70%, with the aim of reaching 100% to increase the safety.
Ethena Labs project exhibits an interesting and well-developed architecture we believe the team has done a good job regarding the code, but the identified risks need to be addressed, and measures should be implemented to protect the protocol from potential malicious use cases. It is also highly recommended that the team continues to invest in security measures such as mitigation reviews, audits, and bug bounty programs to maintain the security and reliability of the project.
15 hours
#0 - c4-pre-sort
2023-11-01T14:49:10Z
raymondfam marked the issue as high quality report
#1 - c4-sponsor
2023-11-09T19:28:45Z
FJ-Riveros (sponsor) acknowledged
#2 - c4-judge
2023-11-10T19:14:48Z
fatherGoose1 marked the issue as grade-a