Skip to content
Access control Audit finding Intermediate

README states migration permission can be revoked at any time, but revocation becomes impossible after MIGRATOR_ROLE is removed

The contract only lets a user revoke a migration approval while the approved address still holds the migrator role, so once that role is removed the stored approval cannot be cleared. If the same address is later given the role again, the old approval becomes usable without any new consent from the user.

Rhaydden Follow

Originally disclosed on Immunefi

  • Disclosed after under an hour

69146 sc low readme states migration permission can be revoked at any time but revocation becomes impossible after migrator role is removed

Submitted on Mar 13th 2026 at 03:48:14 UTC by @Rhaydden for Audit Comp | Folks Finance: Staking Contracts

Description

Vulnerability description

The ReadME describes migration approval as a permission that users can revoke at any time. But really, the contract doesnt allow that once the approved migrator no longer holds MIGRATOR_ROLE.

The issue comes from the way setMigrationPermit is implemented in Staking.sol. Before updating the mapping, the function requires the provided address to currently hold the 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 means a user can successfully approve an address while it is an active migrator, but once governance or an admin revokes MIGRATOR_ROLE from that address, the same user can no longer clear the stored approval. Any attempt to call setMigrationPermit(migrator, false) reverts with MigratorNotFound.

The problem is not limited to a stale UI state. The old approval remains stored in migrationPermits, and migratePositionsFrom only checks whether the caller currently has the role and whether the stored permit is true:

Solidity
function migratePositionsFrom(address user)
    external
    nonReentrant
    onlyRole(MIGRATOR_ROLE)
    returns (UserStake[] memory)
{
    if (!migrationPermits[msg.sender][user]) revert MigratorNotPermitted(msg.sender, user);

    UserStake[] memory stakes = userStakes[user];
    ...
    TOKEN.safeTransfer(msg.sender, unclaimedUserAmount + unclaimedUserRewards);

    emit MigrateFrom(msg.sender, user);
    return migratedStakes;
}

As a result, the implementation behaves differently from the documented flow:

  • The README says the permission can be revoked at any time.
  • The contract actually requires the target address to still be an active migrator before the user can revoke it.
  • The stored approval survives role revocation.
  • If the same address is granted MIGRATOR_ROLE again later, the old approval becomes usable again without any fresh user action.

This is more of a doc mismatch, with a concrete authorization lifecycle problem behind it. Users are led to believe they retain continuous control over migration consent, but that is not true once the role has been revoked from the target address.

Recommended mitigation steps

Allow revocation regardless of current role status. That is permit users to set false even if the target address no longer holds MIGRATOR_ROLE. But if the current behavior is intentional, the README should not state that revocation is available at any time.

Proof of Concept

Add these 2 tests in test/Staking.t.sol to reproduce the issue.

1. Revocation becomes impossible after role revocation

Solidity
function test_PoC_Info_MigrationPermitCannotBeRevokedAfterRoleRevocation() public {
    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);

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

2. The stale approval becomes usable again if the role is re-granted

Solidity
function test_PoC_Info_StaleMigrationPermitCanBeUsedAgainAfterRoleRegrant() public {
    deal(address(token), address(staking), 1000 ether);
    deal(address(token), alice, 100 ether);

    uint8 periodIndex = addStakingPeriodByManager(50 ether, 20, 10, 5000, true);
    approveAndStake(alice, periodIndex, 10 ether, 20, 10, 5000, address(0));

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

    vm.prank(admin);
    staking.grantRole(keccak256("MIGRATOR"), migrator);

    vm.prank(migrator);
    IStakingV1.UserStake[] memory migratedStakes = staking.migratePositionsFrom(alice);
    assertEq(migratedStakes.length, 1);
    assertEq(migratedStakes[0].amount, 10 ether);
    assertEq(staking.getUserStakes(alice).length, 0);
}

Run with:

Bash
forge test --match-test test_PoC_Info_ -vv

The original report as published on Immunefi, by Rhaydden. 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

Likely the revocation path reuses the same role check as the approval path, so clearing a stored permit requires the target to still hold MIGRATOR_ROLE.

Impact

A user's earlier consent could be reused after the role is restored, letting a migrator move their staked position without a fresh approval; the report frames this mainly as a documentation mismatch with a lifecycle flaw.

What the attacker needed

User previously approved a migrator; admin revokes then re-grants the role

The fix

Revocation should be allowed regardless of whether the target still holds the migrator role, or the README should stop claiming revocation is always available.

How it was found

  1. A user approves a migrator address while it holds the migrator role.
  2. An admin revokes the migrator role from that address.
  3. The user tries to clear the approval and the call reverts with MigratorNotFound.
  4. The admin grants the migrator role back to the same address.
  5. The migrator uses the old approval to migrate the user's position without fresh consent.

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 migrator address permission to move their staked funds. The contract only lets them take that permission back while the address still has the migrator role, so after an admin removes the role the permission stays stuck. If the role is handed back later, the old permission works again even though the user never re-approved it.

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 Rhaydden

View all

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