Users cannot revoke permit for a role revoked migrator leading to residual permit risk if such migrator s role is ever reinstated
The setMigrationPermit function requires the migrator to currently hold the MIGRATOR_ROLE even when a user tries to revoke their permit. If the migrator's role is revoked, users cannot remove their approval, leaving a stale permit that becomes active again if the role is reinstated.
- Disclosed after under an hour
69493 sc low users cannot revoke permit for a role revoked migrator leading to residual permit risk if such migrator s role is ever reinstated
Submitted on Mar 15th 2026 at 07:46:16 UTC by @Another for Audit Comp | Folks Finance: Staking Contracts
- Report ID: #69493
- 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 requires the migrator to currently hold the MIGRATOR_ROLE before allowing any change to the permit mapping. If an admin revokes this role from a migrator contract, users are unable to revoke their personal approvals to that migrator. This leaves stale permits in place, which become active again if the role is ever reinstated, violating the principle that users should always have full control over their own permissions.
Vulnerability Details
In Staking.sol, the function setMigrationPermit is implemented as follows:
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 check hasRole(MIGRATOR_ROLE, _migrator) is performed unconditionally, even when the user attempts to set _isMigrationPermitted = false (i.e., to revoke a previously granted permit). If the migrator’s role has been revoked, the function will always revert with MigratorNotFound. Consequently:
- Users cannot revoke their approval, even though the migrator is no longer authorized by the protocol.
- The stored permit remains
truein themigrationPermitsmapping. - If the migrator’s role is reinstated (for any reason), the old permit becomes active again potentially without the user’s consent.
This gives users no way to remove their approval once the migrator loses its role, effectively locking their permission until the role is restored — a situation that undermines user sovereignty over their own positions.
Impact Details
Users lose the ability to withdraw their migration approval when a migrator is revoked. If the migrator is ever reactivated, previously approved users may have their positions migrated without a fresh confirmation. While the migrator itself cannot call migratePositionsFrom while its role is revoked, the lingering permit creates a future risk.
References
Staking.sol–setMigrationPermitfunction - https://github.com/Folks-Finance/folks-staking-contracts/blob/3131a2d46b5afa76f606bf08adfd85452a47e2d8/src/Staking.sol#L78
Proof of Concept
Add the following test to Staking.t.sol inside the StakingTest contract. It demonstrates that after the migrator’s role is revoked, Alice cannot revoke her permit, and the permit remains true.
function test_Migration_UserCannotRevokePermitAfterMigratorRoleRevoked() public {
// Alice permits migrator
vm.prank(alice);
staking.setMigrationPermit(migrator, true);
assertEq(staking.migrationPermits(migrator, alice), true);
// Admin revokes migrator role
vm.prank(admin);
staking.revokeRole(keccak256("MIGRATOR"), migrator);
// Now Alice tries to revoke the permit – this should revert
vm.expectRevert(abi.encodeWithSelector(IStakingV1.MigratorNotFound.selector, migrator));
vm.prank(alice);
staking.setMigrationPermit(migrator, false);
// Permit remains true, Alice cannot revoke it
assertEq(staking.migrationPermits(migrator, alice), true);
}
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, including when a user is trying to revoke a permit, so revocation fails once the migrator loses its role.
Impact
Users lose the ability to withdraw their migration approval when a migrator is revoked, and if the migrator is ever reactivated, previously approved users may have their positions migrated without fresh confirmation.
What the attacker needed
User previously granted a permit; admin revokes migrator role; migrator role later reinstated
How it was found
- Alice grants a migration permit to the migrator.
- The admin revokes the migrator's role.
- Alice tries to revoke her permit, but the call reverts with MigratorNotFound.
- The permit remains true in the mapping.
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 contract only lets a user change that permission if the migrator still has an official role. If an admin removes that role, the user can no longer cancel their permission, so it stays on record and could be used again if the role comes back.
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.