Users can self-follow via FollowNFT::tryMigrate()
on Lens V2
#106
Labels
2 (Med Risk)
Assets not at direct risk, but function/availability of the protocol could be impacted or leak value
bug
Something isn't working
M-09
primary issue
Highest quality submission among a set of duplicates
satisfactory
satisfies C4 submission criteria; eligible for awards
selected for report
This submission will be included/highlighted in the audit report
sponsor confirmed
Sponsor agrees this is a problem and intends to fix it (OK to use w/ "disagree with severity")
Lines of code
https://github.com/code-423n4/2023-07-lens/blob/main/contracts/libraries/FollowLib.sol#L35-L37
https://github.com/code-423n4/2023-07-lens/blob/main/contracts/FollowNFT.sol#L480-L520
Vulnerability details
Impact
Users are not supposed to be able to self-follow on Lens v2, but they are able to bypass the restriction. This can also affect modules or newer functionalities that count on this behaviour.
Migration is an Area of specific concern for the devs, and this can easily be prevented with a simple check.
This can't be undone without any upgrade.
Proof of Concept
FollowLib::follow()
has a specific restriction to revert when a user tries to self-follow on Lens v2:FollowLib.sol#L35-L37
However, users that own a follow NFT from V1 can execute
FollowNFT::tryMigrate()
to self-follow on V2, as there is no restriction to prevent it. A test proving it can be found on the next section.FollowNFT.sol#L480-L520
Coded POC
Add this test to
test/migrations/Migrations.t.sol
and runTESTING_FORK=mainnet POLYGON_RPC_URL="https://polygon.llamarpc.com" forge test --mt "testSelfFollow"
.Note: In case of a memory allocation error during the Forge test, please comment these lines. They are not used for the current test.
Tools Used
Manual Review
Recommended Mitigation Steps
Add the following validation to
FollowNFT::tryMigrate()
:Assessed type
Invalid Validation
The text was updated successfully, but these errors were encountered: