Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Uninitialized Implementation Contracts are not Completely Protected #249

Open
c4-bot-8 opened this issue Jun 8, 2024 · 0 comments
Open
Labels
2 (Med Risk) Assets not at direct risk, but function/availability of the protocol could be impacted or leak value bug Something isn't working edited-by-warden 🤖_36_group AI based duplicate group recommendation sufficient quality report This report is of sufficient quality

Comments

@c4-bot-8
Copy link
Contributor

c4-bot-8 commented Jun 8, 2024

Lines of code

https://github.com/code-423n4/2024-05-predy/blob/main/src/PredyPool.sol#L68
https://github.com/code-423n4/2024-05-predy/blob/main/src/markets/gamma/GammaTradeMarket.sol#L67
https://github.com/code-423n4/2024-05-predy/blob/main/src/markets/perp/PerpMarketV1.sol#L90

Vulnerability details

Impact

The uninitialized implementation contracts are not totally safe against an eventual takeover by an attacker even if their initialize functions use initializer modifier.

Proof of Concept

As a proof of concept, I’ll provide the links to the relevant OpenZeppelin documentation / communication.

According to OpenZeppelin’s documentation:

https://github.com/OpenZeppelin/openzeppelin-contracts-upgradeable/blob/master/contracts/proxy/utils/Initializable.sol#L43-L45

An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation contract, which may impact the proxy. To prevent the implementation contract from being used, you should invoke the {_disableInitializers} function in the constructor to automatically lock it when it is deployed.

Here is the link to the respective communication with OpenZeppelin staff:
https://forum.openzeppelin.com/t/what-does-disableinitializers-function-mean/28730/7

Tools Used

Manual checking.

Recommended Mitigation Steps

Invoke _disableInitializers wherever applicable:

// src/PredyPool.sol

contract PredyPool is IPredyPool, IUniswapV3MintCallback, Initializable, ReentrancyGuardUpgradeable {
	...
	constructor() {
+		_disableInitializers();
	}
	...
}
// src/markets/gamma/GammaTradeMarket.sol

contract GammaTradeMarket is IFillerMarket, BaseMarketUpgradable, ReentrancyGuardUpgradeable {
	...
	constructor() {
+		_disableInitializers();
	}
	...
}
// src/markets/perp/PerpMarketV1.sol

contract PerpMarketV1 is BaseMarketUpgradable, ReentrancyGuardUpgradeable {
	...
	constructor() {
+		_disableInitializers();
	}
	...
}

Assessed type

Upgradable

@c4-bot-8 c4-bot-8 added 2 (Med Risk) Assets not at direct risk, but function/availability of the protocol could be impacted or leak value bug Something isn't working labels Jun 8, 2024
c4-bot-9 added a commit that referenced this issue Jun 8, 2024
@c4-bot-8 c4-bot-8 changed the title Incomplete Protection of Uninitialized Implementation Contracts From Attacker Uninitialized Implementation Contracts are not Completely Protected Jun 9, 2024
@c4-bot-12 c4-bot-12 added the 🤖_36_group AI based duplicate group recommendation label Jun 14, 2024
howlbot-integration bot added a commit that referenced this issue Jun 17, 2024
@howlbot-integration howlbot-integration bot added the sufficient quality report This report is of sufficient quality label Jun 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
2 (Med Risk) Assets not at direct risk, but function/availability of the protocol could be impacted or leak value bug Something isn't working edited-by-warden 🤖_36_group AI based duplicate group recommendation sufficient quality report This report is of sufficient quality
Projects
None yet
Development

No branches or pull requests

3 participants