Stale migration permits cannot be revoked after migrator role removal
A user's approval of a migrator address cannot be withdrawn once that address loses its migrator role, because the revoke call reverts. If the role is granted again later, the old approval becomes usable again without any fresh consent from the user.
Originally disclosed on Immunefi
- Disclosed after under an hour
69814 sc low stale migration permits cannot be revoked after migrator role removal
Submitted on Mar 16th 2026 at 23:32:46 UTC by @incogknito for Audit Comp | Folks Finance: Staking Contracts
- Report ID: #69814
- 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
Finding
The README says migration permission can be revoked at any time, but that is not true in Staking.sol: https://github.com/Folks-Finance/folks-staking-contracts/blob/3131a2d46b5afa76f606bf08adfd85452a47e2d8/src/Staking.sol#L77-L82
setMigrationPermit() requires the target address to currently hold MIGRATOR_ROLE. So if a user approves a migrator and that role is later revoked, calling setMigrationPermit(migrator, false) reverts with MigratorNotFound, leaving the old permit stored in migrationPermits.
If the same address receives MIGRATOR_ROLE again later, the old approval becomes usable again and migratePositionsFrom() can be called without any fresh user action.
Impact
Users cannot revoke a previously granted migration permit once the role is removed. The old permit remains onchain. Re-granting MIGRATOR_ROLE makes the stale approval usable again.
Recommendation
Allow setMigrationPermit(migrator, false) even if migrator no longer has MIGRATOR_ROLE.
Proof of Concept
function test_PoC_Info_MigrationPermitReactivatesAfterRoleRegrant() public {
vm.prank(bob);
staking.setMigrationPermit(migrator, true);
assertEq(staking.migrationPermits(migrator, bob), true);
vm.prank(admin);
staking.revokeRole(staking.MIGRATOR_ROLE(), migrator);
vm.expectRevert(abi.encodeWithSelector(IStakingV1.MigratorNotFound.selector, migrator));
vm.prank(bob);
staking.setMigrationPermit(migrator, false);
assertEq(staking.migrationPermits(migrator, bob), true);
vm.prank(admin);
staking.grantRole(staking.MIGRATOR_ROLE(), migrator);
vm.expectEmit(true, true, true, true);
emit IStakingV1.MigrateFrom(migrator, bob);
vm.prank(migrator);
IStakingV1.UserStake[] memory migratedStakes = staking.migratePositionsFrom(bob);
assertEq(migratedStakes.length, 0);
}
forge test --match-test test_PoC_Info_MigrationPermitReactivatesAfterRoleRegrant -vv
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 revoke path checks that the target currently holds the migrator role before clearing the stored permit, so removal of the role blocks the cleanup.
Impact
A user's earlier approval could be reused after the role is restored, so positions may be migrated without fresh consent; the report rates this as low severity.
What the attacker needed
User has granted a migration permit; admin revokes then re-grants the role
The fix
The revoke path should clear the stored permit even when the target no longer holds the migrator role.
How it was found
- A user grants a migration permit to a migrator address.
- An admin revokes the migrator role from that address.
- The user tries to revoke the permit and the call reverts, leaving the permit stored.
- An admin grants the migrator role back to the same address.
- The migrator calls the migration function and the stale permit is accepted.
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 contract permission to move their staked positions, and is told they can take that permission back at any time. The code only lets them take it back while that contract still holds a privileged role, so once the role is removed the permission is stuck. If the role is handed back later, the old permission silently works again.
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.