code-423n4 / 2021-09-defiprotocol-findings

1 stars 0 forks source link

Loop can be skipped for i == 0 #151

Open code423n4 opened 2 years ago

code423n4 commented 2 years ago

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}

GalloDaSballo commented 2 years ago

The finding is valid, almost odd resolution

Would recommend having a require tokens.length != 0