Pre-launch[SEC-I02 (H14)] : FACTORY_ADDRESS non-empty not enforced when RUN_MODE is not prod [SEC-I01] #451
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#451
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?
changed title from
Pre-launch: FACTORY_ADDRESS non-empty not enforced when RUN_MODE is not prodtoPre-launch[SEC-I02 (H14)] : FACTORY_ADDRESS non-empty not enforced when RUN_MODE is not prod [SEC-I01]changed the description
Summary
The indexer skips factory provenance checks when FACTORY_ADDRESS is empty. The verify_factory_provenance function in
pair_discovery.rs(lines 163-168) logs a warning and returns Ok(()) without checking the factory, meaning any contract emitting swap events is indexed without validation. RUN_MODE=prod enforces a non-empty FACTORY_ADDRESS, but staging and QA deployments that do not set RUN_MODE=prod can ship with FACTORY_ADDRESS="" and silently index unverified pairs, including attacker-controlled clone contracts.What Was Checked
indexer/src/indexer/pair_discovery.rslines 163-168:if factory_addr.is_empty() { tracing::warn!(...); return Ok(()); }-- provenance check is entirely skipped when FACTORY_ADDRESS is empty.docs/operator-secrets.mdlines 35-38: RUN_MODE=prod requires non-empty FACTORY_ADDRESS. No equivalent guard for non-prod RUN_MODE.Expected (per checklist)
The indexer refuses to start or logs a startup error that fails the deploy if FACTORY_ADDRESS is empty, regardless of RUN_MODE. Alternatively, the post-deploy verification script or launch-checklist includes an explicit step asserting FACTORY_ADDRESS is non-empty before the indexer is considered healthy.
Actual
FACTORY_ADDRESS="" is silently accepted in non-prod RUN_MODE. Only a log warning is emitted at discovery time, not at startup.
Suggested Fix
Add a startup assertion in the indexer config validation (independent of RUN_MODE) that logs a prominent error and refuses to process blocks if FACTORY_ADDRESS is empty. Alternatively, add an explicit pre-flight check to
scripts/qa/verify-deploy.shanddocs/runbooks/launch-checklist.mdPhase 0 that confirms FACTORY_ADDRESS is non-empty before the deployment is marked healthy.Verification Checklist
Cc: @PlasticDigits
mentioned in issue #381
mentioned in merge request !983
Fixed. FACTORY_ADDRESS empty was only rejected under RUN_MODE=prod, so a staging/QA indexer with FACTORY_ADDRESS="" would sail past and
verify_factory_provenanceskips the provenance check — indexing unverified (possibly spoofed clone) pairs.Now it's a hard config error in EVERY run mode (
ConfigError::EmptyFactoryAddress), checked before the prod block, so the indexer refuses to start with an empty/whitespace factory address regardless of RUN_MODE.Test:
empty_factory_address_rejected_in_dev(whitespace FACTORY_ADDRESS in dev -> EmptyFactoryAddress). indexer lib 167/0.Shipped together with #458 (the other config.rs finding) in MR !983, branch
qa/451-458-indexer-config-guards, commit6ae40413. Needs review/merge @PlasticDigits — leaving open for verification.mentioned in issue #458
mentioned in commit
d326a2e188mentioned in commit
0529634a84mentioned in merge request !996
mentioned in commit
b5752c20c5mentioned in commit
9b98249d3bmentioned in merge request !997
Verification — #451 (SEC-I02 / H14): FACTORY_ADDRESS non-empty guard
Verified on
main@772a7dec(includes fix from MR !983 /6ae40413).Acceptance criteria
FACTORY_ADDRESSin everyRUN_MODEmake verify-issue-451(8/8); unit testempty_factory_address_rejected_in_dev; manual:RUN_MODE=dev FACTORY_ADDRESS=""→ exit 1, messageFACTORY_ADDRESS must be non-empty in every RUN_MODE; whitespace-only also rejected at startupFACTORY_ADDRESSnon-emptyscripts/qa/verify-deploy.shexits 1 withFACTORY_ADDRESS not foundwhen unset; covered bymake verify-issue-451grep checkFACTORY_ADDRESSpreconditiondocs/runbooks/launch-checklist.md— Indexer FACTORY_ADDRESS (SEC-I02) checkbox;make check-factory-address-docsOKFACTORY_ADDRESSbefore indexertest-indexer-librunscargo test --lib(includes config guard); operator docs (docs/operator-secrets.md,docs/qa-invariants.mdQ5) and agent skillskills/AGENTS_FACTORY_ADDRESS_GUARD.mdCommands run
Implementation confirmed
indexer/src/config.rs: unconditionalConfigError::EmptyFactoryAddresswhenfactory_address.trim().is_empty()(before prod-only block).pair_discovery.rswarn-and-skip branch is documented as unreachable in normal operation once startup guard is in place.No repo changes required for verification. Closing as verified.
mentioned in issue #447
mentioned in issue #337
mentioned in commit
9ff4ea7b60mentioned in merge request !1007