feat(security): C-1 — verify InstantWithdrawCw20 wire format vs ustr-cmm treasury schema #21
Labels
No labels
enhancement
governance
QA
testing
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
code/ust1-window#21
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?
Summary
Close C-1 from
audits/INTERNAL_KIMIK3_1786162831.md: makeust1-window'sInstantWithdrawCw20wire format a cross-repo verified contract against finalustr-cmmtreasury schema, not a self-referential local stub.Audit ref: C-1 / TEST-1 / SC-7
Depends on: PlasticDigits2/ustr-cmm#6 (final msg schema frozen)
Related: #20 (withdraw path that introduced this client)
Current codebase
contracts/ust1-window/src/treasury.rsTreasuryExecuteMsg::InstantWithdrawCw20 { recipient, token, amount }viacw_serde; only schema check is serialize-against-selfcontracts/ust1-window/src/multitest.rssmartcontracts-terraclassic/tests/src/stub_treasury.rsdeny_unknown_fields; forwards-compatible by designCargo.lock)InstantWithdrawCw20until ustr-cmm#6 mergesterra1zxwp…SetCw20SpenderProblem: The only schema authority in this repo is the window's own type + a permissive stub. Any final treasury field rename, casing change, or enum layout difference bricks every mainnet withdraw (fail-closed — no theft — but redemption dead until emergency migrate).
Why this is needed
SetCw20Spender; schema conformance is a necessary but not sufficient gate before announcing redeem.Constraints / guardrails
deny_unknown_fields/ equivalent).ustr-cmm(or published JSON schema artifact), not a floating branch tip in CI without lock.ExecuteMsg(only InstantWithdrawCw20) — do not import the full treasury crate into the window wasm unless size/compile cost is acceptable.cmm-treasurywasm when available; stub remains for fast unit tests only and must stay byte-compatible.min_vfdusd_outin this issue.Relevant files
contracts/ust1-window/src/treasury.rs— client msg + buildercontracts/ust1-window/src/multitest.rs— in-crate stubsmartcontracts-terraclassic/tests/src/stub_treasury.rs— integration stubsmartcontracts-terraclassic/tests/src/integration_tests.rs— prefer real treasury wasm pathCargo.toml/Cargo.lock— ustr-cmm pin if shared types useddocs/DEPLOYMENT.md— post-migrate withdraw probe checklist.gitlab-ci.ymland/or.github/workflows/ci.yml) — cross-repo schema jobRecommended direction
ustr-cmm#6rev, export/generate treasury JSON schema (or compile treasury msg types) and add a CI/unit test thatwindow::TreasuryExecuteMsg::InstantWithdrawCw20serializes byte-for-byte to the treasury's expected variant.deny_unknown_fields(or matching strictness) on stubs so misspelled/extra fields fail like production.ignoreif artifact unavailable offline; required in CI when network/cache allows).DEPLOYMENT.md.Acceptance criteria
Test plan (all paths)
Uint128).Test plan (attack / hack / abuse vectors)
token/amount/recipient→ both stub and real treasury reject; window never builds incomplete msgs.Verification criteria
cargo test(window + integration) green with strict stubs.mentioned in commit 7021c8661d568f3c0f3c717af5f5219c09257484
mentioned in merge request !42
mentioned in merge request !43
MR verification (issue #21 / !43)
Verdict: FAIL→FIXING (CI) — implementation complete locally; GitLab pipeline blocked merge.
Local tests (tip
7021c86+)cargo test -p ust1-window --lib— 20/20 ✅cargo test -p ust1-integration-tests --lib— 19/19 ✅scripts/verify_treasury_wire_schema.sh— ✅ (golden matches ustr-cmm @e6c4b7cf)AC status
All five acceptance criteria appear satisfied in code and tests.
CI failure (pipeline 2742608719, job
rust)rust:1.85-bookwormprovides rustc 1.85.1, butCargo.lockrequires ≥1.86 (icu_*@2.2.0) and ≥1.88 (time@0.3.47). Compilation aborted beforecargo test.Fix applied: bump GitLab CI image to
rust:1.88-bookwormon the MR branch.Ops follow-up (out of scope)
Live withdraw probe after migrate +
SetCw20Spenderper DEPLOYMENT.md Phase 5.mentioned in commit d8fa2081b7bccc744fd2ce0a77daa18fe826b304
mentioned in commit
6a946fb870Follow-up: CI fixes on !43
After rebase onto merged !37/!40/!35/!41:
rust:1.85-bookworm→rust:1.88-bookworm(Cargo.lock MSRV).cargo fmtsocargo fmt --checkpasses.redundant_localsinoracle-serviceconsensus tests (let rate = rate/let url = url) that-D warningsrejects in the newrustCI job.Local gate before push:
cargo fmt --check,cargo clippy --all-targets -- -D warnings, window/integration/oracle-service tests green.mentioned in commit
a26793150eMR !43 merged
CI is green (
rust:1.88-bookworm+ fmt/clippy/tests +verify_treasury_wire_schema.sh) and !43 is merged intomain.Remaining ops follow-up (out of MR scope): live withdraw probe after migrate +
SetCw20Spenderper DEPLOYMENT.md Phase 5.