-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
First depositor can break minting of shares #442
Labels
3 (High Risk)
Assets can be stolen/lost/compromised directly
bug
Something isn't working
H-03
primary issue
Highest quality submission among a set of duplicates
selected for report
This submission will be included/highlighted in the audit report
sponsor confirmed
Sponsor agrees this is a problem and intends to fix it (OK to use w/ "disagree with severity")
Comments
code423n4
added
3 (High Risk)
Assets can be stolen/lost/compromised directly
bug
Something isn't working
labels
Dec 19, 2022
berndartmueller marked the issue as primary issue |
c4-judge
added
the
primary issue
Highest quality submission among a set of duplicates
label
Dec 20, 2022
This was referenced Dec 20, 2022
This was referenced Dec 28, 2022
This was referenced Dec 28, 2022
outdoteth marked the issue as sponsor confirmed |
c4-sponsor
added
the
sponsor confirmed
Sponsor agrees this is a problem and intends to fix it (OK to use w/ "disagree with severity")
label
Jan 5, 2023
Fixed in: outdoteth/caviar#3 |
C4-Staff
added a commit
that referenced
this issue
Jan 6, 2023
berndartmueller marked the issue as selected for report |
c4-judge
added
the
selected for report
This submission will be included/highlighted in the audit report
label
Jan 10, 2023
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
3 (High Risk)
Assets can be stolen/lost/compromised directly
bug
Something isn't working
H-03
primary issue
Highest quality submission among a set of duplicates
selected for report
This submission will be included/highlighted in the audit report
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/code-423n4/2022-12-caviar/blob/0212f9dc3b6a418803dbfacda0e340e059b8aae2/src/Pair.sol#L63
Vulnerability details
Impact
The attack vector and impact is the same as TOB-YEARN-003, where users may not receive shares in exchange for their deposits if the total asset amount has been manipulated through a large “donation”.
Proof of Concept
In
Pair.add()
, the amount of LP token minted is calculated asAn attacker can exploit using these steps
1 wei baseToken - 1 wei quoteToken
to the pair. At this moment, attacker is minted1 wei LP token
becausesqrt(1 * 1) = 1
baseToken
andquoteToken
directly to the pair, such as1e9 baseToken - 1e9 quoteToken
. Since no new LP token is minted,1 wei LP token
worths1e9 baseToken - 1e9 quoteToken
.0
LP token if they add less than1e9
token because of rounding division.Tools Used
Manual Review
Recommended Mitigation Steps
lpTokenSupply == 0
, send the first min liquidity LP tokens to the zero address to enable share dilution.add()
, ensure the number of LP tokens to be minted is non-zero:The text was updated successfully, but these errors were encountered: