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.
- 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
- Report ID: #68955
- Report Type: Smart Contract
- Report severity: Low
- Target: https://github.com/Folks-Finance/folks-staking-contracts/blob/main/src/Staking.sol
- Impacts:
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:
// 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 unconditionalhasRolechecksrc/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:
- User calls
setMigrationPermit(migratorAddress, true)→ permit is granted, stored astrue - Admin calls
revokeRole(MIGRATOR_ROLE, migratorAddress)→ migrator loses the role - User discovers the migrator no longer needs permission and calls
setMigrationPermit(migratorAddress, false)to clean up - Transaction reverts:
MigratorNotFound(migratorAddress)— thehasRolecheck fails on revocation - User has no way to clear their permit — it remains
truein storage indefinitely - Later: Admin re-grants
MIGRATOR_ROLEto the same address (legitimate reason: replacement migrator) - The stale permit becomes active again without the user's knowledge or fresh authorization
- If the user created new stakes after the role was revoked, these new stakes are now vulnerable to migration without fresh consent
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
- A user grants a migration permit to a migrator address.
- An admin revokes the migrator role from that address.
- The user tries to revoke their permit and the transaction reverts with MigratorNotFound.
- 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.