[#138] Finding 3: Forge dev scripts — chainid guard (anti mainnet mis-RPC) #141
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#141
Loading…
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?
Parent: Split from #138 — Pre-deploy review pass 2 (Finding 3).
Severity: Medium
Problem
Dev-oriented Foundry scripts run without
block.chainidguards:contracts/script/DeployDev.s.solcontracts/script/DeployKumbayaAnvilFixtures.s.solcontracts/script/AnvilSameBlockDrill.s.solcontracts/script/SimulateAnvilRichState.s.sol(path may vary — confirm repo)DeployDev(representative risks):MockReserveCl8ywith publicmint— unlimited supply if deployed live.One mistaken
--rpc-url+ realPRIVATE_KEYcan broadcast a full dev stack to production.References
contracts/script/DeployDev.s.soland siblings listed abovedocs/operations/final-signoff-and-value-movement.md(gates #55)docs/testing/invariants-and-business-logic.md.cursor/skills/yieldomega-guardrails/SKILL.mdRecommended fix
At the top of each script’s
run():Adjust allowed IDs to match this repo’s documented local + MegaETH testnet/mainnet policy (confirm with
docs/contracts/foundry-and-megaeth.md/ team). Add a one-line comment referencing intentional allowlist.Optional: document in
docs/testing/e2e-anvil.mdor deploy runbooks that production deploys must not use these script names.Acceptance criteria
31337) and approved MegaETH chain IDs from project docs still work.Verification checklist
forge script script/DeployDev.s.solagainst Anvil succeeds.requirewith clear message.forge teststill passes forcontracts/.mentioned in issue #138
mentioned in commit
efeb854610Shipped on
main(mergece71d7f)@brouie please verify when you can — issue stays open per agent runbook.
What changed
contracts/script/DevOnlyChainGuard.sol:assertDevScriptChain()allows 31337 (Anvil), 6343 (MegaETH testnet), 6342 (legacy); reverts on 4326 (MegaETH mainnet), Ethereum 1, and all other chain IDs with messageDevOnlyChainGuard: chain not allowed (31337/6342/6343).run()for:DeployDev,DeployKumbayaAnvilFixtures,AnvilSameBlockDrill,SimulateAnvilRichStatePart1/Part2/Part2EndSaleOnly.contracts/test/DevOnlyChainGuard.t.sol(FOUNDRY_PROFILE=ci forge test— 302 passed in agent run).Docs / cross-links
INV-DEVSCRIPT-141: invariants — §141Checklist for verification
cd contracts && FOUNDRY_PROFILE=ci forge testpasses (includesDevOnlyChainGuardTest).anvilthenforge script script/DeployDev.s.sol --broadcast --rpc-url http://127.0.0.1:8545 --code-size-limit 524288completes (or your usual stack script).forge script script/DeployDev.s.sol -vvv --fork-url https://eth.llamarpc.com(or any RPC with chain id ≠ 31337/6342/6343) should simulate-revert at the guard before any deploy.cast chain-id --rpc-url <megaeth-testnet>returns 6343 — fork/broadcast tests against that ID should pass the guard (still exercise caution with real keys).Parent context: #138 Finding 3.
mentioned in commit
0f7b9a4e34@PlasticDigits — verification PASS on
ce71d7f. walked your checklist:FOUNDRY_PROFILE=ci forge test --match-contract DevOnlyChainGuardTestgreen: 5/5 PASS —allows_anvil(31337),allows_megaeth_testnet(6343),allows_megaeth_testnet_legacy(6342),reverts_mainnet_eth(1),reverts_megaeth_mainnet(4326). full forge suite 310/310 ona421ba1.2-3. live anvil deploy + wrong-chain fork smoke skipped this round (no localnet stack up). guard wiring verified at source:
DeployDev.s.sol:42,DeployKumbayaAnvilFixtures.s.sol:26,AnvilSameBlockDrill.s.sol:35,SimulateAnvilRichState.s.sol:64/135/227(all three Parts).DevOnlyChainGuard.assertDevScriptChain()revertsDevOnlyChainGuard: chain not allowed (31337/6342/6343)on disallowed IDs.the test that matters most for the actual misconfig risk is
reverts_megaeth_mainnet(4326) since that's the realistic 'staging RPC env points at mainnet by mistake' shape. that path reverts cleanly.ready for close on your side.