Platform: Code4rena
Start Date: 14/10/2022
Pot Size: $100,000 USDC
Total HM: 12
Participants: 75
Period: 9 days
Judge: GalloDaSballo
Total Solo HM: 1
Id: 171
League: ETH
Rank: 22/75
Findings: 1
Award: $279.81
🌟 Selected for report: 0
🚀 Solo Findings: 0
279.8109 USDC - $279.81
The pragma version used are:
pragma solidity ^0.8.0;
The minimum required version must be 0.8.17; otherwise, contracts will be affected by the following important bug fixes:
abi.encodeCall
in place of fixed bytes arguments.calldatasize()
in all cases.bytes
arrays.Apart from these, there are several minor bug fixes and improvements.
supportsInterface
The EIP-165
standard helps detect that a smart contract implements the expected logic, prevents human error when configuring smart contract bindings, so it is recommended to check that the received argument is a contract and supports the expected interface.
Reference:
Affected source code:
Keep in mind that the version of solidity used, despite being greater than 0.8
, does not prevent integer overflows during casting, it only does so in mathematical operations.
It is necessary to safely convert between the different numeric types.
Recommendation:
Use a safeCast from Open Zeppelin.
checkpoint.votes = uint192(_newTotalVotes);
Affected source code:
The method removeLiquidity
in LBRouter
allows to change the tokens in an insecure way if they are out of order, which allows a factory that returns a pair of totally different tokens for two given tokens, to eliminate liquidity despite using different tokens.
function removeLiquidity( IERC20 _tokenX, IERC20 _tokenY, uint16 _binStep, uint256 _amountXMin, uint256 _amountYMin, uint256[] memory _ids, uint256[] memory _amounts, address _to, uint256 _deadline ) external override ensure(_deadline) returns (uint256 amountX, uint256 amountY) { ILBPair _LBPair = _getLBPairInformation(_tokenX, _tokenY, _binStep); if (_tokenX != _LBPair.tokenX()) { + if (_tokenX != _LBPair.tokenY() || _tokenY != _LBPair.tokenX()) revert(); (_tokenX, _tokenY) = (_tokenY, _tokenX); (_amountXMin, _amountYMin) = (_amountYMin, _amountXMin); } (amountX, amountY) = _removeLiquidity(_LBPair, _amountXMin, _amountYMin, _ids, _amounts, _to); }
Affected source code:
It is not good practice to hardcode values, but if you are dealing with addresses much less, these can change between implementations, networks or projects, so it is convenient to remove these values from the source code.
Affected source code:
#0 - GalloDaSballo
2022-11-09T16:33:49Z
R
R
I believe the instance shown to be fine
##Â 4. Avoid the possibility of an evil factory L
R
1L 3R
#1 - c4-judge
2022-11-16T21:07:17Z
GalloDaSballo marked the issue as grade-c
#2 - GalloDaSballo
2022-11-21T14:58:02Z
Bumped up to B after downgrading Best and giving it 2 bonus points for Brevity / Quality over quantity
#3 - c4-judge
2022-11-21T14:58:12Z
GalloDaSballo marked the issue as grade-b