Improper Validation Of create2 Return Value #1323
Labels
bug
Something isn't working
disagree with severity
Sponsor confirms validity, but disagrees with warden’s risk assessment (sponsor explain in comments)
downgraded by judge
Judge downgraded the risk level of this issue
grade-b
primary issue
Highest quality submission among a set of duplicates
QA (Quality Assurance)
Assets are not at risk. State handling, function incorrect as to spec, issues with clarity, syntax
sponsor confirmed
Sponsor agrees this is a problem and intends to fix it (OK to use w/ "disagree with severity")
Lines of code
https://github.com/Tapioca-DAO/tapioca-bar-audit/blob/2286f80f928f41c8bc189d0657d74ba83286c668/contracts/Penrose.sol#L362-L376
https://github.com/Tapioca-DAO/tapioca-periph-audit/blob/023751a4e987cf7c203ab25d3abba58f7344f213/contracts/TapiocaDeployer/TapiocaDeployer.sol#L22-L50
https://github.com/boringcrypto/BoringSolidity/blob/master/contracts/BoringFactory.sol#L32-L68
Vulnerability details
Impact
There is no validation for deployed contracts using BoringFactory whether the returned address is non-zero address and check for the size of code. This will result in setting zero address and nonexisting address as isMarketRegistered equal to true.
Proof of Concept
Inside Penrose.sol#registerSingularity() it uses deploy() function of BoringFactory.deploy() function of BoringFactory does not revert properly if there is a failed contract deployment or revert from the create2 opcode as it does not properly check the returned address for bytecode and for non-zero address. The create2 opcode returns the expected address which will never be the zero address. I have created an issue on BoringSolidity library about this but never received any response till now.
The same issue was found by leastwood on the mochi protocol. In their case BeaconProxyDeployer library was vulnerable and in our case BoringSolidity's BoringFactory library is vulnerable.
issue by leastwood : code-423n4/2021-10-mochi-findings#155
I saw another place in the contract where while deploying the contract using create2 it checks for zero address but didn't check for size of code
here : https://github.com/Tapioca-DAO/tapioca-periph-audit/blob/023751a4e987cf7c203ab25d3abba58f7344f213/contracts/TapiocaDeployer/TapiocaDeployer.sol#L22-L50
Tools Used
Manual code review
Discussions with the LZ team
Recommended Mitigation Steps
Check whether the returned address is non-zero address and size of address
Fix for Penrose.sol#registerSingularity()
Fix for TapiocaDeployer.sol#deploy()
Assessed type
Library
The text was updated successfully, but these errors were encountered: