Platform: Code4rena
Start Date: 08/09/2023
Pot Size: $70,000 USDC
Total HM: 8
Participants: 84
Period: 6 days
Judge: gzeon
Total Solo HM: 2
Id: 285
League: ETH
Rank: 3/84
Findings: 2
Award: $3,092.33
🌟 Selected for report: 1
🚀 Solo Findings: 0
3057.637 USDC - $3,057.64
https://github.com/code-423n4/2023-09-centrifuge/blob/main/src/LiquidityPool.sol#L141-L152
Deposit and mint under LiquidityPool lack access control, which enables any user to proceed the mint/deposit for another user. Attacker can deposit (this does not require tokens) some wai before users TX to DoS the deposit.
deposit and mint do processDeposit/processMint which are the secondary functions to the requests. These function do not take any value in the form of tokens, but only send shares to the receivers. This means they can be called for free.
With this an attacker who wants to DoS a user, can wait him to make the request to deposit and on the next epoch front run him by calling deposit with something small like 1 wei. Afterwards when the user calls deposit
, his TX will inevitable revert, as he will not have enough balance for the full deposit.
Manual review.
Have some access control modifiers like withApproval used also in redeem.
- function deposit(uint256 assets, address receiver) public returns (uint256 shares) { + function deposit(uint256 assets, address receiver) public returns (uint256 shares) withApproval(receiver) { shares = investmentManager.processDeposit(receiver, assets); emit Deposit(address(this), receiver, assets, shares); } - function mint(uint256 shares, address receiver) public returns (uint256 assets) { + function mint(uint256 shares, address receiver) public returns (uint256 assets) withApproval(receiver) { assets = investmentManager.processMint(receiver, shares); emit Deposit(address(this), receiver, assets, shares); }
Access Control
#0 - c4-pre-sort
2023-09-15T01:27:17Z
raymondfam marked the issue as primary issue
#1 - c4-pre-sort
2023-09-15T01:27:21Z
raymondfam marked the issue as sufficient quality report
#2 - c4-pre-sort
2023-09-17T06:15:12Z
raymondfam marked the issue as high quality report
#3 - c4-pre-sort
2023-09-17T06:15:58Z
raymondfam marked the issue as sufficient quality report
#4 - c4-sponsor
2023-09-18T12:56:08Z
hieronx (sponsor) confirmed
#5 - gzeon-c4
2023-09-26T14:56:17Z
Duplicates need to mention the DOS / dust attack to qualify
#6 - c4-judge
2023-09-26T14:56:23Z
gzeon-c4 marked the issue as selected for report
#7 - hieronx
2023-10-03T13:53:43Z
🌟 Selected for report: ciphermarco
Also found by: 0x3b, 0xbrett8571, 0xmystery, 0xnev, K42, Kral01, Sathish9098, castle_chain, catellatech, cats, emerald7017, fouzantanveer, foxb868, grearlake, hals, jaraxxus, kaveyjoe, lsaudit, rokinot
34.6879 USDC - $34.69
The audit unveiled a well-structured and intriguing codebase, primarily centered around economic aspects. While the code demonstrated promise, there were minor concerns regarding code quality and documentation. Additionally, the architecture exhibited potential, particularly in the proposal to introduce a flywheel mechanism to incentivize users. The audit also raised awareness about centralization risk, emphasizing the need to strike a balance between centralization and decentralization for optimal system resilience.
Severity | Occurrences |
---|---|
High | 1 |
Medium | 7 |
Low | 1 |
Gas | 0 |
Analysis | 8 hours |
Start date | 08.09.2023 |
End date | 14.09.2023 |
Total | 6 days |
Members | Positions | Time spent |
---|---|---|
0x3b | full time researcher | ~50H |
The codebase was "a blast," and the time spent was just perfect. I had enough time to delve into every aspect of the scope, even exploring some out-of-scope codebases to gather reference points. The economics were truly fascinating, and I examined them from every perspective. The bridge was intriguing, though unfortunately, the other part of the code was out of scope. In fact, approximately 80% of my time was dedicated to attempts to manipulate the rewards, deposits, and withdrawals. I encountered several scenarios where any user could potentially cause damage, extract value, and achieve a better profit by manipulating the price to their advantage.
The code quality was excellent, however, it contained some unnecessary functions that only increased gas consumption during deployments. Additionally, it lacked proper testing. The bridge part was highly sophisticated, however again, due to the numerous missing pieces of information, I suspect that some of the findings may be invalid. In general, there might be many false positives or unexpected behaviors. For future reference, it would be much better to have more natural language specifications or more documentation on the matter.
LiquidityPool.sol
InvestmentManager.sol
Escrow.sol
approve
, which approves different contracts to spend its tokens.PoolManager.sol
UserEscrow.sol
Root.sol
PauseAdmin.sol
DelayedAdmin.sol
Tranche.sol
ERC20.sol
RestrictionManager.sol
Gateway.sol
Messages.sol
Router.sol
Auth.sol
Context.sol
msg.sender
.Factory.sol
SafeTransferLib.sol
The contracts provided to us were sufficient to achieve the system's intended goals. They included managers, wrappers, and bridges. They were relatively simple, and the code was straightforward, making the audit a pleasant experience.
One potential enhancement I would recommend is implementing a flywheel mechanism to further incentivize and encourage users to stake on Centrefuge.
Another alternative worth considering is incorporating an NFT concept. Users could lock their stakes and receive a minted NFT, which they could choose to sell or hold. This approach could introduce an intriguing dimension to the system and offer users additional benefits for their participation in Centrifuge. It's important to note that I am not a consultant on stocks and bonds, and I cannot say whether these suggestions would comply with the law.
The system's centralization risk is significant due to the absence of any form of governance. It does have admins, including both EOAs and other contracts. However, this centralization may not be a major concern, provided that these admins are genuinely invested in the project's overall growth. When harnessed effectively, centralization can provide the system with a competitive edge over its competitors. It facilitates rapid decision-making, enabling Centrefuge to adapt swiftly and stay ahead of industry trends. In contrast, decentralized DAO systems often require proposals, votes, and lengthy approval and implementation processes.
Nevertheless, it's crucial to acknowledge that centralization also carries potential downsides, such as an increased vulnerability to single points of failure. Striking a balance between centralization and decentralization is important to ensure the system's robustness and sustainability. One recommended approach is to implement a multisig system involving a small group of developers/owners who can collectively make decisions. This approach ensures that the protocol remains secure even if a private key is leaked or an account is compromised, while still maintaining agility.
However, it's worth recognizing the developers' efforts in mitigating the impact of malicious admins. From the code, it's apparent that the most they can do before being removed is to pause the system, which is not a significant issue. On the other hand, the EOA method also enables quick responses to emergencies since, in the event of one, an EOA can promptly pause the entire system.
The current state of this protocol leaves it susceptible to various types of economic attacks. Certain functions within the code can be manipulated by users to gain advantages over others or even illicitly acquire tokens from the protocol. However, after a comprehensive refinement following this audit, the risks associated with these vulnerabilities can be significantly reduced. By addressing these weaknesses and implementing robust security measures, the protocol can become more resilient against potential economic attacks.
Nonetheless, it is crucial to exercise caution when adding new features to the code, especially those involving economic incentives. While they can enhance the protocol's performance and attract users, they also tend to be the most vulnerable points, susceptible to exploitation if not designed and implemented with the utmost care.
-50 hours
#0 - c4-pre-sort
2023-09-17T02:02:05Z
raymondfam marked the issue as sufficient quality report
#1 - c4-judge
2023-09-26T17:21:22Z
gzeon-c4 marked the issue as grade-b