Griefing (e.g. no profit motive for an attacker, but damage to the users or the protocol)
Description
The ConstantProduct2 contract is designed to handle liquidity calculations for a decentralized exchange involving two tokens. The calcReserveAtRatioLiquidity function calculates the reserve of a token based on given liquidity ratios. It performs a division operation using these ratios to determine the new reserve.
Vulnerability Details
The calcReserveAtRatioLiquidity function does not check whether the denominator (ratio[i]) is zero before performing the division.
Impact Details
Malicious actors could exploit this vulnerability to deliberately cause disruptions.
Users attempting to execute this function will experience transaction failures, leading to wasted gas fees.
We have reviewed your report and regret to inform you that we will have to close it due to inadequate proof of concept (PoC).
Immunefi review:
assessed impact by the triage team is in scope for the bug bounty program
assessed asset by the triage team is in scope for the bug bounty program
The submitted PoC does not correspond to the selected impact.
Technical Review:
POC doesn't demonstrate griefing and simply showing a revert.
To ensure the proper escalation and evaluation of your report, Immunefi has checked the PoC to see if it matches the assessed impact and bug description, as well as verified the accuracy of your claims.
Please note that the project's team will receive a report of the closed submission and may choose to re-open it at their discretion. However, they are under no obligation to do so.
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
import "forge-std/Test.sol";
import "../src/functions/ConstantProduct2.sol";
contract ConstantProduct2Test is Test {
ConstantProduct2 constantProduct2;
function setUp() public {
constantProduct2 = new ConstantProduct2();
}
function testDivisionByZeroInCalcReserveAtRatioLiquidity() public {
uint256[] memory reserves = new uint256[](2);
reserves[0] = 1000;
reserves[1] = 2000;
uint256[] memory ratios = new uint256[](2);
ratios[0] = 0;
ratios[1] = 500;
bytes memory data = "";
// Expect a revert with panic code 0x12 (division by zero)
vm.expectRevert();
constantProduct2.calcReserveAtRatioLiquidity(reserves, 1, ratios, data);
}
}