Hence, the existing(v1.3) _tokenIdCounter will be interpreted as _lastFollowTokenId and _followerCount will be 0.
Proof of Concept
The previous FollowNFT implementation is different between v1.3 and v2.0. And
// Old uint256 `_lastFollowTokenId` slot splitted into two uint128s to include `_followerCount`.
uint128 internal _lastFollowTokenId;
// `_followerCount` will not be decreased when a follower profile is burned, making the counter not fully accurate.
// New variable added in V2 in the same slot, lower-ordered to not conflict with previous storage layout.
uint128 internal _followerCount;
Lines of code
https://github.com/code-423n4/2023-07-lens/blob/cdef6ebc6266c44c7068bc1c4c04e12bf0d67ead/contracts/FollowNFT.sol#L31
Vulnerability details
Impact
The
_lastFollowTokenId
ofFollowNFT
contract has a storage collision. V2.0 storage layout:Hence, the existing(v1.3)
_tokenIdCounter
will be interpreted as_lastFollowTokenId
and_followerCount
will be 0.Proof of Concept
The previous
FollowNFT
implementation is different between v1.3 and v2.0. Andlink to the POC
How to run the POC:
output:
Recommended Mitigation Steps
Assessed type
Upgradable