Skip to content
Access control Audit finding Intermediate

Unconditional hasRole check in setMigrationPermit() — Authorization Entrapment

The setMigrationPermit function requires the target migrator to still hold MIGRATOR_ROLE even when a user wants to revoke their own permit, so once an admin revokes that role users can no longer clear their stored consent. If the role is later granted again to the same address, the old permit silently becomes active again without fresh user approval.

hyuunn Follow

Originally disclosed on Immunefi

  • Disclosed after under an hour

68955 sc low unconditional hasrole check in setmigrationpermit authorization entrapment

Submitted on Mar 12th 2026 at 04:38:52 UTC by @hyuunn for Audit Comp | Folks Finance: Staking Contracts

Description

Brief/Intro

When an admin revokes the MIGRATOR_ROLE from a migrator address, users who previously granted a migration permit to that address cannot revoke their permit. The permit persists indefinitely in storage. If the role is later re-granted to the same address, the stale permit automatically reactivates without the user's knowledge or fresh authorization.

Vulnerability Details

The setMigrationPermit() function applies the hasRole check to both grant and revoke operations:

Solidity
// File: src/Staking.sol:84-87
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);
}

When an admin revokes MIGRATOR_ROLE, users cannot call setMigrationPermit(migrator, false) — the check reverts. The permit remains true in storage indefinitely. This violates the design principle documented in IMigratorV1.sol: "migrator should not be able to migrate stakes if not approved by user" — user approval must always be revocable at their discretion.

Impact Details

  • Authorization Entrapment: Users cannot revoke stale permits after role revocation, losing control over their migration consent
  • Surprise Re-Migration Risk: If the role is re-granted to the same address (or if the address is an upgradeable proxy), the permit silently reactivates without fresh user authorization
  • No Immediate Fund Loss: Impact is authorization integrity, not fund theft — but violates core security principle that users must control their own approvals

Conditions for Insight Value: Admin revokes a migrator role while users still hold permits; user later wants to revoke; role could potentially be re-granted

References

  • src/Staking.sol:84-87 — setMigrationPermit() with unconditional hasRole check
  • src/interfaces/IMigratorV1.sol — design intent: "migrator should not be able to migrate stakes if not approved by user"

Proof of Concept

Scenario Where Authorization Control Is Lost:

  1. User calls setMigrationPermit(migratorAddress, true) → permit is granted, stored as true
  2. Admin calls revokeRole(MIGRATOR_ROLE, migratorAddress) → migrator loses the role
  3. User discovers the migrator no longer needs permission and calls setMigrationPermit(migratorAddress, false) to clean up
  4. Transaction reverts: MigratorNotFound(migratorAddress) — the hasRole check fails on revocation
  5. User has no way to clear their permit — it remains true in storage indefinitely
  6. Later: Admin re-grants MIGRATOR_ROLE to the same address (legitimate reason: replacement migrator)
  7. The stale permit becomes active again without the user's knowledge or fresh authorization
  8. If the user created new stakes after the role was revoked, these new stakes are now vulnerable to migration without fresh consent

The original report as published on Immunefi, by hyuunn. 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

Likely the same hasRole check guards both granting and revoking a permit, so revocation is blocked whenever the migrator no longer holds the role.

Impact

Users lose the ability to withdraw their migration consent, and a later re-grant of the role could let a migrator move their stakes without fresh approval; the report states there is no immediate fund loss.

What the attacker needed

User has granted a migration permit; admin revokes the migrator role; role may later be re-granted

The fix

The revocation path should be allowed regardless of whether the migrator still holds the role, so users can always clear their own permit.

How it was found

  1. A user grants a migration permit to a migrator address.
  2. An admin revokes the migrator role from that address.
  3. The user tries to revoke their permit and the transaction reverts with MigratorNotFound.
  4. The permit stays true in storage, and if the role is granted again it becomes active without fresh 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 tick a box saying a particular helper contract is allowed to move their staked tokens. The contract only lets them untick that box while the helper still has an official 'migrator' badge. If an admin removes the badge, the untick call fails, so the box stays ticked forever, and if the badge comes back the old permission quietly applies 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 by hyuunn

View all

4 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.