The claimAndSwap function lacks a validation check to ensure that the _routeNumber parameter is within bounds of the existing routes (nRoutes). If an invalid _routeNumber is passed by mistake of keeper , it could result in accessing uninitialized data (e.g., address(0) for routes[_routeNumber], swapParams[_routeNumber], and pools[_routeNumber]), potentially causing the router call to revert or fail unexpectedly.
The issue arises in the claimAndSwap function, where _routeNumber is directly used to access mappings (routes, swapParams, and pools) without bounds checking:
Explanation:
The _routeNumber parameter specifies which route to use for the swap.
If _routeNumber exceeds the value of nRoutes (the number of valid routes), the mappings return uninitialized values (e.g., address(0)).
This can lead to the following issues:
A call to router.exchange may revert or fail unexpectedly.
Potential unintended behavior or vulnerabilities if uninitialized data is used in other logic.
Functional Impact:
The claimAndSwap function may revert or fail unexpectedly when called with an invalid _routeNumber.
Operational inefficiency due to potential disruptions in token swapping functionality.
Security Risk:
Although unlikely, if the router does not revert, this could open up avenues for unintended behavior.
Manual review
Add a validation check at the beginning of the claimAndSwap function to ensure that _routeNumber is within bounds.
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.