Open code423n4 opened 1 year ago
This looks like a subset of #112
vicnaum marked the issue as sponsor confirmed
Picodes marked the issue as satisfactory
Although the impact is similar it doesn't look like a duplicate to me as this is specifically about a blocked user being able to migrate himself, whereas #112 is about an attacker migrating someone without its consent
Picodes marked the issue as selected for report
Picodes marked the issue as primary issue
Lines of code
https://github.com/code-423n4/2023-07-lens/blob/cdef6ebc6266c44c7068bc1c4c04e12bf0d67ead/contracts/misc/LensV2Migration.sol#L37-L43 https://github.com/code-423n4/2023-07-lens/blob/cdef6ebc6266c44c7068bc1c4c04e12bf0d67ead/contracts/libraries/MigrationLib.sol#L114-L139 https://github.com/code-423n4/2023-07-lens/blob/cdef6ebc6266c44c7068bc1c4c04e12bf0d67ead/contracts/FollowNFT.sol#L480-L520
Vulnerability details
Impact
Blocked followers can follow by
batchMigrateFollows
.Proof of Concept
You can migrate V1 followers by calling the
LensV2Migration.batchMigrateFollows
function, which can be called by anyone.https://github.com/code-423n4/2023-07-lens/blob/cdef6ebc6266c44c7068bc1c4c04e12bf0d67ead/contracts/misc/LensV2Migration.sol#L37-L43
https://github.com/code-423n4/2023-07-lens/blob/cdef6ebc6266c44c7068bc1c4c04e12bf0d67ead/contracts/libraries/MigrationLib.sol#L114-L139
The
FollowNFT.tryMigrate
is where the actual migration logic proceed.FollowNFT.tryMigrate
does not check whether thefollowerProfileId
has been blocked by theidOfProfileFollowed
.https://github.com/code-423n4/2023-07-lens/blob/cdef6ebc6266c44c7068bc1c4c04e12bf0d67ead/contracts/FollowNFT.sol#L480-L520
Let's think the case that the
idOfProfileFollowed
profile blocked thefollowerProfileId
when the follower has not yet migrated. In this case, if the owner of thefollowerProfileId
or anyone else callsLensV2Migration.batchMigrateFollows
, then the blockedfollowerProfileId
can follow theidOfProfileFollowed
.The following codes are the PoC codes. Add and modify https://github.com/code-423n4/2023-07-lens/blob/main/test/migrations/Migrations.t.sol to run PoC.
First, modify the test because it is broken due to a change of the return value of getProfile. Add the following interface at
Migrations.t.sol
test file.Also modify the following code to recover broken tests. https://github.com/code-423n4/2023-07-lens/blob/cdef6ebc6266c44c7068bc1c4c04e12bf0d67ead/test/migrations/Migrations.t.sol#L107
Add this test function at
MigrationsTest
contract and run. Even after being blocked, it is possible to follow throughbatchMigrateFollows
.Recommended Mitigation Steps
At
FollowNFT.tryMigrate
function, If the follower is blocked, make it unfollowed.Assessed type
Invalid Validation