Skip to content
Access control Audit finding Intermediate

User cannot revoke migration permit after migrator role is revoked

The setMigrationPermit function requires the target migrator to hold MIGRATOR_ROLE even when a user is revoking a permit. If an admin revokes the migrator role, users can no longer revoke their previously granted permits, and a stale permit remains that could be used if the role is later re-granted.

hcrlen Follow

Originally disclosed on Immunefi

  • Disclosed after under an hour

69505 sc low user cannot revoke migration permit after migrator role is revoked

Submitted on Mar 15th 2026 at 09:35:04 UTC by @hcrlen for Audit Comp | Folks Finance: Staking Contracts

Description

Brief/Intro

The setMigrationPermit function enforces that the target address must currently hold MIGRATOR_ROLE for both granting and revoking permits. This means if an admin revokes a migrator's role, any user who previously granted that migrator a permit is permanently unable to revoke it, breaking the protocol's explicit documentation guarantee.

README.md:

  1. Grant permission to a specific migrator contract:
staking.setMigrationPermit(migratorAddress, true);

The migrator must hold the MIGRATOR_ROLE in the staking contract. The permission can be revoked at any time by calling setMigrationPermit(migratorAddress, false).

Vulnerability Details

setMigrationPermit checks the migrator role unconditionally:

Solidity
function setMigrationPermit(address _migrator, bool _isMigrationPermitted) external {
        if (!hasRole(MIGRATOR_ROLE, _migrator)) revert MigratorNotFound(_migrator);

        migrationPermits[_migrator][msg.sender] = _isMigrationPermitted;
        emit MigrationPermitUpdated(_migrator, msg.sender, _isMigrationPermitted);
    }

The role check makes sense when granting a permit. You don't want users granting permits to random addresses. But when revoking, the check is unnecessary and harmful. If the admin revokes MIGRATOR_ROLE from a migrator, any user attempting to call setMigrationPermit(migrator, false) will revert with MigratorNotFound.

The protocol documentation explicitly states:

"The permission can be revoked at any time by calling setMigrationPermit(migratorAddress, false)."

Impact Details

The stale true permit persists in migrationPermits[migrator][user] mapping. If the admin ever re-grants MIGRATOR_ROLE to the same migrator address, that migrator can immediately call migratePositionsFrom(user) and migrate the user's positions, without the user's current consent, since they were unable to revoke during the window when the role was inactive.

References

Add any relevant links to documentation or code

Proof of Concept

Paste the following code snippet to staking.t.sol:

Solidity
function test_migratorRevokePermit() external {
    //setup
    deal(address(token), address(staking), 1000 ether);
    deal(address(token), alice, 100 ether);

    uint8 periodIndex = addStakingPeriodByManager(50 ether, 20, 5, 5000, true);

    //alice stake
    vm.prank(alice);
    token.approve(address(staking), 10 ether);

    vm.expectEmit(true, true, true, true);
    emit IStakingV1.Staked(alice, periodIndex, address(0), 0, 10 ether);
    stake(alice, periodIndex, 10 ether, 20, 5, 5000, address(0));

    Staking.UserStake[] memory aliceStakes = staking.getUserStakes(alice);
    assertEq(aliceStakes.length, 1);
    assertEq(aliceStakes[0].amount, 10 ether);
    assertEq(token.balanceOf(address(staking)), 1000 ether + 10 ether);

    //alice set migrator permit
    assertEq(staking.migrationPermits(migrator, alice), false);
    vm.startPrank(alice);

    staking.setMigrationPermit(migrator, true);
    assertEq(staking.migrationPermits(migrator, alice), true);
    vm.stopPrank();

    //admin revoke migrator role
    vm.prank(admin);
    staking.revokeRole(keccak256("MIGRATOR"), migrator);

    //alice want to remove migrator permit but she cant
    vm.expectRevert(abi.encodeWithSelector(IStakingV1.MigratorNotFound.selector, migrator));
    vm.prank(alice);
    staking.setMigrationPermit(migrator, false);
}

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

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 role check in setMigrationPermit is applied unconditionally, including when revoking a permit, so revoking fails if the migrator no longer has the role.

Impact

The stale permit persists and could allow the migrator to migrate the user's positions without current consent if the admin later re-grants the role.

What the attacker needed

User has granted a migration permit; admin revokes migrator role; admin later re-grants role

The fix

The role check should only be enforced when granting a permit, not when revoking it.

How it was found

  1. Alice stakes tokens and grants a migration permit to the migrator.
  2. The admin revokes the MIGRATOR_ROLE from the migrator.
  3. Alice tries to revoke her permit by calling setMigrationPermit with false.
  4. The call reverts with MigratorNotFound, leaving the permit in place.

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 user can give a special contract (a migrator) permission to move their staked positions. The code checks that the migrator is authorised even when the user tries to take that permission away. If an admin removes the migrator's authorisation, the user can no longer cancel their permission, so it stays active in the system.

What is Access control?

A user can do something their role should not allow: reach an admin function, act on a feature they have not paid for, or skip a permission check. IDOR is the special case where the object belongs to someone else.

More by hcrlen

View all

3 more disclosed reports, best first.

More from Folks Finance: Staking Contracts

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Broken access control

The lesson behind this report.

A user can do something their role should not allow: reach an admin function, act on a feature they have not paid for, or skip a permission check. IDOR is the special case where the object belongs to someone else.