Skip to content
Business logic Audit finding Intermediate

Setmigrationpermit does not deliver on specified functionalities

The setMigrationPermit function requires the target migrator to hold the MIGRATOR_ROLE even when a user tries to revoke a previously granted migration permission. If the role is revoked, the user can no longer revoke the permission, so a later reintroduction of the same migrator would allow migration despite the user's attempted revocation.

max10afternoon Follow

Originally disclosed on Immunefi

  • Disclosed after under an hour

69777 sc low setmigrationpermit does not deliver on specified functionalities

Submitted on Mar 16th 2026 at 19:24:43 UTC by @max10afternoon for Audit Comp | Folks Finance: Staking Contracts

Description

Brief/Intro

In the documentation for mitigation process it is stated that: "The permission can be revoked at any time by calling setMigrationPermit(migratorAddress, false)" (https://github.com/Folks-Finance/folks-staking-contracts/tree/main?tab=readme-ov-file#migration). This is not the case as it will not always be possible to do so.

Vulnerability Details

The setMigrationPermit allows a user to permit or revoke permission to a migration contract to call migratePositionsFrom:

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

In order to interact with this functionality it is necessary for the targeted address to have the migrator role, even when trying to revoke permissions.

This means that if the role were to be revoked to a migrator address, the user will no longer be able to revoke any previously assigned permission for it. Hence if the migrator contract will be reintroduced at a later time the migration can be performed even as the user tried to prevent it (unsuccessfully due this issue), breaking the trust assumption specified in the docs, expecially considering that the migration MIGHT be a permissionless process beside the checks performed in the Staking contract, as per documentation.

Mitigation

This can easily be fixed by allowing to modify the state of any element in migrationPermits for as long as _isMigrationPermitted is set to false. Mitigating the issue without introducing any additional risks.

Impact Details

Low - Contract fails to deliver promised returns, but doesn't lose value:

This issue matches the description of this severity categorization as it is expected for a user to be able to revoke such permission at ANY time, but the function does not allows to do so ( "The permission can be revoked at any time by calling setMigrationPermit(migratorAddress, false)" https://github.com/Folks-Finance/folks-staking-contracts/tree/main?tab=readme-ov-file#migration ).

Proof of Concept

Add the following test case in the test file /test/Staking.t.sol:

Solidity
function test_Migration_RevokeFailure() public {
    deal(address(token), address(staking), 1000 ether);
    deal(address(token), alice, 100 ether);

    uint8 periodIndex = addStakingPeriodByManager(50 ether, 20, 10, 5000, true);
    approveAndStake(alice, periodIndex, 10 ether, 20, 10, 5000, address(0));

    //Alices allows migrations
    vm.prank(alice);
    staking.setMigrationPermit(migrator, true);
    assertEq(staking.getUserStakes(alice).length, 1);

    //Admin revoke migrator
    vm.prank(admin);
    staking.revokeRole(keccak256("MIGRATOR"), migrator);

    //Alice can no longer revoke pemrit
    vm.expectRevert(abi.encodeWithSelector(IStakingV1.MigratorNotFound.selector, migrator));
    vm.prank(alice);
    staking.setMigrationPermit(migrator, false);
    assertEq(staking.getUserStakes(alice).length, 1);

    //If at a later time amidn reintroduces the same migrator
    //The migrations will be executed even as Alice tried to prevent it
    vm.prank(admin);
    staking.grantRole(keccak256("MIGRATOR"), migrator);

    vm.expectEmit(true, true, true, true);
    emit IStakingV1.MigrateFrom(migrator, alice);
    vm.prank(migrator);
    IStakingV1.UserStake[] memory migratedStakes = staking.migratePositionsFrom(alice);
    assertEq(migratedStakes.length, 1);
    assertEq(migratedStakes[0].amount, 10 ether);
    assertEq(staking.getUserStakes(alice).length, 0);
}

The original report as published on Immunefi, by max10afternoon. 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 setMigrationPermit function checks for the MIGRATOR_ROLE on the target migrator even when the caller is trying to revoke a permission, so revocation fails if the role has been removed.

Impact

A user cannot revoke a migration permission while the migrator lacks the role, so if the role is later restored the migrator could migrate the user's positions against their will, breaking the documented guarantee that permission can be revoked at any time.

What the attacker needed

User has staked tokens; user previously granted migration permission; admin revokes migrator role; admin later restores migrator role

The fix

The function should allow revoking a permission (setting it to false) without requiring the target migrator to still have the MIGRATOR_ROLE.

How it was found

  1. Alice calls setMigrationPermit to allow a migrator contract.
  2. Admin revokes the MIGRATOR_ROLE from that migrator.
  3. Alice tries to revoke the permission but the call reverts with MigratorNotFound.
  4. Admin later grants the MIGRATOR_ROLE back to the same migrator.
  5. The migrator calls migratePositionsFrom for Alice and her stake is migrated despite her attempted revocation.

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 special contract permission to move their staked tokens. The documentation says this permission can be removed at any time. However, the removal function checks that the contract still has a special admin role; if that role was removed, the user cannot remove the permission, and the contract could later move their tokens if the role is given back.

What is Business logic?

The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.

More by max10afternoon

View all

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

Business logic flaws

The lesson behind this report.

The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.