Skip to content

🟡 burn acts as an open proxy for arbitrary token contracts, and skips burn_enabled for unknown tokens #1021

Description

@Ejirowebfi

Area: Smart contract · lib.rs (burn)

Description

burn(token_address, from, amount) never verifies that token_address was deployed by this factory.
For unknown addresses the TokenIndex lookup simply returns None and the function proceeds to call
balance and burn on the arbitrary external contract — meaning (a) the factory-wide invariant
"a token's burn_enabled flag gates burning" only applies to known tokens, and (b) the factory
happily forwards calls (and emits its own official-looking burn events, polluting the indexed
history that Transaction History renders) for any contract anyone points it at. A malicious contract
at token_address also gets to execute arbitrary code mid-call with the factory as caller — the
reentrancy lock protects factory state, but the factory still lends its event log and its transaction
context to whatever the callee does. There is no legitimate use of factory-burn for non-factory
tokens; holders of external tokens can burn directly on those contracts.

Tasks

  • Require TokenIndex(token_address) to exist in burn; return TokenNotFound otherwise
    (making the burn_enabled check unconditional as a side effect).
  • Audit mint_tokens, set_metadata, and set_burn_enabled for the same trust boundary
    (they currently do check the owner key — add explicit tests locking that in).
  • Add tests: burn on a never-registered address fails; burn events are only ever emitted for
    factory tokens; burn_enabled=false blocks burn for every factory token with no bypass.
  • Update docs/contract-abi.md (burn errors gain TokenNotFound).

Acceptance criteria

  • The factory only ever invokes token contracts it deployed, proven by tests.
  • No code path can burn a factory token whose burn_enabled is false, and no factory burn event
    can reference a non-factory token.

Issue 17 of 20 from the codebase audit tracked in ISSUES.md.

Metadata

Metadata

Assignees

Labels

GrantFox OSSIssue tracked in GrantFox OSSMaybe RewardedIssue may be eligible for a GrantFox rewardOfficial Campaign | FWC26Campaign: Official Campaign | FWC26auditFrom the ISSUES.md codebase auditreleasedseverity: elevatedCorrectness/robustness gap with user-visible impact

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions