Referral percentages schedule stuck on first configuration
The referral percentage setter appends new tiers to a storage vector instead of overwriting the original five slots, while lookups only ever read the first five indices. Once an inflated commission schedule is stored, the owner cannot lower it, so referral partners keep receiving the higher split on every mint.
- Disclosed after under an hour
57454 sc low referral percentages schedule stuck on first configuration
Submitted on Oct 26th 2025 at 10:54:30 UTC by @OxPrince for Audit Comp | Belong
- Report ID: #57454
- Report Type: Smart Contract
- Report severity: Low
- Target: https://github.com/immunefi-team/audit-comp-belong/blob/feat/cairo/src/nftfactory/nftfactory.cairohttps://github.com/immunefi-team/audit-comp-belong/blob/feat/cairo/src/nftfactory/nftfactory.cairo
- Impacts:
- Protocol insolvency
Description
Brief/Intro
The factory exposes setReferralPercentages, but the implementation never overwrites the five referral tiers that were first stored during initialize. Each subsequent call just appends another five entries to used_to_percentage, while every lookup continues to read only the original slots. As a result, once an aggressive commission schedule is live there is no way to rotate back to a safer set of percentages, and referral partners keep receiving the inflated split indefinitely.
Vulnerability Details
_set_referral_percentagesiterates over the supplied span and callsappend()on every entry (src/nftfactory/nftfactory.cairo:451-456), so the storage vector keeps growing instead of being overwritten.- Referral math indexes the vector by usage count:
usedToPercentageandgetReferralRatereadself.used_to_percentage.at(timesUsed)(src/nftfactory/nftfactory.cairo:200-245). _set_referral_usercapsused_codeat 4 (src/nftfactory/nftfactory.cairo:431-433), meaning only indices 0–4 are ever consulted. Those slots are permanently populated with the very first schedule because nothing truncates or rewrites them.
Impact Details
If the owner ever raises the referral percentages—whether deliberately for a campaign or because a privileged key is misused—the protocol cannot later lower them. Referral operators can continue routing sales through their codes and siphon the same heightened commission on every mint. Because the payout comes directly from revenue that should fund the platform and creators, sustained operation under inflated rates can quickly drain treasury inflows and threaten solvency.
{% stepper %} {% step %}
Reproduction steps
- Call
initializewith a schedule such as[9000, 9000, 9000, 9000, 9000]. {% endstep %}
{% step %}
- Later call
setReferralPercentageswith safer values, e.g.[500, 400, 300, 200, 100]. {% endstep %}
{% step %}
- Query
usedToPercentage(1)or run a sale throughgetReferralRate; the contract still returns9000, confirming the old payout remains active. {% endstep %} {% endstepper %}
References
Add any relevant links to documentation or code
Proof of Concept
<details> <summary>Rust test PoC — demonstrates that setReferralPercentages appends instead of overwriting</summary>#[test]
fn test_setReferralPercentages_update_should_override() {
let contract = deploy();
let nft_factory = INFTFactoryDispatcher { contract_address: contract };
start_cheat_caller_address(contract, constants::OWNER());
let initial = array![9000, 9000, 9000, 9000, 9000].span();
nft_factory.setReferralPercentages(initial);
assert_eq!(nft_factory.usedToPercentage(0), *initial[0]);
assert_eq!(nft_factory.usedToPercentage(4), *initial[4]);
let updated = array![500, 400, 300, 200, 100].span();
nft_factory.setReferralPercentages(updated);
// Expected behavior: latest schedule visible at indices 0-4.
assert_eq!(nft_factory.usedToPercentage(0), *updated[0]);
assert_eq!(nft_factory.usedToPercentage(4), *updated[4]);
}
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 setter appends to the storage vector instead of overwriting the first five indices that the lookup logic actually reads.
Impact
If the owner ever raises referral percentages, they cannot be lowered again, so referral operators could keep siphoning the inflated commission and sustained operation could drain treasury inflows and threaten solvency.
What the attacker needed
Owner sets an inflated schedule first; owner later wants to lower rates
The fix
The setter should overwrite the existing five referral slots rather than appending new entries, so the latest schedule is the one consulted.
How it was found
- Call initialize with a high referral schedule such as five equal high values.
- Later call setReferralPercentages with lower, safer values.
- Query usedToPercentage or run a sale through getReferralRate and observe the original high value is still returned.
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.
The contract stores referral commission rates in a list. When the owner tries to change the rates, the new values are added to the end of the list rather than replacing the old ones, and the code only ever reads the first five entries. So the very first rates set stay in force forever, even if the owner later wants to reduce them.
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.