Security: no post-deploy script cross-checks frontend and indexer env addresses against on-chain contract config [SEC-H04] #442
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#442
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
scripts/deploy-dex-local.shwritesfrontend-dapp/.env.localandindexer/.envfrom the just-deployed contract addresses, so they match at the moment of writing for LocalTerra. However, no script performs a subsequent comparison of all address fields in the env files (FACTORY_ADDRESS, ROUTER_ADDRESS, FEE_DISCOUNT_ADDRESS, and their VITE_ counterparts) against what the on-chain contracts report as their own config.scripts/qa/verify-deploy.shreads FACTORY_ADDRESS from the env and uses it to query the chain, but only does schema probes and does not cross-check ROUTER, FEE_DISCOUNT, or any VITE_ address variable against chain state. For staging and mainnet, env files are configured manually, so drift between env files and on-chain addresses is not detected.What Was Checked
scripts/deploy-dex-local.shlines 938-998: writesfrontend-dapp/.env.localandindexer/.envfrom deployed addresses at write time. Confirmed these variables are written:VITE_FACTORY_ADDRESS,VITE_ROUTER_ADDRESS,VITE_FEE_DISCOUNT_ADDRESS,FACTORY_ADDRESS,ROUTER_ADDRESS.scripts/qa/verify-deploy.shlines 75-165: reads FACTORY_ADDRESS from indexer/.env or frontend-dapp/.env.local; uses it to query the factory; runs pair schema probes. Does not compare ROUTER_ADDRESS or FEE_DISCOUNT_ADDRESS or any VITE_ var against on-chain state.docs/deployment-guide.mdlines 114-160: post-deployment checklist is entirely manual terrad query commands. No script compares env to chain output.scripts/qa/orscripts/performs a systematic env-to-chain address comparison.Expected (per checklist)
A post-deploy script reads all address fields from both env files (frontend-dapp/.env.local and indexer/.env), queries the on-chain config for each address (factory get_config for governance/treasury, router config for factory, fee-discount config for governance), and asserts that the addresses match what is reported by the chain.
Actual
No such comparison script exists. For LocalTerra the env files are written by the deploy script and match by construction. For staging and mainnet, env files are maintained manually and address drift is undetected unless the operator runs manual queries.
Evidence
scripts/qa/verify-deploy.shin full: uses FACTORY from env to query chain but only does schema probes; does not compare ROUTER or FEE_DISCOUNT addresses against on-chain valuesscripts/deploy-dex-local.shlines 938-998: writes env files but no post-write verification step queries chain to confirm values matchSuggested Fix
Add a
scripts/qa/verify-env-addresses.shthat: (1) reads FACTORY_ADDRESS, ROUTER_ADDRESS, FEE_DISCOUNT_ADDRESS from both env files and asserts they match each other; (2) queries factoryget_configand asserts the on-chain factory address equals FACTORY_ADDRESS; (3) queries routerconfigand asserts its factory field equals the env FACTORY_ADDRESS; (4) queries fee-discount config and asserts its governance field is non-empty. Wire this intomake verify-deployand add a step todocs/runbooks/launch-checklist.mdPhase 4 requiring it before go/no-go sign-off.Verification Checklist
docs/runbooks/launch-checklist.mdPhase 4 requires this comparison before go/no-go sign-offLabels
security,pre-launchCc: @PlasticDigits
mentioned in issue #381
mentioned in commit
8f5db8bccfmentioned in merge request !977
Went through the SEC-H04 env/chain address cross-check (
8f5db8bc, !977) — verified the script against the current deploy, including the drift-detection path.make verify-issue-442→ 7/7 PASS, with the liveqa-verify-env-addressesat 14 checks / 0 failures. It does what the issue asked:Checked the failure path too, not just the happy one: pointed both env files' FACTORY at a real-but-non-factory address (so env parity still passes) and the on-chain cross-check caught the drift two ways — the factory config query failed, and router.config.factory (the real factory) didn't match the tampered env value → RESULT FAIL, exit nonzero. So it genuinely cross-checks env against chain, which is the whole point of SEC-H04.
cannot_be_merged right now is just the Makefile .PHONY/target-list rebase (the same line every SEC-H MR appends to; branch base is behind current main) — verify-deploy.sh and the docs merge clean. Good to merge / good to close from my side once it's rebased.
@PlasticDigits
mentioned in commit
96f0f8514eVerification — SEC-H04 env/chain address cross-check (MR !977 / #442)
Verified at
8f5db8bcon fresh LocalTerra deploy (make setup-cloud-localterra --fresh --skip-build).Acceptance criteria (#442)
make qa-verify-env-addresses— 14 checks / 0 failures: env parity (FACTORY, ROUTER, FEE_DISCOUNT), factoryconfig, routerconfig.factory, fee-discountconfig.governanceVITE_FACTORY_ADDRESSto router addr viaVERIFY_ENV_FRONTEND_FILE=…→FACTORY (indexer == frontend)FAIL, exit 1launch-checklist.mdPhase 4 requires comparison before go/no-gogrep verify-env-addresses docs/runbooks/launch-checklist.md;make check-deploy-env-addresses-docsVerification checklist
make verify-issue-442(full runner)make test-qa-verify-env-addressesmake qa-verify-deploywires env check after Q1skills/AGENTS_DEPLOY_ENV_ADDRESSES_VERIFY.md,docs/qa-invariants.md.env==frontend-dapp/.env.localfor all three addressesNotes
test1uluna after partial deploy);--freshreset resolved it — same class of bot-swarm / stale-volume issue called out in othere2e-txrunbooks.Good to close #442 from QA.
Verification complete — SEC-H04 / #442
Verified on
main@96f0f851after fresh LocalTerra deploy (./scripts/setup-cloud-agent-localterra.sh --fresh --skip-build).Acceptance criteria
make qa-verify-env-addresses— 14 checks / 0 failures: [1/4] env parity (FACTORY, ROUTER, FEE_DISCOUNT indexer ↔ frontend VITE_*); [2/4] factoryconfigat FACTORY_ADDRESS; [3/4] routerconfig.factory== env FACTORY; [4/4] fee-discountconfig.governanceRESULT: FAIL, exit 1docs/runbooks/launch-checklist.mdPhase 4 requires this before go/no-goverify-env-addresses.sh/make qa-verify-env-addresses; doc invariantmake check-deploy-env-addresses-docsOKRegression suite
make verify-issue-442→ 7/7 PASS (doc invariant, script present, agent skill, launch runbook wiring,verify-deploy.shintegration, unit tests, live LocalTerra).Wiring confirmed
scripts/qa/verify-env-addresses.sh— SEC-H04 cross-check implementationscripts/qa/verify-deploy.sh— invokes env address check after schema/stamp probesskills/AGENTS_DEPLOY_ENV_ADDRESSES_VERIFY.md— agent playbook presentNo repo changes required; implementation from !977 is complete and verified.
mentioned in issue #446
mentioned in issue #451
mentioned in issue #477