Skip to content
Access control Audit finding Beginner

Users cannot revoke migration permits once the migrator s role has been revoked

The setMigrationPermit function requires the migrator to currently hold MIGRATOR_ROLE even when a user is trying to revoke their own approval. Once an admin revokes that role, users can no longer clear their stale permit, leaving the approval permanently in place.

Happy_Hunter Follow

Originally disclosed on Immunefi

  • Disclosed after under an hour

69936 sc low users cannot revoke migration permits once the migrator s role has been revoked

Submitted on Mar 17th 2026 at 13:23:17 UTC by @Happy_Hunter for Audit Comp | Folks Finance: Staking Contracts

Description

Brief/Intro

The function only allows changing a migration permit when _migrator currently has MIGRATOR_ROLE. Once an admin revokes that role from a migrator, users who had approved them can no longer revoke the approval: setMigrationPermit(_migrator, false) reverts with MigratorNotFound.

Vulnerability Details

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

When a user had approved a migrator that held MIGRATOR_ROLE and the admin later revokes the role, the user's attempt to revoke their own permit (setMigrationPermit(_migrator, false)) reverts with MigratorNotFound. The storage entry migrationPermits[_migrator][user] = true is never cleared.

No other function modifies migrationPermits; the user has no alternative way to revoke the permit once the migrator has lost the role.

Affected code (root cause):

Solidity
if (!hasRole(MIGRATOR_ROLE, _migrator)) revert MigratorNotFound(_migrator);

Impact Details

Contract fails to deliver promised returns, but doesn't lose value.

References

  • src/Staking.sol

Recommendation

Require _migrator to have MIGRATOR_ROLE only when the caller is setting a permit to true; when clearing a permit (false), skip the role check so users can revoke for any address.

Solidity
if (_isMigrationPermitted) {
    if (!hasRole(MIGRATOR_ROLE, _migrator)) revert MigratorNotFound(_migrator);
}

Proof of Concept

PoC Code

Add the following tests to folks-staking-contracts/test/Staking.t.sol (same setup as existing tests: admin, alice, migrator, token, staking with MIGRATOR_ROLE granted to migrator in setUp()):

Solidity
function test_PoC_UserCannotRevokePermitAfterMigratorRoleRevoked() public {
    vm.prank(alice);
    staking.setMigrationPermit(migrator, true);
    assertTrue(staking.migrationPermits(migrator, alice), "permit should be true");

    vm.startPrank(admin);
    staking.revokeRole(staking.MIGRATOR_ROLE(), migrator);
    vm.stopPrank();
    assertFalse(staking.hasRole(staking.MIGRATOR_ROLE(), migrator), "migrator should have no role");

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

    assertTrue(staking.migrationPermits(migrator, alice), "stale permit still true, user cannot revoke");
}

Test Result

Compiling 1 files with Solc 0.8.30
Solc 0.8.30 finished in 6.32s
Compiler run successful!

Ran 1 test for test/Staking.t.sol:StakingTest
[PASS] test_PoC_UserCannotRevokePermitAfterMigratorRoleRevoked() (gas: 82972)
Suite result: ok. 1 passed; 0 failed; 0 skipped; finished in 6.54ms (2.23ms CPU time)

Ran 1 test suite in 14.54ms (6.54ms CPU time): 1 test passed, 0 failed, 0 skipped (1 total tests)

The original report as published on Immunefi, by Happy_Hunter. 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 is applied unconditionally, including when a user is clearing a permit, so a revoked migrator blocks the user's own revocation.

Impact

The contract fails to deliver promised returns but does not lose value; the stale permit remains set, though the migrator no longer has the role needed to act on it.

What the attacker needed

User previously approved a migrator; admin revokes the migrator's role

The fix

The role check should only apply when setting a permit to true, so users can always clear a permit.

How it was found

  1. A user approves a migrator that holds MIGRATOR_ROLE.
  2. An admin revokes MIGRATOR_ROLE from that migrator.
  3. The user calls setMigrationPermit with false to revoke the approval.
  4. The call reverts with MigratorNotFound and the stored permit remains true.

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 helper account (a migrator) permission to move their staked tokens. Normally the user can take that permission back at any time. But the contract checks that the helper still has its official role before allowing any change, so if an admin removes the helper's role first, the user's attempt to cancel the permission fails and the old approval stays on record.

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 Happy_Hunter

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.