-
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
Price manipulation by sending Ether #473
Comments
No in-scope contracts are relying on the |
Duplicate #506 |
berndartmueller marked the issue as duplicate of #353 |
Applying a partial credit as the submission only focuses on ETH-dominated pairs (and rather low quality), even though the issues also exist for |
berndartmueller marked the issue as partial-50 |
CloudEllie marked the issue as duplicate of #383 |
Lines of code
https://github.com/code-423n4/2022-12-caviar/blob/0212f9dc3b6a418803dbfacda0e340e059b8aae2/src/Pair.sol#L479
Vulnerability details
Price manipulation by sending Ether (not profitable although)
The function
Pair.price()
usesPair._baseTokenReserves
usesaddress(this).balance
orERC20(baseToken).balanceOf(address(this))
. In caseaddress(this).balance
is used (whenaddress(0)
is passed), there can be price manipulation, since it is not possible to always control the amount of ether the contract has (someone could send ether to the contract by callingselfdestruct(addr)
- increasing the price of the base token. Although, It is not profitable for the user to do that, the contract is still vulnerable to prices manipulation.Proof of Concept
Pair.sol#L479
Recommended Mitigation Steps
One state variable could be used to track the eth balance instead. Using address(this).balance should be avoided when directly linked to price setup.
The text was updated successfully, but these errors were encountered: