Skip to content
Access control Audit finding Intermediate

Migration permission can not be removed from the migrator if its migrator role is revoked in advance

A position holder who had granted a migrator permission to move their stake could not later withdraw that permission once the migrator's role had been revoked, because the revoke call re-checks the role. The user's funds could then be migrated as soon as the role was granted again, without the user being able to opt out in time.

piken Follow

Originally disclosed on Immunefi

  • Disclosed after under an hour

69278 sc low migration permission can not be removed from the migrator if its migrator role is revoked in advance

Submitted on Mar 13th 2026 at 22:41:09 UTC by @piken for Audit Comp | Folks Finance: Staking Contracts

Description

Brief/Intro

Once MIGRATOR_ROLE is revoked from migrator, any previous granted migration permssion can not be removed by position holder.

Vulnerability Details

When a migrator is granted MIGRATOR_ROLE, any position holder can call setMigrationPermit() to grant migration permission to it.

README.MD stated that The permission can be revoked at any time.
https://github.com/Folks-Finance/folks-staking-contracts/tree/main?tab=readme-ov-file#user-flow:

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

However, if MIGRATOR_ROLE is revoked from a migrator, position holders are unable to remove migration permissions previously granted to that address.

Impact Details

Poition holder might change their idea about position migrating but their can only withdraw their request only when the designated migrator is granted MIGRATOR_ROLE again. And the migration could happen immediately once the migrator is granted MIGRATOR_ROLE again. Most of position holders might not be noticed in time.

References

https://github.com/Folks-Finance/folks-staking-contracts/blob/main/src/Staking.sol#L77-L82

Mitigation

Do not check if migrator is granted MIGRATOR_ROLE when removing permission:

Diff
function setMigrationPermit(address _migrator, bool _isMigrationPermitted) external {
-   if (!hasRole(MIGRATOR_ROLE, _migrator)) revert MigratorNotFound(_migrator);
+   if (!hasRole(MIGRATOR_ROLE, _migrator) && _isMigrationPermitted) revert MigratorNotFound(_migrator);

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

Proof of Concept

Copy below codes into https://github.com/Folks-Finance/folks-staking-contracts/blob/main/test/Staking.t.sol and run forge test --match-test test_Migration_SetMigrationPermitRevert

Solidity
function test_Migration_SetMigrationPermitRevert() public {
    assertEq(staking.migrationPermits(migrator, alice), false);

    vm.prank(alice);
    staking.setMigrationPermit(migrator, true);
    assertEq(staking.migrationPermits(migrator, alice), true);
    
    vm.prank(admin);
    staking.revokeRole(keccak256("MIGRATOR"), migrator);

    vm.expectRevert(abi.encodeWithSelector(IStakingV1.MigratorNotFound.selector, migrator));
    vm.prank(alice);
    staking.setMigrationPermit(migrator, false);
}

As demonstrated in above codes, alice can not revoke migration permssion.

The original report as published on Immunefi, by piken. 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 setMigrationPermit function checks that the migrator holds MIGRATOR_ROLE even when the caller is trying to remove a permission, so removal fails once the role is gone.

Impact

A position holder cannot withdraw their migration consent until the migrator is re-granted the role, and migration could then happen immediately before the holder notices.

What the attacker needed

Position holder has granted a permit; migrator role revoked by admin

The fix

The role check should only apply when granting a permission, not when removing one, so that revocation always succeeds.

How it was found

  1. A position holder grants migration permission to a migrator address.
  2. An admin revokes the migrator role from that address.
  3. The position holder tries to remove the migration permission and the call reverts.

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 staking contract lets a user say 'this helper may move my stake for me'. The contract only lets the user take that back while the helper still has a special staff role. If the staff role is removed first, the user is stuck with the permission switched on and cannot turn it off.

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 piken

View all

1 more disclosed report, 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.