Users cannot revoke migration authorization after migrator role removal
The setMigrationPermit function checks that the migrator address holds MIGRATOR_ROLE even when a user is trying to revoke permission. If an admin removes the role, users can no longer clear their stored approval, which becomes active again if the role is later restored.
- Disclosed after under an hour
69527 sc low users cannot revoke migration authorization after migrator role removal
Submitted on Mar 15th 2026 at 12:18:55 UTC by @gneiss for Audit Comp | Folks Finance: Staking Contracts
- Report ID: #69527
- 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 setMigrationPermit function in the Staking contract allows users to grant or revoke permission for a migrator address that can move their staking positions. However, the current implementation requires the target address to hold the MIGRATOR_ROLE for both enabling and disabling the permit.
If an administrator later removes the role from a previously authorized migrator, users who had granted permission to that address are no longer able to revoke it. Any attempt to call setMigrationPermit(migrator, false) will revert with MigratorNotFound.
As a result, the approval entry remains permanently stored as true, leaving users without a direct method to clear it on-chain. This contradicts the documented behavior which states that migration permissions can be revoked at any time.
Vulnerability Details
Offer a detailed explanation of the vulnerability itself. Do not leave out any relevant information. Code snippets should be supplied whenever helpful, as long as they don’t overcrowd the report with unnecessary details. This section should make it obvious that you understand exactly what you’re talking about, and more importantly, it should be clear by this point that the vulnerability does exist.
Impact Details
The problem originates from the unconditional role validation inside setMigrationPermit.
Affected Code
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 function verifies that _migrator currently holds MIGRATOR_ROLE before performing any update. This check executes even when _isMigrationPermitted is false, which corresponds to a user attempting to revoke permission.
If the migrator role has already been revoked by an administrator, the role check fails and the transaction reverts. Consequently, users cannot remove the stored permit.
Scenario
A realistic sequence demonstrating the issue:
- A user grants migration permission to an address that currently holds
MIGRATOR_ROLE. - At a later time, an administrator removes the role from that address (for example after a migration phase ends).
- The user attempts to disable the authorization by calling
setMigrationPermit(migrator, false). - The call reverts because the migrator no longer satisfies the role requirement.
The permit therefore remains stored as true.
Although migrations cannot be executed while the role is missing, the stored authorization remains in the contract state. If the same address receives the MIGRATOR_ROLE again in the future, the previous approvals automatically become valid again without any new user action.
Impact
This issue primarily affects permission management rather than directly causing fund loss.
Potential consequences include:
- Irreversible approvals – Users may be unable to remove migration permissions they previously granted.
- Stale permissions remaining in storage – Authorization entries persist even after the migrator is removed.
- Automatic reactivation of privileges – If the address receives
MIGRATOR_ROLEagain later, all previously granted permissions instantly become active.
While migrations still require the role, the inability to revoke permissions contradicts expected behavior and introduces long-term authorization risk.
References
Proof of Concept
The following Foundry test demonstrates that once a migrator’s role is removed, a user cannot revoke a previously granted permit.
Run:
forge test --mt test_UserStuckWithPermitAfterMigratorRoleRevoked -vvv
function test_UserStuckWithPermitAfterMigratorRoleRevoked() public {
// provide token balances to staking contract and test user
deal(address(token), address(staking), 1_000 ether);
deal(address(token), alice, 100 ether);
// manager creates a staking configuration
uint8 periodId = addStakingPeriodByManager(50 ether, 20, 10, 5000, true);
// alice deposits tokens into the staking contract
approveAndStake(alice, periodId, 10 ether, 20, 10, 5000, address(0));
// user authorizes the migrator address
vm.prank(alice);
staking.setMigrationPermit(migrator, true);
// verify the permission is recorded
bool permitEnabled = staking.migrationPermits(migrator, alice);
assertTrue(permitEnabled);
// retrieve role identifier for the migrator role
bytes32 migratorRoleId = staking.MIGRATOR_ROLE();
// admin removes migrator privileges
vm.prank(admin);
staking.revokeRole(migratorRoleId, migrator);
// confirm role removal
assertFalse(staking.hasRole(migratorRoleId, migrator));
// user attempts to remove the authorization
vm.startPrank(alice);
vm.expectRevert(
abi.encodeWithSelector(IStakingV1.MigratorNotFound.selector, migrator)
);
staking.setMigrationPermit(migrator, false);
vm.stopPrank();
// permission entry remains enabled
bool permitStillActive = staking.migrationPermits(migrator, alice);
assertTrue(permitStillActive);
}
The test confirms that the permit remains set to true even though the user attempted to revoke it.
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 runs unconditionally, including when the user is trying to revoke permission.
Impact
Users cannot revoke a stored migration approval, and if the same address regains MIGRATOR_ROLE the old approval becomes valid again without any new user action; the report states this does not directly cause fund loss.
What the attacker needed
User previously granted migration permission; admin removed MIGRATOR_ROLE from that address
The fix
The role check should only apply when granting permission, so that revocation is always allowed.
How it was found
- A user grants migration permission to an address that holds MIGRATOR_ROLE.
- An administrator removes MIGRATOR_ROLE from that address.
- The user calls setMigrationPermit with false to revoke the permission.
- The call reverts with MigratorNotFound and the permit remains true.
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 staking position. The contract only lets a user change that permission if the migrator still has a special admin role. If an admin removes that role, the user cannot turn the permission off, and it stays saved in the contract.
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.