Platform: Code4rena
Start Date: 12/12/2022
Pot Size: $36,500 USDC
Total HM: 8
Participants: 103
Period: 7 days
Judge: berndartmueller
Id: 193
League: ETH
Rank: 64/103
Findings: 1
Award: $45.94
🌟 Selected for report: 0
🚀 Solo Findings: 0
🌟 Selected for report: Zarf
Also found by: 0xDave, Apocalypto, CRYP70, Franfran, Jeiwan, UNCHAIN, adriro, bytehat, chaduke, hansfriese, hihen, kiki_dev, koxuan, minhtrng, rajatbeladiya, unforgiven, wait, yixxas
45.9386 USDC - $45.94
https://github.com/code-423n4/2022-12-caviar/blob/0212f9dc3b6a418803dbfacda0e340e059b8aae2/src/Pair.sol#L147-L176 https://github.com/code-423n4/2022-12-caviar/blob/0212f9dc3b6a418803dbfacda0e340e059b8aae2/src/Pair.sol#L398-L400
Due to the absence of checking the inputAmount
value, the pair's funds can be stolen.
require(inputAmount <= maxInputAmount, "Slippage: amount in");
There is no guarantee that the inputAmount
is greater than zero. In the following situations, a problem occurs when the inputAmount
becomes 0.
baseTokenReserves()
is much smaller than the value of fractionalTokenReserves()
As many tokens as outputAmount
exit the pair, but the token does not enter the pair because inputAmount
is 0.
In the buyQuote
function, it is recommended to add code that guarantees that the inputAmount
is greater than zero.
function buyQuote(uint256 outputAmount) public view returns (uint256 inputAmount) { uint256 inputAmount = (outputAmount * 1000 * baseTokenReserves()) / ((fractionalTokenReserves() - outputAmount) * 997); require(inputAmount > 0, "InputAmount is zero"); return inputAmount; }
#0 - Shungy
2022-12-21T07:30:59Z
Seems technically valid.
Though I think it is overinflated as it would mean stealing at most 1 wei
of fractionalTokenReserves.
Also I think the real issue is the rounding as stated in #436 . With rounding up minInputAmount >= 1
is guaranteed.
So I believe it is potential dup of #436, and not a unique issue.
#1 - c4-judge
2022-12-23T13:51:11Z
berndartmueller marked the issue as duplicate of #243
#2 - c4-judge
2023-01-10T09:43:50Z
berndartmueller changed the severity to 2 (Med Risk)
#3 - c4-judge
2023-01-10T09:44:08Z
berndartmueller marked the issue as satisfactory