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
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.
Area: Smart contract ·
lib.rs(burn)Description
burn(token_address, from, amount)never verifies thattoken_addresswas deployed by this factory.For unknown addresses the
TokenIndexlookup simply returnsNoneand the function proceeds to callbalanceandburnon the arbitrary external contract — meaning (a) the factory-wide invariant"a token's
burn_enabledflag gates burning" only applies to known tokens, and (b) the factoryhappily forwards calls (and emits its own official-looking
burnevents, polluting the indexedhistory that Transaction History renders) for any contract anyone points it at. A malicious contract
at
token_addressalso gets to execute arbitrary code mid-call with the factory as caller — thereentrancy 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-
burnfor non-factorytokens; holders of external tokens can burn directly on those contracts.
Tasks
TokenIndex(token_address)to exist inburn; returnTokenNotFoundotherwise(making the
burn_enabledcheck unconditional as a side effect).mint_tokens,set_metadata, andset_burn_enabledfor the same trust boundary(they currently do check the
ownerkey — add explicit tests locking that in).factory tokens;
burn_enabled=falseblocks burn for every factory token with no bypass.docs/contract-abi.md(burnerrors gainTokenNotFound).Acceptance criteria
burn_enabledis false, and no factoryburneventcan reference a non-factory token.
Issue 17 of 20 from the codebase audit tracked in
ISSUES.md.