Fail production frontend builds when VITE_E2E_MOCK_WALLET is set (#327) #500
No reviewers
Labels
No labels
agent:fix_bugfix
agent:fix_conflicts
agent:fix_security
agent:gap_analysis
agent:implement
agent:open_issues
agents
agent:security_audit
agent:verify
area
timecurve
arena
arena-v2
audit
block:feature_review
block:security
bug
contracts
design
devops
docs
documentation
enhancement
epic
feature
frontend
indexer
low priority
megaeth
operations
ops
performance
QA
qa checklist
referrals
removal
security
smart-contracts
tech-debt
testing
time-arena
timecurve
visual-qa
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
code/yieldomega!500
Loading…
Reference in a new issue
No description provided.
Delete branch "issue-327-production-mock-wallet-gate"
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
Implements GitLab #327 (parent #325 audit F-05 recommendation #3): production frontend builds now fail closed when
VITE_E2E_MOCK_WALLET=1would be inlined intodist/.frontend/vite.config.ts— callsassertProductionBuildEnvatvite buildstart; clear error message;ANVIL_E2E=1bypass forscripts/e2e-anvil.shonly.frontend/src/lib/viteProductionEnvGuard.ts— testable guard module + Vitest coverage.scripts/check-frontend-vite-env.sh --production— deploy-script check that rejects mock wallet in merged.env*files.scripts/qa/build-frontend-for-rabby.sh— exports emptyVITE_E2E_MOCK_WALLETso.env.localmock flags cannot leak into Rabby builds.unit-tests→frontend-testjob assertsVITE_E2E_MOCK_WALLET=1 npm run buildexits non-zero.docs/testing/e2e-anvil.md,docs/testing/ci.md,INV-FRONTEND-327-PRODUCTION-MOCK-WALLETin invariants.vite devand Anvil auto-mock withoutVITE_E2E_MOCK_WALLETare unchanged.Acceptance checklist
npm run buildwithVITE_E2E_MOCK_WALLET=1fails with clear errorcd frontend && VITE_CHAIN_ID=31337 VITE_RPC_URL=http://127.0.0.1:8545 VITE_TIME_ARENA_ADDRESS=0x…01 VITE_PODIUM_VAULTS_ADDRESS=0x…02 VITE_REFERRAL_REGISTRY_ADDRESS=0x…03 VITE_E2E_MOCK_WALLET=1 npm run buildbash scripts/e2e-anvil.shbash scripts/qa/build-frontend-for-rabby.sh(needs Anvil stack.env.local).env.localin agent VM; script unchanged + empty export guard).github/workflows/unit-tests.yml→frontend-testmock-wallet stepfrontend/src/wagmi-config.ts+wagmi-config.test.tscd frontend && npm run typecheck && npm run lint && npm testcd frontendwith requiredVITE_*(no mock) →npm run buildbash scripts/check-frontend-vite-env.sh --productionwithVITE_E2E_MOCK_WALLET=1in.env.production.localThird-party verification
issue-327-production-mock-wallet-gate.cd frontend && npm ci && npm run typecheck && npm run lint && npm test→ green.cd frontend && VITE_E2E_MOCK_WALLET=1 npm run build→ must fail before writingdist/.export PATH="$HOME/.foundry/bin:$PATH" && bash scripts/e2e-anvil.sh→ green (mock allowed viaANVIL_E2E=1).bash scripts/qa/build-frontend-for-rabby.shthengrep -rq 'mock({ accounts' frontend/dist/assets/→ no matches.Security review — MR !500
Commit reviewed:
a9bb2e219e5cc3765efcb1a048ce3d2e9b5f5fa2Scope: Production build guard for
VITE_E2E_MOCK_WALLET(frontend/vite.config.ts,viteProductionEnvGuard.ts,scripts/check-frontend-vite-env.sh --production,scripts/qa/build-frontend-for-rabby.sh, CI regression step, docs/invariants).Outcome:
FINDINGS: 0medium+Prior threads: None (first security review on this MR).
Summary
This MR implements fail-closed hardening for audit F-05 (#327): production
vite buildaborts whenVITE_E2E_MOCK_WALLET=1would be inlined, with a documentedANVIL_E2E=1bypass forscripts/e2e-anvil.shonly. The Rabby build script change (export VITE_E2E_MOCK_WALLET=instead ofunset) correctly prevents.env.localmock flags from overriding the guard via Vite’sprocess.envprecedence.Review traced attacker-controlled inputs to sinks:
command === "build"+VITE_E2E_MOCK_WALLET=1;wagmi-config.tsonly enables mock on strict=== "1"; productionimport.meta.env.DEVis false so dev auto-mock path is inactiveANVIL_E2E=1bypass.env*files); requires build-environment control — not an external attack pathVerified locally:
VITE_E2E_MOCK_WALLET=1 npm run buildfails; empty-export Rabby-style build succeeds without inlining mock;ANVIL_E2E=1+ mock allows E2E build as designed.Security review: no medium+ findings on this diff.
mentioned in commit
ecb17aad3c