Platform: Code4rena
Start Date: 07/04/2023
Pot Size: $47,000 USDC
Total HM: 20
Participants: 120
Period: 6 days
Judge: GalloDaSballo
Total Solo HM: 4
Id: 230
League: ETH
Rank: 101/120
Findings: 1
Award: $10.86
🌟 Selected for report: 0
🚀 Solo Findings: 0
🌟 Selected for report: AkshaySrivastav
Also found by: 0xTheC0der, Dug, GT_Blockchain, Haipls, adriro, bin2chen, carlitox477, dingo2077, fs0c, hasmama, hihen, holyhansss_kr, juancito, ladboy233, philogy, saian, said, sashik_eth, yixxas, zion
10.8554 USDC - $10.86
https://github.com/code-423n4/2023-04-caviar/blob/cd8a92667bcb6657f70657183769c244d04c015c/src/Factory.sol#L81 https://github.com/code-423n4/2023-04-caviar/blob/cd8a92667bcb6657f70657183769c244d04c015c/src/Factory.sol#L92
Because of the CREATE2 opcode clones an existing contract at a deterministic address by the salt, this could be front-run by an MEV bot passing in the same parameters and changing the salt.
// @params (_baseToken, _nft, _virtualBaseTokenReserves, _virtualNftReserves, _changeFee, _feeRate, _merkleRoot, _useStolenNftOracle, _payRoyalties, tokenIds, baseTokenAmount) could all be copied // while @param _salt can be changed and the transaction could be front-run to essentially take up the address that the salt would have clone would now revert.
function create( address _baseToken, address _nft, uint128 _virtualBaseTokenReserves, uint128 _virtualNftReserves, uint56 _changeFee, uint16 _feeRate, bytes32 _merkleRoot, bool _useStolenNftOracle, bool _payRoyalties, bytes32 _salt, uint256[] memory tokenIds, // put in memory to avoid stack too deep error uint256 baseTokenAmount ) public payable returns (PrivatePool privatePool) {
privatePool = PrivatePool(payable(privatePoolImplementation.cloneDeterministic(_salt)));
https://docs.openzeppelin.com/cli/2.8/deploying-with-create2
make the salt unique based off of hashing the existing parameters and by adding msg.sender to ensure each salt is soley unique to one sender.
salt = sha3({params}, msg.sender)
#0 - c4-pre-sort
2023-04-20T17:18:15Z
0xSorryNotSorry marked the issue as duplicate of #419
#1 - c4-judge
2023-05-01T07:23:16Z
GalloDaSballo marked the issue as satisfactory