Security: missing assert_pair_in_registry on two factory batch limit config functions [SEC-I03] (F01) #455
Labels
No labels
agent:fix_bugfix
agent:fix_conflicts
agent:fix_security
agent:gap_analysis
agent:implement
agent:implement
agent:implement
agent:open_issues
agent:ready
agent:research
agent:security_audit
agent:verify
architecture
backend
blocker:hybrid
blocker:launch
blocker:limit-orders
blocker:v2
block:log_only
block:security
bug
ci
contracts
correctness
deploy
dev
devops
docs
documentation
duplicate
e2e
enhancement
epic
feature
frontend
functional-completion
gas
good first issue
governance
help wanted
high-risk
hooks
hybrid
indexer
infra
infrastructure
integrators
invalid
launch-blocker
limit-orders
localnet
localterra
low priority
missing-implementation
needs-design
ops
performance
priority
high
priority
medium
product
qa
QA
question
ready
ready
research
scripts
security
security-hardening
smartcontracts
tech-debt
testing
ux
UX
v2
verification
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
code/cl8y-dex-terraclassic#455
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
Two factory admin functions --
execute_set_pair_limit_batch_maxandexecute_set_pair_limit_clean_config-- validate the pair address withdeps.api.addr_validatebut do not callassert_pair_in_registry. Every other single-pair admin function in the factory callsassert_pair_in_registryafter address validation. Without the registry check, governance can issueUpdateLimitOrderConfigorUpdateLimitCleanConfigto any arbitrary valid address, not just factory-registered pairs. Practical impact is low because only governance can invoke these messages, but the inconsistency breaks the uniform registry guard pattern and introduces a discoverability gap.What Was Checked
smartcontracts/contracts/factory/src/contract.rslines 718-739 (execute_set_pair_limit_batch_max): callsdeps.api.addr_validatethen proceeds withoutassert_pair_in_registry.smartcontracts/contracts/factory/src/contract.rslines 741-764 (execute_set_pair_limit_clean_config): same pattern, no registry check.execute_set_pair_fee(line 352),execute_set_pair_hooks(line 396),execute_set_discount_registry(line 422),execute_set_pair_paused(line 661),execute_sweep_pair(line 687): all callassert_pair_in_registryafteraddr_validate.Expected (per checklist)
All factory admin functions that target a pair address call
assert_pair_in_registryimmediately after address validation, consistently enforcing that the target is a factory-registered pair.Actual
execute_set_pair_limit_batch_maxandexecute_set_pair_limit_clean_configomit the registry check. The pattern is inconsistent with all other single-pair admin functions.Suggested Fix
Add
assert_pair_in_registry(&deps, &pair_addr)?to both functions immediately afterdeps.api.addr_validate(&pair)?, following the pattern inexecute_set_pair_fee. No behavior change for valid governance operations targeting registered pairs.Verification Checklist
assert_pair_in_registryadded toexecute_set_pair_limit_batch_maxafteraddr_validateassert_pair_in_registryadded toexecute_set_pair_limit_clean_configafteraddr_validateSetPairLimitBatchMaxorSetPairLimitCleanConfigagainst a non-registered address returns an errorCc: @PlasticDigits
changed title from
Security: missing assert_pair_in_registry on two factory batch limit config functions [SEC-I03]toSecurity: missing assert_pair_in_registry on two factory batch limit config functions [SEC-I03] (F01)changed the description
mentioned in issue #452
mentioned in issue #381
mentioned in merge request !981
Took this one. Added
assert_pair_in_registryto bothexecute_set_pair_limit_batch_maxandexecute_set_pair_limit_clean_config, right afteraddr_validate, matching the pattern inexecute_set_pair_fee. Also fixed a stale doc comment on the batch-max fn (it had theupdate_configblurb).So governance can no longer dispatch
UpdateLimitOrderConfig/UpdateLimitCleanConfigat an arbitrary valid-but-unregistered address — same uniform guard as every other single-pair admin fn now.Tests (new in
pair_addr_registry_tests):set_pair_limit_batch_max_rejects_unregistered_pair-> PairNotInRegistryset_pair_limit_clean_config_rejects_unregistered_pair-> PairNotInRegistryset_pair_limit_config_accepts_registered_pair-> both succeed against a registered pairfactory lib 5/0, full smartcontracts workspace 460/0.
MR !981, branch
qa/455-factory-registry-guard, commitf481b2b4. Needs your review/merge @PlasticDigits — leaving it open for verification.mentioned in commit
e242a3abd1Verification complete — all criteria PASS
Verified on
mainat merge commite242a3ab(MR !981,f481b2b4).Checklist
assert_pair_in_registryinexecute_set_pair_limit_batch_maxafteraddr_validatecontract.rs:725-726—addr_validatethenassert_pair_in_registryassert_pair_in_registryinexecute_set_pair_limit_clean_configafteraddr_validatecontract.rs:752-753— same pattern asexecute_set_pair_feeSetPairLimitBatchMax/SetPairLimitCleanConfigon non-registered address returns errorset_pair_limit_batch_max_rejects_unregistered_pairandset_pair_limit_clean_config_rejects_unregistered_pairboth assertContractError::PairNotInRegistryset_pair_limit_config_accepts_registered_pair— both fns succeed whenPAIR_ADDR_REGISTEREDis setmake test-contracts— factory lib 5/0, full smartcontracts workspace 460/0Commands
Notes
Fix restores uniform registry guard across all single-pair factory admin functions. Practical impact remains low (governance-only), but the inconsistency and discoverability gap from SEC-I03 F01 are resolved.
Closing as verified.
mentioned in issue #337