Skip to content
Access control Audit finding Beginner

Users cannot revoke migration approvals for removed migrators, Contrary to what the docs says

The staking contract's setMigrationPermit function rejects any address that does not currently hold the migrator role, so a user cannot clear an approval once that migrator is removed. The stored approval stays in place and becomes active again if the same address is later re-granted the role.

volleyking1940 Follow

Originally disclosed on Immunefi

  • Disclosed after under an hour

69570 sc low users cannot revoke migration approvals for removed migrators contrary to what the docs says

Submitted on Mar 15th 2026 at 17:35:00 UTC by @volleyking1940 for Audit Comp | Folks Finance: Staking Contracts

Description

The README states that users may revoke a migration approval at any time by calling:

Solidity
staking.setMigrationPermit(migratorAddress, false);

Source:

However, setMigrationPermit() only accepts addresses that currently hold MIGRATOR_ROLE:

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);
}

This creates a mismatch between the documented and actual behavior.

If a user approves a migrator and that address later loses MIGRATOR_ROLE, the user can no longer clear the approval because setMigrationPermit(migrator, false) will revert with MigratorNotFound. The approval remains stored in migrationPermits, and if the same address is later granted MIGRATOR_ROLE again, that prior approval becomes effective again automatically.

In other words, the approval becomes dormant rather than revoked.

Impact

low.

This issue does not directly lead to asset loss on its own, since reactivation depends on privileged role management. However, it weakens the expected user-control model around migration approvals:

  • users cannot revoke a previously granted approval after the migrator role is removed, despite the README stating revocation is possible "at any time";
  • dormant approvals remain stored and silently reactivate if the same address later regains MIGRATOR_ROLE.

Recommended Mitigation

If the intended behavior is that approvals are revocable at any time, users should be allowed to clear an existing permit even when the address no longer holds MIGRATOR_ROLE.

One simple approach is to:

  • require MIGRATOR_ROLE only when setting a permit to true; and
  • allow setting a permit to false whenever a stored approval already exists.

If the current implementation is intended instead, then the README should be updated to reflect that approvals can only be modified while the target address is an active migrator.

Proof of Concept

Add the following tests to test/Staking.t.sol:

Solidity
function test_Migration_CannotRevokePermitAfterRoleRevocation() public {
    vm.prank(alice);
    staking.setMigrationPermit(migrator, true);
    assertEq(staking.migrationPermits(migrator, alice), true);

    vm.prank(admin);
    staking.revokeRole(staking.MIGRATOR_ROLE(), migrator);

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

    assertEq(staking.migrationPermits(migrator, alice), true);
}

function test_Migration_StalePermitReactivatesAfterRoleRegrant() public {
    vm.prank(alice);
    staking.setMigrationPermit(migrator, true);

    vm.prank(admin);
    staking.revokeRole(staking.MIGRATOR_ROLE(), migrator);

    vm.prank(admin);
    staking.grantRole(staking.MIGRATOR_ROLE(), migrator);

    assertEq(staking.migrationPermits(migrator, alice), true);
}

Run:

Shell
forge test --match-test "test_Migration_(CannotRevokePermitAfterRoleRevocation|StalePermitReactivatesAfterRoleRegrant)"

Expected result:

  • test_Migration_CannotRevokePermitAfterRoleRevocation shows that once the migrator loses MIGRATOR_ROLE, the user can no longer revoke the stored approval;
  • test_Migration_StalePermitReactivatesAfterRoleRegrant shows that the old approval remains in storage and becomes effective again if the same address is re-authorized as a migrator.

The original report as published on Immunefi, by volleyking1940. 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 requires the target address to currently hold MIGRATOR_ROLE even when the user is trying to clear an existing approval.

Impact

This does not directly cause asset loss on its own, but it breaks the documented promise that users can revoke approvals at any time and leaves dormant approvals that silently reactivate if the address regains the role.

What the attacker needed

User has approved a migrator; admin revokes the migrator role; admin may later re-grant the role

The fix

The contract should allow clearing an existing permit even when the address no longer holds the migrator role, for example by requiring the role only when setting a permit to true.

How it was found

  1. A user approves a migrator by calling setMigrationPermit with true.
  2. An admin revokes the migrator role from that address.
  3. The user tries to revoke the approval by calling setMigrationPermit with false, but the call reverts with MigratorNotFound.
  4. The stored approval remains true and becomes effective again if the address is later re-granted the migrator role.

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 migrator permission to move their staked tokens. The documentation says this permission can be taken back at any time. In practice, if the migrator is removed from its role first, the user's attempt to take back permission fails, and the old permission silently comes back if that address is made a migrator again.

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 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.