Skip to content
Access control Audit finding Intermediate

Cannot Revoke Migration Permit After Role Revocation (Stale Permits Re-Activate on Re-Grant)

The permit-setting function checks that the migrator holds the migrator role even when a user is trying to revoke a permit, so once the role is removed the user's revocation call reverts and the approval stays in storage. If the same address is later given the role again, the stale permit lets it migrate the user's positions without fresh consent.

rlp_xdaem0n Follow

Originally disclosed on Immunefi

  • Disclosed after under an hour

69966 sc low cannot revoke migration permit after role revocation stale permits re activate on re grant

Submitted on Mar 17th 2026 at 14:53:43 UTC by @rlp_xdaem0n for Audit Comp | Folks Finance: Staking Contracts

Description

Brief/Intro

setMigrationPermit checks hasRole(MIGRATOR_ROLE, _migrator) before allowing any permit change — including revocation. When an admin revokes MIGRATOR_ROLE from a migrator address (e.g., because it was compromised), all users who had previously approved that migrator are permanently locked into their approval: calling setMigrationPermit(_migrator, false) reverts with MigratorNotFound. The permit persists in storage with no user-accessible remediation path.

If the admin later re-grants MIGRATOR_ROLE to the same address — whether intentionally (believing the address re-secured) or accidentally — the stale permit is immediately exploitable: the migrator can call migratePositionsFrom(user) and extract the user's full unclaimed principal + rewards without the user ever re-consenting.


Vulnerability Details

The Role Check Blocks Both Granting and Revoking

Solidity
// Staking.sol L77-L82
function setMigrationPermit(address _migrator, bool _isMigrationPermitted) external {
    if (!hasRole(MIGRATOR_ROLE, _migrator)) revert MigratorNotFound(_migrator); // @audit blocks revocation too
    migrationPermits[_migrator][msg.sender] = _isMigrationPermitted;
    emit MigrationPermitUpdated(_migrator, msg.sender, _isMigrationPermitted);
}

The hasRole check serves a legitimate purpose when granting a permit: it ensures the user only approves addresses that actually hold MIGRATOR_ROLE. However, the same check is applied unconditionally when revoking (_isMigrationPermitted = false), where it serves no security purpose and actively harms users.

Attack Sequence

  1. Normal operation: Migrator M holds MIGRATOR_ROLE. Alice calls setMigrationPermit(M, true).
  2. Role revocation: Admin revokes MIGRATOR_ROLE from M (e.g., M is compromised, or migration phase ends).
  3. User trapped: Alice calls setMigrationPermit(M, false) — reverts with MigratorNotFound(M). Alice has no way to clean up her permit.
  4. Role re-grant: Admin re-grants MIGRATOR_ROLE to M at a later time.
  5. Exploitation: M calls migratePositionsFrom(alice). The stale permit from step 1 satisfies the check at L172. Alice's unclaimed stake and rewards are transferred to M without Alice's re-consent.

Why This Is Distinct From Known Issues

The project's known issues include: "State migrationPermits may contain migrator which had its MIGRATOR_ROLE later revoked."

This acknowledges that stale permit state exists but does not address:

  1. The user's inability to revoke that stale permit (the actual code bug)
  2. The attack vector when the role is re-granted to the same address

The stale state is a symptom. The bug is that setMigrationPermit applies the role check symmetrically to both granting and revoking, when the security requirement is asymmetric.


Impact

  • Loss of user sovereignty: Users cannot revoke permissions they granted. This violates the principle that users should always be able to reduce their own exposure.
  • Unauthorized migration on role re-grant: If the admin re-grants MIGRATOR_ROLE to the same address, the migrator can extract the user's full unclaimed principal + rewards without re-consent. The migrator contract receives the tokens via TOKEN.safeTransfer(msg.sender, ...) at L206.
  • No user remediation path: Between role revocation and re-grant, the user has zero ability to protect themselves. They cannot call setMigrationPermit (reverts), cannot withdraw faster (linear unlock), and cannot cancel the permit through any other function.

Recommended Fix

Only require hasRole when granting a permit. Revocation should always be permitted:

Solidity
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);
}

Single-line change. Preserves the granting validation while restoring user sovereignty over revocation.


References

Link to Proof of Concept

https://gist.github.com/wsam07/a7454521c87df36d8d81cc0706e94fa5

Proof of Concept

This PoC proves (1) users cannot revoke a previously granted migration permit after MIGRATOR_ROLE is revoked, and (2) the stale permit becomes effective again if the same migrator address is later re-granted the role. A standalone copy of the PoC (including the commands and sample output) is available below.

Check Full PoC: https://gist.github.com/wsam07/a7454521c87df36d8d81cc0706e94fa5

The original report as published on Immunefi, by rlp_xdaem0n. Images and videos are our own copies; raw HTML is shown as text. View it on Immunefi.

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 is applied to both granting and revoking, so revocation is blocked once the migrator no longer holds the role.

Impact

Users cannot cancel an approval, and if the role is re-granted to the same address the migrator could move the user's unclaimed principal and rewards without re-consent.

What the attacker needed

User previously approved the migrator; admin revokes then re-grants the role

The fix

The role check should only apply when granting a permit, so revocation is always allowed.

How it was found

  1. A migrator holds the migrator role and a user approves it with setMigrationPermit.
  2. The admin revokes the migrator role from that address.
  3. The user tries to revoke the permit and the call reverts with MigratorNotFound.
  4. The admin later re-grants the migrator role to the same address.
  5. The migrator calls migratePositionsFrom for the user and the stale permit satisfies the check.

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 approve a migrator address to move their staked funds. The contract only lets a user change that approval if the migrator currently holds a special role, so when an admin removes the role the user can no longer cancel their approval. If the role is handed back to the same address later, the old approval is still there and can be used again.

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.

More from Folks Finance: Staking Contracts

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Broken access control

The lesson behind this report.

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.