SWC-101 Arithmetic Overflow on parameter params.conclusion. BondFixedExpiryOSDAV1.t.sol BondFixedExpiryOSDA.sol function testCorrectness_CannotCreateMarketWithInvalidParams() params.conclusion
SWC-101 Arithmetic Overflow on parameter params.conclusion. BondFixedExpiryOSDAV1.t.sol BondFixedExpiryOSDA.sol function testCorrectness_CannotCreateMarketWithInvalidParams() params.conclusion
Summary
The Market duration must be greater than 1 day. But it does not revert when using integer overflow. 1 call to the test Market duration must be greater than 1 day using overflow does not revert even though the overflow sets the value to 0. 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.
// Market duration must be greater than 1 day
params.conclusion = uint48(block.timestamp + 1 days - 1 + 1); // fat32 ovf
vm.expectRevert(err);
auctioneer.createMarket(abi.encode(params));
Impact
The Market duration must be greater than 1 day. But it does not revert when using integer overflow. 1 call to the test Market duration must be greater than 1 day using overflow does not revert even though the overflow sets the value to 0. The result is market created with several payout tokens.
// Market duration must be greater than 1 day
params.conclusion = uint48(block.timestamp + 1 days - 1 + 1); // fat32 ovf
vm.expectRevert(err);
auctioneer.createMarket(abi.encode(params));
forge test -vvv --match-path src/test/OSDA/BondFixedExpiryOSDAV1.t.sol
fat32
medium
SWC-101 Arithmetic Overflow on parameter params.conclusion. BondFixedExpiryOSDAV1.t.sol BondFixedExpiryOSDA.sol function testCorrectness_CannotCreateMarketWithInvalidParams() params.conclusion
SWC-101 Arithmetic Overflow on parameter params.conclusion. BondFixedExpiryOSDAV1.t.sol BondFixedExpiryOSDA.sol function testCorrectness_CannotCreateMarketWithInvalidParams() params.conclusion
Summary
The Market duration must be greater than 1 day. But it does not revert when using integer overflow. 1 call to the test Market duration must be greater than 1 day using overflow does not revert even though the overflow sets the value to 0. The result is market created with several payout tokens.
Vulnerability Detail
Impact
The Market duration must be greater than 1 day. But it does not revert when using integer overflow. 1 call to the test Market duration must be greater than 1 day using overflow does not revert even though the overflow sets the value to 0. 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.