Skip to content
Business logic Audit finding Beginner

Whitelisted role cannot be revoked in nft cairo

The NFT contract only lets the owner add an address to the whitelist and has no on-chain way to remove it. If the owner revokes a whitelist status off-chain, the on-chain record still says the address is whitelisted, so the two sources of truth disagree.

Divine_Dragon Follow

Originally disclosed on Immunefi

Informational View original
  • Disclosed after under an hour

57921 sc insight whitelisted role cannot be revoked in nft cairo

Submitted on Oct 29th 2025 at 13:29:09 UTC by @Divine_Dragon for Audit Comp | Belong

Impacts:

  • (Not specified in original report)

Description

Vulnerability Details

addWhitelisted in the nft.cairo contract is used by the contract owner to mark a given address as whitelisted. However, there is no function in the contract to revoke a whitelisted status on-chain. Because of this, if the owner needs to revoke whitelist status they must perform changes off-chain (in the back-end). This creates a mismatch between on-chain data and back-end data:

  • On-chain: address remains whitelisted (true).
  • Back-end: may mark the address as not whitelisted (false) after an off-chain revoke.

This inconsistency can break users' trust: users checking their on-chain status see true, but operations like mintStaticOperation might rely on back-end whitelist checks and fail because the back-end revoked the status off-chain.

Mitigation

{% hint style="info" %} Replace addWhitelisted with a toggle-style function (for example toggleWhitelisted) that allows the owner to switch an address's whitelisted status between true and false on-chain. This provides a proper on-chain revoke mechanism and prevents divergence between on-chain and back-end state. {% endhint %}

References

https://github.com/immunefi-team/audit-comp-belong/blob/0cbcde6fd80dbc55a9e3403c8e5a74827dea19e2/src/nft/nft.cairo#L448-L455

Proof of Concept

Test demonstrating the inability to re-revoke (only adding is implemented):

Rust
#[test]
#[should_panic(expected: 'Address is already whitelisted')]
fn test_addWhitelisted_whitelisted_already() {
    let contract = deploy();

    let nft = INFTDispatcher { contract_address: contract };

    start_cheat_caller_address(contract, constants::CREATOR());

    nft.addWhitelisted(contract_address_const::<1>());

    // Throws: 'Address is already whitelisted'
    nft.addWhitelisted(contract_address_const::<1>());
}

The test indicates once a whitelisted status is set for an address, there is no way to revert that status on-chain using the provided interface.

<details> <summary>Test run output</summary>
 *  Executing task: snforge test nft::tests::test_nft::test_addWhitelisted_whitelisted_already --exact 

   Compiling snforge_scarb_plugin v0.51.1 (git+https://github.com/foundry-rs/starknet-foundry.git?tag=v0.51.1#6f5a02e54c76c2e740c0756568448265e12a6f2d)
    Finished `release` profile [optimized] target(s) in 0.05s
   Compiling test(nft_unittest) nft v0.1.0

    Finished `dev` profile target(s) in 4 seconds

Collected 1 test(s) from nft package
Running 1 test(s) from src/
[PASS] nft::tests::test_nft::test_addWhitelisted_whitelisted_already (l1_gas: ~0, l1_data_gas: ~1344, l2_gas: ~928453)
Tests: 1 passed, 0 failed, 0 ignored, other filtered out
</details>

The original report as published on Immunefi, by Divine_Dragon. 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 contract exposes only an add function for the whitelist and no corresponding remove or toggle function, so the on-chain state cannot be reversed.

Impact

On-chain and back-end whitelist data can diverge, which may confuse users and could cause operations that rely on the back-end check to fail for an address that still looks whitelisted on-chain.

What the attacker needed

Contract owner role; none for an attacker

The fix

The contract should replace the add-only function with a toggle-style function so the owner can switch an address's whitelisted status on-chain.

How it was found

  1. Deploy the contract and impersonate the creator.
  2. Call addWhitelisted for an address.
  3. Call addWhitelisted again for the same address and observe the panic saying it is already whitelisted.

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 whitelist is a list of addresses that are allowed to do something. This contract can add an address to the list but has no function to take it off again. So once an address is on the list on the blockchain, it stays there, even if the team removes it in their own database.

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 Divine_Dragon

View all

1 more disclosed report, best first.

More from Belong

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.