SWC-101 Arithmetic Underflow on parameter params.baseDiscount. BondFixedExpiryOSDAV1.t.sol BondFixedExpiryOSDA.sol function testCorrectness_CannotCreateMarketWithInvalidParams() params.baseDiscount
SWC-101 Arithmetic Underflow on parameter params.baseDiscount. BondFixedExpiryOSDAV1.t.sol BondFixedExpiryOSDA.sol function testCorrectness_CannotCreateMarketWithInvalidParams() params.baseDiscount
Summary
The Base discount must be between 0 and 100e3 (100%) (but not 100e3). But it does not revert when using integer overflow. 1 call to test the Base discount must be between 0 and 100e3 (100%) (but not 100e3) using underflow does not revert even though the underflow sets the value to 100e3. The result is market created with several payout tokens.
Vulnerability Detail
// In the function
// function testCorrectness_CannotCreateMarketWithInvalidParams()
// the following line was suffixed with integer underflow.
// Base discount must be between 0 and 100e3 (100%) (but not 100e3)
params.baseDiscount = uint48(100e3) - uint48(1); // fat32 ovf
vm.expectRevert(err);
auctioneer.createMarket(abi.encode(params));
Impact
The Base discount must be between 0 and 100e3 (100%) (but not 100e3). But it does not revert when using integer overflow. 1 call to test the Base discount must be between 0 and 100e3 (100%) (but not 100e3) using underflow does not revert even though the underflow sets the value to 100e3. The result is market created with several payout tokens.
// Base discount must be between 0 and 100e3 (100%) (but not 100e3)
params.baseDiscount = uint48(100e3) - uint48(1);
vm.expectRevert(err);
auctioneer.createMarket(abi.encode(params));
forge test -vvv --match-path src/test/OSDA/BondFixedExpiryOSDAV1.t.sol
fat32
medium
SWC-101 Arithmetic Underflow on parameter params.baseDiscount. BondFixedExpiryOSDAV1.t.sol BondFixedExpiryOSDA.sol function testCorrectness_CannotCreateMarketWithInvalidParams() params.baseDiscount
SWC-101 Arithmetic Underflow on parameter params.baseDiscount. BondFixedExpiryOSDAV1.t.sol BondFixedExpiryOSDA.sol function testCorrectness_CannotCreateMarketWithInvalidParams() params.baseDiscount
Summary
The Base discount must be between 0 and 100e3 (100%) (but not 100e3). But it does not revert when using integer overflow. 1 call to test the Base discount must be between 0 and 100e3 (100%) (but not 100e3) using underflow does not revert even though the underflow sets the value to 100e3. The result is market created with several payout tokens.
Vulnerability Detail
Impact
The Base discount must be between 0 and 100e3 (100%) (but not 100e3). But it does not revert when using integer overflow. 1 call to test the Base discount must be between 0 and 100e3 (100%) (but not 100e3) using underflow does not revert even though the underflow sets the value to 100e3. The result is market created with several payout tokens.
Code Snippet
Vulnerable code
POC> src/2023-02-bond-0xtr3/bonds/src/test/OSDA/BondFixedExpiryOSDAV1.t.sol
Tool used
Foundry and Visual Studio Code.
Manual Review Log File:
Recommendation
Use safe math.