Users cannot revoke migration permission during migrator role rotation window
The setMigrationPermit function requires the migrator to hold MIGRATOR_ROLE even when a user is revoking permission, so if the role is temporarily revoked the user cannot withdraw consent. If the role is later re-granted to the same address, the migrator can transfer the user's staked principal and rewards without renewed consent.
- Disclosed after under an hour
69962 sc low users cannot revoke migration permission during migrator role rotation window
Submitted on Mar 17th 2026 at 14:52:22 UTC by @x0t0wt1w for Audit Comp | Folks Finance: Staking Contracts
- Report ID: #69962
- 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 unconditionally requires the migrator to hold MIGRATOR_ROLE regardless of whether the user is granting or revoking permission. If a migrator's role is temporarily revoked, during a key rotation or infrastructure upgrade users are locked out from revoking their migration consent during that window. If the role is subsequently re-granted to the same address, the migrator can immediately call migratePositionsFrom() and transfer all of the user's staked principal and unclaimed rewards without any renewed consent, effectively ignoring the user's expressed intent to revoke. The permission system provides a false sense of control over a critical authorization.
Vulnerability Details
The setMigrationPermit function enforces a MIGRATOR_ROLE check unconditionally, regardless of whether the user is granting or revoking permission:
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);
}
This creates the following scenario:
- User calls
setMigrationPermit(migrator, true)-> permission granted successfully. - Admin revokes
MIGRATOR_ROLEfrom the migrator (key rotation, compromise, upgrade, etc.). - User attempts to revoke their permission by calling
setMigrationPermit(migrator, false). - The call reverts with
MigratorNotFound-> the user is now locked out of revoking. - Admin re-grants
MIGRATOR_ROLEto the same address at a later date. migrationPermits[migrator][user]is still true in storage -> the migrator can now callmigratePositionsFrom(user)without any renewed consent from the user.
The permission persists indefinitely in storage with no expiration mechanism and no TTL. There is no event or on-chain signal that would alert the user that their previously-blocked revocation attempt is now effectively void. The user has no recourse once this state is reached. The root cause is that the check hasRole(MIGRATOR_ROLE, _migrator) should only apply when _isMigrationPermitted == true. Revoking consent must always be unconditionally available to the user. The fix is straightforward:
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);
}
Impact Details
A user who attempts to revoke their migration permission during a MIGRATOR_ROLE rotation window is silently locked out, with no on-chain indication of when revocation will become possible again. If the role is re-granted to the same address before the user retries, the migrator can immediately call migratePositionsFrom() and transfer all of the user's staked principal and unclaimed rewards, without any renewed consent. The user's expressed intent to revoke is effectively ignored, and the permission system provides a false sense of control.
References
Proof of Concept
Add the following test in Staking.t.sol and run forge test --match-test test_SetMigrationPermit_UserCannotRevokeWhenMigratorRoleRevoked
function test_SetMigrationPermit_UserCannotRevokeWhenMigratorRoleRevoked()
public
{
assertEq(staking.migrationPermits(migrator, alice), false);
vm.startPrank(alice);
staking.setMigrationPermit(migrator, true);
assertEq(staking.migrationPermits(migrator, alice), true);
vm.stopPrank();
vm.prank(admin);
staking.revokeRole(keccak256("MIGRATOR"), migrator);
//Alice tries to revoke the migration permit but it reverts with MigratorNotFound
vm.expectRevert(
abi.encodeWithSelector(
IStakingV1.MigratorNotFound.selector,
migrator
)
);
vm.startPrank(alice);
staking.setMigrationPermit(migrator, false);
vm.stopPrank();
}
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 is applied unconditionally instead of only when granting permission, so revocation is blocked while the migrator lacks the role.
Impact
A user cannot revoke migration permission during a role rotation window, and if the role is re-granted the migrator could transfer the user's staked principal and unclaimed rewards without renewed consent.
What the attacker needed
User has granted migration permission; admin revokes migrator role; admin later re-grants role to same address
The fix
The role check should only apply when granting permission, so that revocation is always allowed.
How it was found
- User grants migration permission to the migrator.
- Admin revokes MIGRATOR_ROLE from the migrator.
- User tries to revoke their permission but the call reverts with MigratorNotFound.
- Admin later re-grants MIGRATOR_ROLE to the same address.
- The stored permission is still true, so the migrator can call migratePositionsFrom without renewed consent.
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 allow a special 'migrator' contract to move their staked funds. The code checks that the migrator is currently approved by the admin even when the user tries to say 'no, stop'. If the admin temporarily removes the migrator's approval, the user cannot withdraw their own permission, and if the migrator is approved again later, it can still move the user's funds.
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.