Users cannot revoke a migration permit after role removal
The setMigrationPermit function requires the target address to hold MIGRATOR_ROLE even when a user tries to disable a previously granted migration permit. After an admin revokes the migrator role, users can no longer revoke their approval, leaving stale permissions in storage.
- Disclosed after under an hour
69673 sc low users cannot revoke a migration permit after role removal
Submitted on Mar 16th 2026 at 07:47:51 UTC by @Athenea for Audit Comp | Folks Finance: Staking Contracts
- Report ID: #69673
- Report Type: Smart Contract
- Report severity: Low
- Target: https://github.com/Folks-Finance/folks-staking-contracts/blob/main/src/Staking.sol
Description
Brief/Intro
This insight highlights a user-control issue in the migration permission system. Once a migrator loses MIGRATOR_ROLE, users who had previously approved it can no longer explicitly revoke that approval, leaving stale permissions in storage.
Vulnerability Details
setMigrationPermit() requires the target address to currently hold MIGRATOR_ROLE for both enabling and disabling a permit:
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);
}
As a result, once a migrator loses MIGRATOR_ROLE, users who previously approved it can no longer explicitly revoke that approval.
Impact Details
This is not an immediate exploit, because a role-revoked migrator cannot call migratePositionsFrom() while the role is absent.
Still, the behavior weakens user control and leaves stale approvals in place until role configuration changes again.
References
Recommendation
Require MIGRATOR_ROLE only when enabling a permit, not when disabling one:
function setMigrationPermit(address _migrator, bool _isMigrationPermitted) external {
if (_isMigrationPermitted && !hasRole(MIGRATOR_ROLE, _migrator)) {
revert MigratorNotFound(_migrator);
}
migrationPermits[_migrator][msg.sender] = _isMigrationPermitted;
emit MigrationPermitUpdated(_migrator, msg.sender, _isMigrationPermitted);
}
Proof of Concept
Steps
- Deploy
Staking. - Grant
MIGRATOR_ROLEtomigrator. - User enables migration permit for
migrator. - Admin revokes
MIGRATOR_ROLEfrommigrator. - User tries to disable the permit.
Code
Git Url: https://github.com/breakAIDev/fork-staking-poc.git
pragma solidity ^0.8.23;
import {console2} from "forge-std/console2.sol";
import {BaseInsightScript, PoCToken} from "../src/InsightPoCHelpers.sol";
import {Staking} from "repo-src/Staking.sol";
contract RevokePermitAfterRoleRemoval is BaseInsightScript {
function run() external {
_selectForkIfConfigured();
console2.log("=== Insight 1: Revoke permit fails after role removal ===");
(Staking staking, PoCToken token) = _deployStakingFixture();
token;
bytes32 migratorRole = staking.MIGRATOR_ROLE();
vm.prank(USER_A);
staking.setMigrationPermit(MIGRATOR, true);
console2.log("Step 1: USER_A enabled migration permit for MIGRATOR");
vm.prank(ADMIN);
staking.revokeRole(migratorRole, MIGRATOR);
console2.log("Step 2: ADMIN revoked MIGRATOR_ROLE");
vm.prank(USER_A);
(bool success, bytes memory lowLevelData) =
address(staking).call(abi.encodeCall(staking.setMigrationPermit, (MIGRATOR, false)));
if (success) {
console2.log("Unexpected: permit revocation succeeded");
} else {
console2.log("Step 3: USER_A tried to disable the permit and the call reverted");
console2.logBytes(lowLevelData);
}
}
}
Result
Script ran successfully.
Gas used: 5623713
== Logs ==
Fork selected from BSC_RPC_URL
=== Insight 1: Revoke permit fails after role removal ===
Step 1. USER_A enabled migration permit for MIGRATOR
Step 2. ADMIN revoked MIGRATOR_ROLE
Step 3. USER_A tried to disable the permit and the call reverted
0x881da127000000000000000000000000000000000000000000000000000000000000000e
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 setMigrationPermit function checks for MIGRATOR_ROLE on both enabling and disabling a permit, so disabling fails once the role is removed.
Impact
This is not an immediate exploit because a role-revoked migrator cannot call migratePositionsFrom while the role is absent, but it weakens user control and leaves stale approvals until role configuration changes again.
What the attacker needed
User previously granted a migration permit; admin revokes the migrator role
The fix
The check for MIGRATOR_ROLE should apply only when enabling a permit, not when disabling one.
How it was found
- Deploy the Staking contract.
- Grant MIGRATOR_ROLE to a migrator address.
- As a user, enable the migration permit for that migrator.
- As admin, revoke MIGRATOR_ROLE from the migrator.
- As the user, try to disable the permit and observe the call reverts.
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' contract permission to move their staked positions. The code only lets a user change that permission if the migrator currently has a special admin role. If the admin removes that role, the user can no longer turn off their earlier permission, so it stays switched on in the contract's records.
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.