SetMigrationPermit blocks revocation after role revoke, enabling stale consent reuse
The staking contract only lets a user change a migration permit while the target migrator currently holds the migrator role, so once that role is revoked the user can no longer withdraw consent. If the same address is later re-granted the role, the old approval becomes effective again and positions can be migrated without fresh user consent.
- Disclosed after under an hour
69650 sc low setmigrationpermit blocks revocation after role revoke enabling stale consent reuse
Submitted on Mar 16th 2026 at 05:37:24 UTC by @oxKrodhan for Audit Comp | Folks Finance: Staking Contracts
- Report ID: #69650
- Report Type: Smart Contract
- Report severity: Low
- Target: https://github.com/Folks-Finance/folks-staking-contracts/blob/main/src/Staking.sol
- Impacts:
- Griefing (e.g. no profit motive for an attacker, but damage to the users or the protocol)
Description
Brief/Intro
The contract binds permit updates to current role membership in a way that blocks user revocation during certain admin state transitions. This creates a consent lifecycle flaw, stale migration approvals can revive after role re grant.
Vulnerability Details
The issue is caused by how setMigrationPermit enforces the migrator role check before allowing any permit update. In Staking contract, a user can only write migrationPermits[migrator][user] if that migrator currently has MIGRATOR_ROLE. This creates a state lock condition, a user may successfully set permission to true while the migrator is authorized, but if governance later revokes that role, the same user can no longer call setMigrationPermit(migrator, false) because the call reverts with MigratorNotFound. As a result, the stored approval remains true in state with no user side revocation path during the revoked period. If the same migrator address is granted MIGRATOR_ROLE again in the future, the old approval becomes effective again, and migratePositionsFrom can proceed because it checks role authorization and the existing boolean permit. In short, revocation capability is coupled to current role status, which allows stale migration consent to persist and later reactivate without fresh user intent.
Impact Details
- User cannot revoke prior migration consent after role revocation event.
- Governance/operator can later re enable the same migrator address and stale approvals become effective without a fresh opt in.
- This weakens user control guarantees and can cause unexpected migration execution against user expectations.
References
Steps to reproduce scenario
- Deploy staking and grant MIGRATOR_ROLE to address M.
- User Alice opens a stake position.
- Alice calls setMigrationPermit(M, true).
- Admin revokes MIGRATOR_ROLE from M.
- Alice attempts setMigrationPermit(M, false).
- Transaction reverts with MigratorNotFound, so revocation fails.
- Admin grants MIGRATOR_ROLE to M again.
- M calls migratePositionsFrom(Alice) successfully.
- Result, migration uses old approval even though Alice attempted to revoke.
Proof of Concept
function test_PoC_MigrationPermitReactivatesAfterRoleRegrant() public {
deal(address(token), address(staking), 1000 ether);
deal(address(token), alice, 100 ether);
bytes32 migratorRole = staking.MIGRATOR_ROLE();
uint8 periodIndex = addStakingPeriodByManager(50 ether, 20, 10, 5000, true);
approveAndStake(alice, periodIndex, 10 ether, 20, 10, 5000, address(0));
vm.prank(alice);
staking.setMigrationPermit(migrator, true);
assertEq(staking.migrationPermits(migrator, alice), true);
vm.prank(admin);
staking.revokeRole(migratorRole, migrator);
vm.expectRevert(abi.encodeWithSelector(IStakingV1.MigratorNotFound.selector, migrator));
vm.prank(alice);
staking.setMigrationPermit(migrator, false);
assertEq(staking.migrationPermits(migrator, alice), true);
vm.prank(admin);
staking.grantRole(migratorRole, migrator);
vm.prank(migrator);
IStakingV1.UserStake[] memory migratedStakes = staking.migratePositionsFrom(alice);
assertEq(migratedStakes.length, 1);
assertEq(staking.getUserStakes(alice).length, 0);
}
Add above test to the Staking.t.sol and run the test.
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 permit update function checks the migrator's current role before writing the permit, coupling a user's ability to revoke consent to the migrator's role status instead of allowing revocation at any time.
Impact
A user cannot revoke migration consent while the migrator role is revoked, and if the same address is re-granted the role the stale approval could let positions be migrated against the user's expectations.
What the attacker needed
A staked position; migrator role granted then revoked; same address re-granted the role
The fix
The permit update should allow a user to revoke consent regardless of the migrator's current role, for example by only enforcing the role check when setting a permit to true.
How it was found
- Deploy the staking contract and grant the migrator role to an address.
- A user stakes and sets a migration permit to true for that migrator.
- The admin revokes the migrator role from that address.
- The user tries to set the permit to false and the call reverts with MigratorNotFound.
- The admin grants the migrator role back to the same address.
- The migrator calls migratePositionsFrom for the user and the old approval is used.
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 gives a migrator address permission to move their staked positions. The contract only lets the user change that permission while the migrator is still an approved migrator. If the admin removes the migrator and later adds the same address back, the user's old permission is still stored and can be used again, even though the user tried to say no.
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.