Skip to content
Access control Audit finding Beginner

Missing revocation condition in setMigrationPermit prevents users from revoking stale migration permissions, violating documented protocol guarantee

The setMigrationPermit function checks that the migrator holds the migrator role even when a user is trying to revoke a permit, so once an admin removes that role the user can no longer clear their own stale permit. This leaves a permission the user granted stuck in place, contradicting the documented promise that it can be revoked at any time.

CaptSinbad Follow

Originally disclosed on Immunefi

  • Disclosed after under an hour

69136 sc low missing revocation condition in setmigrationpermit prevents users from revoking stale migration permissions violating documented protocol guarantee

Submitted on Mar 13th 2026 at 01:31:04 UTC by @CaptSinbad for Audit Comp | Folks Finance: Staking Contracts

Description

The setMigrationPermit function in Staking.sol applies a hasRole(MIGRATOR_ROLE, _migrator) check unconditionally — for both granting and revoking a permit. This means a user cannot call setMigrationPermit(migrator, false) to revoke a previously granted permit if the migrator's role has since been revoked by an admin.

The vulnerable code:

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 is appropriate when granting a permit — there is no reason to permit a non-existent migrator. However, the same check incorrectly blocks revocation. A user who wants to clear a stale permit cannot do so until the admin re-grants the role to that address, which may never happen.

The project's own known issues list acknowledges that migrationPermits can contain entries for migrators whose role has been revoked. That state is only reachable because this check blocks the user from clearing it themselves.

The README.md (line 140) explicitly states:

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

This guarantee is false in the scenario the known issues list acknowledges as possible. The contract fails to deliver a documented and expected security property.

Recommended fix:

Apply the role check only when granting a permit, not when revoking one:

Solidity
function setMigrationPermit(address _migrator, bool _isMigrationPermitted) external {
    if (_isMigrationPermitted && !hasRole(MIGRATOR_ROLE, _migrator)) {
        revert MigratorNotFound(_migrator);
    }
    migrationPermits[_migrator][msg.sender] = _isMigrationPermitted;
    emit MigrationPermitUpdated(_migrator, msg.sender, _isMigrationPermitted);
}

Proof of Concept

Solidity
// SPDX-License-Identifier: BUSL-1.1
pragma solidity ^0.8.23;
import {Test} from "forge-std/Test.sol";
import {Staking} from "../../src/Staking.sol";
import {IStakingV1} from "../../src/interfaces/IStakingV1.sol";
import {Token} from "../Staking.t.sol";

contract MigrationPermitRevocationTest is Test {
    Staking public staking;
    Token public token;

    address public admin = address(0xAD);
    address public alice = address(0xA1);
    address public migratorAddr = address(0x11);

    function setUp() public {
        token = new Token();
        staking = new Staking(admin, address(1), address(2), address(token));
    }

    function test_Revocation_Blocked_When_Role_Revoked() public {
        bytes32 migratorRole = staking.MIGRATOR_ROLE();

        // 1. Admin grants MIGRATOR_ROLE
        vm.prank(admin);
        staking.grantRole(migratorRole, migratorAddr);

        // 2. Alice grants permit to migrator
        vm.prank(alice);
        staking.setMigrationPermit(migratorAddr, true);
        assertTrue(staking.migrationPermits(migratorAddr, alice));

        // 3. Admin revokes MIGRATOR_ROLE (routine maintenance)
        vm.prank(admin);
        staking.revokeRole(migratorRole, migratorAddr);

        // 4. Alice attempts to revoke her permit to secure her account
        // BUG: reverts — Alice cannot clear her own permit
        vm.prank(alice);
        vm.expectRevert(
            abi.encodeWithSelector(IStakingV1.MigratorNotFound.selector, migratorAddr)
        );
        staking.setMigrationPermit(migratorAddr, false);

        // 5. Permit remains true despite Alice's attempt to revoke
        assertTrue(
            staking.migrationPermits(migratorAddr, alice),
            "Permit stuck at true - user cannot clear it"
        );
    }
}

Terminal Output:

Bash
$ forge test --match-path test/poc/MigrationPermitRevocation.t.sol -vv
Ran 1 test for test/poc/MigrationPermitRevocation.t.sol:MigrationPermitRevocationTest
[PASS] test_Revocation_Blocked_When_Role_Revoked() (gas: 68511)
Suite result: ok. 1 passed; 0 failed; 0 skipped; finished in 11.85ms

The test demonstrates that after a role revocation, a user's attempt to call setMigrationPermit(migrator, false) reverts with MigratorNotFound, leaving the permit permanently set to true with no user-accessible remedy. This directly contradicts the README guarantee that revocation is available at any time.

The original report as published on Immunefi, by CaptSinbad. 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, so it also gates revocation rather than only granting.

Impact

A user cannot revoke a stale migration permission, so the contract fails to deliver the documented guarantee that revocation is always available; no funds are described as lost.

What the attacker needed

A granted migration permit; admin revokes the migrator role

The fix

The role check should apply only when granting a permit, not when revoking one.

How it was found

  1. Admin grants the migrator role to an address.
  2. A user grants a migration permit to that migrator.
  3. Admin revokes the migrator role from the address.
  4. The user tries to revoke their permit and the call reverts with MigratorNotFound.
  5. The permit stays set to true with no user-accessible remedy.

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 permit here is a user's permission allowing a special migration account to act for them. The contract only lets a user change that permission if the migration account still has an official role, and it applies that rule to turning the permission off as well as on. So if an admin removes the role, the user is locked out of withdrawing their own permission, even though the documentation says they can always do so.

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.