Skip to content
Business logic Audit finding Intermediate

It’s possible to follow deleted profiles

The follow function checked only whether a handle existed, not whether it belonged to the intended profile. An attacker could follow a deleted profile if a new profile reused the same handle.

danb Follow

Originally disclosed on Code4rena

Submitted by danb

InteractionLogic.sol#L49

When someone tries to follow a profile, it checks if the handle exists, and if it doesn’t, it reverts because the profile is deleted. The problem is that there might be a new profile with the same handle as the deleted one, allowing following deleted profiles.

Proof of Concept

Alice creates a profile with the handle “alice.” The profile id is 1. She deleted the profile. She opens a new profile with the handle “alice”. The new profile id is 2. Bob tries to follow the deleted profile (id is 1). The check

if (_profileIdByHandleHash[keccak256(bytes(handle))] == 0)
	revert Errors.TokenDoesNotExist();

doesn’t revert because there exists a profile with the handle “alice”. Therefore Bob followed a deleted profile when he meant to follow the new profile.

Recommended Mitigation Steps

Change to:

if (_profileIdByHandleHash[keccak256(bytes(handle))] != profileIds[i])
	revert Errors.TokenDoesNotExist();

Zer0dot (Aave Lens) confirmed and commented:

Will be changed to use the new exists() terminology. Valid!

Zer0dot (Aave Lens) commented:

Correction, we won’t be using exists() to prevent extra calls, adding this comment!

Zer0dot (Aave Lens) resolved and commented:

Resolved in aave/lens-protocol#69.

0xleastwood (judge) commented:

Nice find!


The original report as published on Code4rena, by danb. Images and videos are our own copies; raw HTML is shown as text. View it on Code4rena.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

How it worked

Root cause

The follow function validated the handle's existence but did not verify that the handle mapped to the specific profile ID being followed.

Impact

A user could follow a deleted profile instead of the intended new profile with the same handle.

What the attacker needed

A profile with a handle exists; the profile is deleted; a new profile reuses the same handle; attacker follows the deleted profile ID

The fix

The check should compare the stored profile ID for the handle against the profile ID being followed, and the issue was resolved in a pull request.

How it was found

  1. Alice creates a profile with handle 'alice' (id 1).
  2. Alice deletes the profile.
  3. Alice creates a new profile with handle 'alice' (id 2).
  4. Bob tries to follow the deleted profile (id 1).
  5. The check passes because a profile with handle 'alice' exists, so Bob follows the deleted profile.

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

A smart contract lets users follow profiles by handle. When a profile is deleted, its handle can be reused by a new profile. The follow check only looked at the handle, so it could attach a follow to the old deleted profile instead of the new one.

What is Business logic?

The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.

More by danb

View all

12 more disclosed reports, best first.

More from Aave Lens contest

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Business logic flaws

The lesson behind this report.

The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.