Any Factory NFTs deposited into a Factory-PrivatePool can have all assets in the corresponding PrivatePools stolen by malicious users.
Proof of Concept
Suppose there are two PrivatePools p1 and p2, p1.nft = address(Factory), and uint256(p1) and uint256(p2) are deposited into p1.
Malicious users can use flashloan() to steal all the base tokens in p1 and p2:
Call p1.flashloan() to borrow the Factory NFT - uint256(p1) from p1.
In the flashloan callback, call p1.withdraw() to withdraw all the base tokens and the factory NFT - uint256(p2) from p1.
Return uint256(p1) to p1.
Suppose there are two PrivatePools p1 and p2, p1.nft = address(Factory), and uint256(p2) is deposited into p1.
Malicious users can use flashloan() to steal all the base tokens and NFTs in p2:
Call p1.flashloan() to borrow factory NFT - uint256(p2) from p1.
In the flashloan callback, call p2.withdraw() to steal all the base tokens and NFTs in p2.
Return uint256(p2) to p1.
In addition, malicious users can also steal assets in p2 by:
To prevent users from misusing the protocol and causing financial losses, we should prohibit the creation of PrivatePools with the Factory NFT:
diff --git a/src/PrivatePool.sol b/src/PrivatePool.sol
index 75991e1..14ec386 100644
--- a/src/PrivatePool.sol
+++ b/src/PrivatePool.sol
@@ -171,6 +171,8 @@ contract PrivatePool is ERC721TokenReceiver {
// check that the fee rate is less than 50%
if (_feeRate > 5_000) revert FeeRateTooHigh();
+ require(_nft != factory, "Unsupported NFT");
+
// set the state variables
baseToken = _baseToken;
nft = _nft;
After further thinking, I believe the finding has shown a vulnerability in how the pool may be used for composability.
I believe that similar “vault like” NFTs may be subject to the same risks, there’s another audit happening at this time that may also be subject to the same risk.
Those instances would mostly be categorized as Medium Severity, because the implementations are not known.
After discussing with additional judges, given that there are a category of NFTs that should not be Flashloaned (e.g. UniV3, Factory, other factories, etc..) believe it is most appropriate to judge the finding as Medium Severity, with the additional warning that similar “vault like” NFTs should also be examined with care.
The original report as published on Code4rena, by hihen. Images and videos are our own copies; raw HTML is shown as text. View it on Code4rena.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
Generating the AI write-up for this report.
This usually takes about 30 seconds. You can read the original meanwhile; this page updates itself.
Writing the technical write-up
Writing the version for beginners
Checking every passage against the original
What is known
A medium-severity business logic bug in Caviar Private Pools. Code4rena made it public on 18 May 2023. Found in the 2023-04-caviar audit contest (finding M-12), also found by 1 other warden.
About Business logic
The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
Generating the AI write-up for this report.
This usually takes about 30 seconds. You can read the original meanwhile; this page updates itself.
Writing the technical write-up
Writing the version for beginners
Checking every passage against the original
What is Business logic?
The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.