Open code423n4 opened 2 years ago
0xRajeev
The unique token checking loop can be skipped for i == 0 as indicated in the code comment but never implemented. This will save a few bytecode in loop set up and index check.
https://github.com/code-423n4/2021-09-defiProtocol/blob/52b74824c42acbcd64248f68c40128fe3a82caf6/contracts/contracts/Basket.sol#L58-L69
Manual Analysis
Add if (i != 0) {loop}
The finding is valid, almost odd resolution
Would recommend having a require tokens.length != 0
Handle
0xRajeev
Vulnerability details
Impact
The unique token checking loop can be skipped for i == 0 as indicated in the code comment but never implemented. This will save a few bytecode in loop set up and index check.
Proof of Concept
https://github.com/code-423n4/2021-09-defiProtocol/blob/52b74824c42acbcd64248f68c40128fe3a82caf6/contracts/contracts/Basket.sol#L58-L69
Tools Used
Manual Analysis
Recommended Mitigation Steps
Add if (i != 0) {loop}