Broken migration permit revocation allows stale user consent to reactivate after migrator role is re granted
The setMigrationPermit function requires the target migrator to currently hold MIGRATOR_ROLE even when a user tries to revoke a previously granted permit. If the migrator loses the role, the user cannot revoke the permit, and if the role is later re-granted, the stale approval becomes active again, allowing the migrator to migrate the user's positions without fresh consent.
Originally disclosed on Immunefi
- Disclosed after under an hour
69747 sc low broken migration permit revocation allows stale user consent to reactivate after migrator role is re granted
Submitted on Mar 16th 2026 at 16:25:08 UTC by @SamuilKosev778857 for Audit Comp | Folks Finance: Staking Contracts
- Report ID: #69747
- Report Type: Smart Contract
- Report severity: Low
- Target: https://github.com/Folks-Finance/folks-staking-contracts/blob/main/src/Staking.sol
- Impacts:
- Contract fails to deliver promised returns, but doesn't lose value
Description
Brief/Intro
The migration authorization flow contains a revocation flaw in setMigrationPermit(). A user can approve a migrator while it has MIGRATOR_ROLE, but if that role is later removed, the user can no longer revoke the previously granted approval because the function still requires the target address to currently hold MIGRATOR_ROLE even when the user is setting the permit to false.
Vulnerability Details
The issue is in the permit-setting logic:
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 problem is that the role check is unconditional. It is applied both when the user is granting permission and when the user is trying to revoke permission.
Impact Details
Users are given a per-migrator approval mechanism via setMigrationPermit(), which implies they can allow or deny migration authority for their own positions.
The practical consequences are:
- users may believe they have revoked migration permission when they have not,
- stale approvals can persist indefinitely,
- migration authority can return later without fresh user consent.
References
Proof of Concept
function test_Migration_StalePermitCannotBeRevokedWhenRoleRemoved() public {
deal(address(token), address(staking), 1000 ether);
deal(address(token), bob, 100 ether);
uint8 periodIndex = addStakingPeriodByManager(50 ether, 20, 10, 5000, true);
approveAndStake(bob, periodIndex, 10 ether, 20, 10, 5000, address(0));
assertEq(staking.getUserStakes(bob).length, 1);
// Bob opts in to this migrator
vm.prank(bob);
staking.setMigrationPermit(migrator, true);
assertEq(staking.migrationPermits(migrator, bob), true);
bytes32 migratorRole = staking.MIGRATOR_ROLE();
// Migrator loses the role
vm.prank(admin);
staking.revokeRole(migratorRole, migrator);
assertEq(staking.hasRole(migratorRole, migrator), false);
// Bob now tries to revoke the permit, but cannot because the target no longer has MIGRATOR_ROLE
vm.expectRevert(abi.encodeWithSelector(IStakingV1.MigratorNotFound.selector, migrator));
vm.prank(bob);
staking.setMigrationPermit(migrator, false);
// approval remains stored
assertEq(staking.migrationPermits(migrator, bob), true);
// the same address regains MIGRATOR_ROLE
vm.prank(admin);
staking.grantRole(migratorRole, migrator);
assertEq(staking.hasRole(migratorRole, migrator), true);
// old approval becomes usable again
assertEq(staking.migrationPermits(migrator, bob), true);
vm.prank(migrator);
IStakingV1.UserStake[] memory migratedStakes = staking.migratePositionsFrom(bob);
assertEq(migratedStakes.length, 1);
assertEq(migratedStakes[0].amount, 10 ether);
assertEq(staking.getUserStakes(bob).length, 0);
// Migrator directly received Bob's remaining principal + reward
assertEq(token.balanceOf(migrator), migratedStakes[0].amount + migratedStakes[0].reward);
}
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 in setMigrationPermit is unconditional, so it also blocks revocation when the migrator no longer has the role.
Impact
A user's stale migration approval can persist and later be used to migrate their positions without fresh consent, though the report rates this as low severity and notes no direct loss of value.
What the attacker needed
User has staked tokens; user previously granted a migration permit; migrator role is revoked then re-granted
The fix
The role check should only apply when granting a permit, not when revoking it, so users can always revoke their approval.
How it was found
- Bob stakes tokens and grants a migration permit to a migrator that holds MIGRATOR_ROLE.
- The admin revokes MIGRATOR_ROLE from the migrator.
- Bob tries to revoke the permit but the transaction reverts because the migrator no longer has the role.
- The admin grants MIGRATOR_ROLE back to the same migrator.
- The old permit is still stored and the migrator uses it to migrate Bob's positions.
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 code checks that the migrator is currently authorised before allowing the user to change that permission, even when the user wants to take permission away. If the migrator loses authorisation, the user cannot revoke, and if authorisation returns later, the old permission is still there and can be used.
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.