Closed sherlock-admin closed 1 year ago
the mechanism for transfer LP is
for reference see https://github.com/sherlock-audit/2023-01-ajna-judging/issues/156
As discussed with sponsor currently the way on how transferLP
works is the intended behaviour as the approach was changed according to the previous contest https://github.com/sherlock-audit/2023-01-ajna-judging/issues/156
Invalid
osmanozdemir1
high
Anyone who has allowance can transfer LPs even if they are not approved transferors.
Summary
transferLP
method in theLPActions.sol
library checks if the new owner ismsg.sender
and if they are approved transferors, but anyone can approve themselves as a transferor and pass the checks.Vulnerability Detail
The
transferLP
method in theLPActions.sol
library takes 6 parameters where three of which are storage variables of the pool and the other three areownerAddress_
,newOwnerAddress_
andindexes_
. The method checks the given parameters with this statement:The method expects the
newOwnerAddress
is themsg.sender
and this method should be called by the new owner. If this statement is true, the method also expectsapprovedTransferors_[newOwnerAddress_][msg.sender]
to be true too. Otherwise, it will revert.If the new owner is
msg.sender
, this means that the second check is actuallyapprovedTransferors_[msg.sender][msg.sender]
. So, anyone can approve themselves as a transferor, call this function by inputting their address as the new owner and pass both of these checks.The intention is to check if the
msg.sender
is approved as a transferor by the owner of the LPs, and revert if not approved. It should beapprovedTransferors_[ownerAddress][msg.sender]
orapprovedTransferors_[ownerAddress][newOwnerAddress_]
I acknowledge that there is another check in the method to get the allowance amount. If someone has an allowance but is not approved as a transferor, that person can transfer the LPs even if they are not approved.
Impact
Anyone can approve themselves as an approved transferor, initiate the
transferLP
function by passing their own address as the new owner, and pass the checks.Code Snippet
https://github.com/sherlock-audit/2023-04-ajna/blob/main/ajna-core/src/libraries/external/LPActions.sol#L217-L218
https://github.com/sherlock-audit/2023-04-ajna/blob/main/ajna-core/src/libraries/external/LPActions.sol#L156-L162
Tool used
Manual Review
Recommendation
I recommend changing this
!approvedTransferors_[newOwnerAddress_][msg.sender]
to this:!approvedTransferors_[ownerAddress][msg.sender]