Update initializer modifier to prevent reentrancy during initialization
The project used outdated OpenZeppelin contracts with a known reentrancy vulnerability in the initializer modifier, affecting several upgradeable contracts. An attacker could potentially reenter during initialization, though the exact impact is not detailed in the text.
Submitted by Dravee
The solution uses:
"@openzeppelin/contracts": "^4.0.0",
"@openzeppelin/contracts-upgradeable": "^4.3.2",
These dependencies have a known high severity vulnerability:
- https://security.snyk.io/vuln/SNYK-JS-OPENZEPPELINCONTRACTSUPGRADEABLE-2320177
- https://snyk.io/test/npm/@openzeppelin/contracts-upgradeable/4.3.2#SNYK-JS-OPENZEPPELINCONTRACTSUPGRADEABLE-2320177
- https://snyk.io/test/npm/@openzeppelin/contracts/4.0.0#SNYK-JS-OPENZEPPELINCONTRACTS-2320176
Which makes these contracts vulnerable:
contracts/helpers/CryptoPunksHelper.sol:
19: function initialize(address punksAddress) external initializer {
contracts/helpers/EtherRocksHelper.sol:
19: function initialize(address rocksAddress) external initializer {
contracts/staking/JPEGStaking.sol:
21: function initialize(IERC20Upgradeable _jpeg) external initializer {
contracts/vaults/FungibleAssetVaultForDAO.sol:
71: ) external initializer {
contracts/vaults/NFTVault.sol:
149: ) external initializer {
Recommended Mitigation Steps
Upgrade @openzeppelin/contracts and @openzeppelin/contracts-upgradeable to version 4.4.1 or higher.
spaghettieth (JPEG’d) confirmed, but disagreed with High severity
spaghettieth (JPEG’d) resolved and commented:
Fixed in jpegd/core#11.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
How it worked
Impact
The vulnerability could allow reentrancy during initialization, but the text does not specify the exact consequences.
What the attacker needed
None
The fix
The dependencies were upgraded to version 4.4.1 or higher, and the project confirmed the fix.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
This report is about using old versions of a software library that have a known security flaw. The flaw is in a function that runs once when a contract is set up, and it could let an attacker interfere with that setup. The fix is simply to update the library to a newer version.
What is Smart contracts?
Flaws in on-chain code that let an attacker drain funds, freeze them or break the protocol's accounting.