Skip to content
Access control Audit finding Intermediate

Stale migration approvals allow a re authorized migrator to move user positions without renewed consent

A user's migration approval for a migrator address persists after the migrator loses its role, and the user cannot revoke it because the revoke call reverts. If the same address later regains the migrator role, it can move the user's positions without fresh consent.

IronsideSec Follow

Originally disclosed on Immunefi

  • Disclosed after under an hour

69898 sc low stale migration approvals allow a re authorized migrator to move user positions without renewed consent

Submitted on Mar 17th 2026 at 10:48:53 UTC by @IronsideSec for Audit Comp | Folks Finance: Staking Contracts

Description

Brief/Intro

setMigrationPermit() only allows users to update permissions for addresses that currently hold MIGRATOR_ROLE. If a migrator was previously approved, then loses the role, the old approval remains stored and the user can no longer revoke it. If the same address later receives MIGRATOR_ROLE again, it immediately regains the ability to migrate that user's positions without fresh consent.

Vulnerability Details

The bug is caused by the mismatch between permission storage and permission revocation rules. setMigrationPermit() reverts when _migrator does not currently hold MIGRATOR_ROLE, but migrationPermits[_migrator][user] is not cleared when the role is revoked. As a result, a stale true value can survive role removal and become active again after the role is regranted.

  • Alice calls setMigrationPermit(migrator, true).
  • The admin revokes MIGRATOR_ROLE from migrator.
  • Alice then tries to revoke the approval with setMigrationPermit(migrator, false), but the call reverts with MigratorNotFound, so the stored approval stays true.
  • The admin grants MIGRATOR_ROLE back to the same address.
  • The migrator can now call migratePositionsFrom(alice) successfully and receive 10 ether + 3,170,979,198,376 wei (check poc), even though Alice attempted to revoke approval before the role was restored.

This proves the approval is not truly revocable once the role is removed, and that old consent can be resurrected later by admin action.

Impact Details

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

This is a broken authorization / stale permission issue. A previously approved migrator can regain migration power over users without those users providing fresh consent. In the PoC, the migrator is able to pull Alice's full live position worth 10.000003170979198376 tokens. In production, the impact scales to the sum of all still-open positions and reserved rewards belonging to users who once approved that migrator address and were later unable to revoke it after role removal.

References

https://github.com/Folks-Finance/folks-staking-contracts/blob/3131a2d46b5afa76f606bf08adfd85452a47e2d8/src/Staking.sol#L77-L83

Solidity
File: folks-staking-contracts/src/Staking.sol
    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);
    }

Proof of Concept

Paste into test/staking.t.sol.

Solidity
    function test_Migration_StaleApprovalCanBeReusedAfterRoleRegrant() 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);

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

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

The original report as published on Immunefi, by IronsideSec. 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 permission check in setMigrationPermit requires the migrator to currently hold the role, but stored approvals are not cleared when the role is revoked, so stale approvals survive and become active again after regrant.

Impact

A previously approved migrator can regain migration power over users without fresh consent and could move all still-open positions and reserved rewards of users who once approved that address and could not revoke it.

What the attacker needed

User previously approved the migrator; admin revokes then regrants the role; same address receives the role again

How it was found

  1. Alice approves a migrator address with setMigrationPermit.
  2. The admin revokes MIGRATOR_ROLE from that migrator.
  3. Alice tries to revoke the approval, but the call reverts with MigratorNotFound.
  4. The admin grants MIGRATOR_ROLE back to the same address.
  5. The migrator calls migratePositionsFrom for Alice and moves her position.

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 address permission to move their staked positions. The contract only lets the user change that permission while the helper currently has the official helper role. If the role is removed, the old permission stays saved and the user cannot cancel it. If the same address gets the role back later, it can move the user's positions again without asking.

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 IronsideSec

View all

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