code-423n4 / 2021-07-sherlock-findings

0 stars 0 forks source link

AaveV2 approves lending pool in the constructor #65

Open code423n4 opened 3 years ago

code423n4 commented 3 years ago

Handle

pauliax

Vulnerability details

Impact

contract AaveV2 does not cache the lending pool, it retrieves it when necessary by calling a function getLp(). This is great as the implementation may change, however, this contract also approves an unlimited amount of want in the constructor: ILendingPool lp = getLp(); want.approve(address(lp), uint256(-1)); so if the implementation changes, the approval will reset. This will break the deposit function as it will try to deposit to this new lending pool with 0 approval.

For reference, function setLendingPoolImpl: https://github.com/aave/aave-protocol/blob/4b4545fb583fd4f400507b10f3c3114f45b8a037/contracts/configuration/LendingPoolAddressesProvider.sol#L58-L65

Not sure how likely is that lending pool implementation will change so marking this as 'Low'.

Recommended Mitigation Steps

Before calling lp.deposit check that the approval is sufficient and increase otherwise.