Skip to content
Access control Audit finding Intermediate

Users cannot revoke previously granted migration permit after migrator role is revoked

The setMigrationPermit function in Staking.sol requires the migrator to hold MIGRATOR_ROLE even when a user tries to revoke a previously granted permit. If the admin revokes the migrator's role, users cannot clear their stale consent, and the permit becomes active again if the same address is later re-granted the role.

Oxb4b Follow

Originally disclosed on Immunefi

  • Disclosed after under an hour

69663 sc low users cannot revoke previously granted migration permit after migrator role is revoked

Submitted on Mar 16th 2026 at 06:52:27 UTC by @Oxb4b for Audit Comp | Folks Finance: Staking Contracts

Description

Brief/Intro

The setMigrationPermit() function in Staking.sol prevents users from revoking previously granted migration permissions once the migrator's role has been revoked by the admin. This creates a consent-revocation deadlock where stale permissions persist indefinitely and can become active again if the same address is later re-granted the MIGRATOR_ROLE, allowing migrations without fresh user consent.

Vulnerability Details

Current Implementation

Solidity
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 function enforces hasRole(MIGRATOR_ROLE, _migrator) check regardless of whether the user is granting or revoking permission. This design has an unintended consequence:

  • Granting permission (true): The role check is appropriate — users should only grant permits to active migrators.
  • Revoking permission (false): The role check creates a deadlock — users cannot revoke previously granted permissions if the migrator no longer holds the role.

Root Cause

The migrationPermits mapping is never cleared when a migrator loses the MIGRATOR_ROLE. The single gate (hasRole check) applies to both grant and revoke operations, preventing users from cleaning up stale consent after role revocation.

Consent-Revocation Deadlock Scenario

  1. Alice grants migration permission to migrator M: setMigrationPermit(M, true) → migrationPermits[M][Alice] = true
  2. Admin revokes M's role: revokeRole(MIGRATOR_ROLE, M)
  3. Alice attempts to revoke her old permit: setMigrationPermit(M, false)
  4. Call reverts with MigratorNotFound(M) because hasRole(MIGRATOR_ROLE, M) now returns false
  5. Months later, admin re-grants role: grantRole(MIGRATOR_ROLE, M)
  6. M can now migrate Alice's positions using the stale permit from step 1, without any fresh consent from Alice

Impact and Likelihood Details

Impact: Low

  • No Direct Fund Loss: Funds are not stolen; migration is a legitimate protocol operation.
  • Loss of User Autonomy: Users lose the ability to revoke previously granted migration consent, violating the principle that consent should always be user-controlled.
  • Unexpected Migration: Users who attempted to revoke consent (and were blocked) may be surprised when old permissions become active again after role re-grant.

Likelihood: Low

  • Requires specific operational sequence: user grants permit → role revoked → user attempts revocation → role re-granted to same address.
  • However, the bug is deterministic once the sequence occurs — every user who granted a permit before role revocation will experience this issue.

Link to Proof of Concept

https://gist.github.com/tharunbethina/36b3cf2705b65633fc2fd05fe6d8e599

Proof of Concept

{% stepper %} {% step %}

Alice grants permission to migrator M

setMigrationPermit(M, true) → migrationPermits[M][Alice] = true {% endstep %}

{% step %}

Admin revokes MIGRATOR_ROLE from M

revokeRole(MIGRATOR_ROLE, M) {% endstep %}

{% step %}

Alice tries to revoke old permit

setMigrationPermit(M, false) {% endstep %}

{% step %}

Call reverts

Call reverts with MigratorNotFound(M) (role check blocks revocation) {% endstep %}

{% step %}

Stale permit persists in storage

migrationPermits[M][Alice] remains true {% endstep %}

{% step %}

Admin later re-grants MIGRATOR_ROLE to M

grantRole(MIGRATOR_ROLE, M) {% endstep %}

{% step %}

M migrates Alice's positions

M migrates Alice's positions via migratePositionsFrom(Alice) despite Alice's explicit revocation attempt - her consent intent (false) was ignored due to the deadlock {% endstep %} {% endstepper %}

The original report as published on Immunefi, by Oxb4b. 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 same hasRole check gates both granting and revoking a migration permit, and the stored permit is not cleared when the migrator loses the role.

Impact

Users lose the ability to revoke migration consent, and a stale permit could later allow migration without fresh consent; the report rates this as low impact with no direct fund loss.

What the attacker needed

User previously granted a permit; admin revokes migrator role; admin later re-grants same role

The fix

The contract should allow revocation without requiring the migrator to still hold the role, or clear stored permits when the role is revoked.

How it was found

  1. Alice grants migration permission to migrator M.
  2. The admin revokes MIGRATOR_ROLE from M.
  3. Alice tries to revoke her old permit.
  4. The call reverts with MigratorNotFound because the role check blocks revocation.
  5. The stale permit remains true in storage.
  6. The admin later re-grants MIGRATOR_ROLE to M, and M can migrate Alice's positions using the stale permit.

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 migrator permission to move their staked positions. The contract only lets a user change that permission while the migrator still has a special admin-granted role. If the admin removes that role, the user can no longer say 'no', and the old 'yes' stays saved. If the admin later gives the role back, the migrator can act on the old 'yes' even though the user tried to withdraw it.

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 by Oxb4b

View all

6 more disclosed reports, best first.

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.