security(bridge-debt): pin each market independently and bound issuer upgrade authority #1393

Closed
opened 2026-10-04 12:38:13 +00:00 by PlasticDigits · 2 comments
Owner

Summary and severity

Medium live-market availability; conditional privileged economic risk. Global receipt-policy changes can halt repayment on existing live markets, and upgrade/issuance authority needs explicit market-level containment.

Internal review references: KIMIK3 BD-1/2/3/4/7; SBHIGH-15/16; chains F/U. Investigated against source revision 748579ab718026efad54afcef4b2a5186fe82662 on 2026-10-04. These are engineering findings, not third-party audit certification. Only technical findings and synthetic test cases are included; no conversation, user identity, credentials or real-user activity is published.

Current codebase and evidence

Owner can overwrite the one global debt_code_id. inspect_debt_token compares every existing receipt to that current value on each Issue/Repay, so selecting a code for a new market invalidates old markets. Market stores no receipt/underlying code pins. Underlying validation checks only TokenInfo/decimals; issuance relies on Mint execution to fail if permissions are absent. Both issuer/receipt migrate handlers only stamp cw2. Owner transfer is immediate, and Issue has no per-market amount/epoch ceiling.

Correction: a bare owner equality check supports a multisig address; the other audit reports the live owner/admin as 2-of-3. Treat compromise as privileged and do not label the current deployment a confirmed single-EOA owner. The governance controller already has underlying mint powers, so this is additional liveness/accounting containment, not newly discovered outsider mint authority.

Why a new implementation is needed

Global receipt-policy changes can halt repayment on existing live markets, and upgrade/issuance authority needs explicit market-level containment.

Constraints and guardrails

  • Preserve outstanding == receipt supply, mint only to configured debtor, nontransferability, atomic burn/mint and permissionless beneficial repayment.
  • Never freeze repayment merely because future registration policy changed. Backfill pins from verified existing contracts; do not silently bless arbitrary live code.
  • No claims that advisory $1 equals redeemable reserve backing or that source code enforces a particular owner signer count.

Relevant files

  • Store approved receipt identity per market; future registration defaults must not invalidate previous Issue/Repay. Provide an explicit coordinated market upgrade path.
  • Attest and pin approved underlying implementation/minter behavior and recheck before privileged operations, preserving a safe repayment strategy across approved migrations.
  • Add contract-name/version-aware migration guards, state-preserving backfill and propose/accept owner transfer.
  • Define bounded market issuance/circuit-breaker controls and document governance/migrate powers, custody and display-only advisory valuation. Limits constrain the issuer, not all underlying minters.

Acceptance criteria

  • After default code rotation and second-market registration, every existing valid market can still Issue/Repay under its own pin.
  • Unauthorized or inconsistent receipt/underlying mutations fail atomically; approved upgrades preserve supply/debtor/outstanding and repayment.
  • Wrong-contract/newer-version migrations fail; current storage migrates without loss. Owner transfer needs recipient acceptance.
  • Configured issuance limits reject excess while repay/recovery policy and governance residual powers are explicit.

Test plan: supported and failure paths

  • Use two real synthetic debt markets with different receipt code IDs: issue both, rotate default, repay both, upgrade one and recheck the other.
  • Test same/older/newer/foreign cw2, pin backfill, failed migration, owner propose/cancel/accept, zero/overflow amount, partial/full repayment and recovery.
  • Run cargo test -p bridge-debt -p bridge-debt-token, full contracts and optimized LocalTerra issue/repay smoke.

Test plan: attack, hack and abuse vectors

  • Register TokenInfo-spoof/non-CW20 underlying, wrong minter/debtor/additional minters, duplicate receipt, supply mismatch and migrated receipt/underlying.
  • Attempt arbitrary outsider Issue/owner update, privileged mint-cap exhaustion/reset and dump simulation using synthetic pools; never exercise live mint privileges.
  • Fail one mint/burn leg and confirm outstanding, balances and supply all roll back; do not allow recovery to bypass debt accounting.

Verification criteria

  • Global pin rotation, underlying TokenInfo-only validation and migration/owner handlers are source-confirmed. Current contract tests passed in the baseline.
  • Require both-market rotation regression, full supply-ledger reconciliation and live read-only custody/code-hash inventory before reporting deployed acceptance.
    Record revision, UTC time, exact commands, outcomes and evidence scope. Complete runnable checks first. Unavailable signing, deployment, device or infrastructure checks must be explicitly recorded as unverified; they do not block filing or implementation. An executed failure remains FAIL. Never claim deployment acceptance from unit tests or read-only probes. Public receipts must use synthetic identities and omit secrets.

1392: chain-trust, 1398: economic-guards. Each report owns its stated acceptance scope.

## Summary and severity Medium live-market availability; conditional privileged economic risk. Global receipt-policy changes can halt repayment on existing live markets, and upgrade/issuance authority needs explicit market-level containment. Internal review references: KIMIK3 BD-1/2/3/4/7; SBHIGH-15/16; chains F/U. Investigated against source revision `748579ab718026efad54afcef4b2a5186fe82662` on 2026-10-04. These are engineering findings, not third-party audit certification. Only technical findings and synthetic test cases are included; no conversation, user identity, credentials or real-user activity is published. ## Current codebase and evidence Owner can overwrite the one global debt_code_id. inspect_debt_token compares every existing receipt to that current value on each Issue/Repay, so selecting a code for a new market invalidates old markets. Market stores no receipt/underlying code pins. Underlying validation checks only TokenInfo/decimals; issuance relies on Mint execution to fail if permissions are absent. Both issuer/receipt migrate handlers only stamp cw2. Owner transfer is immediate, and Issue has no per-market amount/epoch ceiling. Correction: a bare owner equality check supports a multisig address; the other audit reports the live owner/admin as 2-of-3. Treat compromise as privileged and do not label the current deployment a confirmed single-EOA owner. The governance controller already has underlying mint powers, so this is additional liveness/accounting containment, not newly discovered outsider mint authority. ## Why a new implementation is needed Global receipt-policy changes can halt repayment on existing live markets, and upgrade/issuance authority needs explicit market-level containment. ## Constraints and guardrails - Preserve outstanding == receipt supply, mint only to configured debtor, nontransferability, atomic burn/mint and permissionless beneficial repayment. - Never freeze repayment merely because future registration policy changed. Backfill pins from verified existing contracts; do not silently bless arbitrary live code. - No claims that advisory $1 equals redeemable reserve backing or that source code enforces a particular owner signer count. ## Relevant files - [smartcontracts/contracts/bridge-debt/src/contract.rs](https://git.cl8y.com/code/cl8y-dex-terraclassic/src/commit/748579ab718026efad54afcef4b2a5186fe82662/smartcontracts/contracts/bridge-debt/src/contract.rs) - [smartcontracts/contracts/bridge-debt/src/state.rs](https://git.cl8y.com/code/cl8y-dex-terraclassic/src/commit/748579ab718026efad54afcef4b2a5186fe82662/smartcontracts/contracts/bridge-debt/src/state.rs) - [smartcontracts/contracts/bridge-debt/src/msg.rs](https://git.cl8y.com/code/cl8y-dex-terraclassic/src/commit/748579ab718026efad54afcef4b2a5186fe82662/smartcontracts/contracts/bridge-debt/src/msg.rs) - [smartcontracts/contracts/bridge-debt-token/src/contract.rs](https://git.cl8y.com/code/cl8y-dex-terraclassic/src/commit/748579ab718026efad54afcef4b2a5186fe82662/smartcontracts/contracts/bridge-debt-token/src/contract.rs) - [docs/runbooks/deploy-usdt-ust1-lp.md](https://git.cl8y.com/code/cl8y-dex-terraclassic/src/commit/748579ab718026efad54afcef4b2a5186fe82662/docs/runbooks/deploy-usdt-ust1-lp.md) - [scripts/deploy-usdt-ust1-lp.sh](https://git.cl8y.com/code/cl8y-dex-terraclassic/src/commit/748579ab718026efad54afcef4b2a5186fe82662/scripts/deploy-usdt-ust1-lp.sh) ## Recommended direction - Store approved receipt identity per market; future registration defaults must not invalidate previous Issue/Repay. Provide an explicit coordinated market upgrade path. - Attest and pin approved underlying implementation/minter behavior and recheck before privileged operations, preserving a safe repayment strategy across approved migrations. - Add contract-name/version-aware migration guards, state-preserving backfill and propose/accept owner transfer. - Define bounded market issuance/circuit-breaker controls and document governance/migrate powers, custody and display-only advisory valuation. Limits constrain the issuer, not all underlying minters. ## Acceptance criteria - [ ] After default code rotation and second-market registration, every existing valid market can still Issue/Repay under its own pin. - [ ] Unauthorized or inconsistent receipt/underlying mutations fail atomically; approved upgrades preserve supply/debtor/outstanding and repayment. - [ ] Wrong-contract/newer-version migrations fail; current storage migrates without loss. Owner transfer needs recipient acceptance. - [ ] Configured issuance limits reject excess while repay/recovery policy and governance residual powers are explicit. ## Test plan: supported and failure paths - Use two real synthetic debt markets with different receipt code IDs: issue both, rotate default, repay both, upgrade one and recheck the other. - Test same/older/newer/foreign cw2, pin backfill, failed migration, owner propose/cancel/accept, zero/overflow amount, partial/full repayment and recovery. - Run cargo test -p bridge-debt -p bridge-debt-token, full contracts and optimized LocalTerra issue/repay smoke. ## Test plan: attack, hack and abuse vectors - Register TokenInfo-spoof/non-CW20 underlying, wrong minter/debtor/additional minters, duplicate receipt, supply mismatch and migrated receipt/underlying. - Attempt arbitrary outsider Issue/owner update, privileged mint-cap exhaustion/reset and dump simulation using synthetic pools; never exercise live mint privileges. - Fail one mint/burn leg and confirm outstanding, balances and supply all roll back; do not allow recovery to bypass debt accounting. ## Verification criteria - Global pin rotation, underlying TokenInfo-only validation and migration/owner handlers are source-confirmed. Current contract tests passed in the baseline. - Require both-market rotation regression, full supply-ledger reconciliation and live read-only custody/code-hash inventory before reporting deployed acceptance. Record revision, UTC time, exact commands, outcomes and evidence scope. Complete runnable checks first. Unavailable signing, deployment, device or infrastructure checks must be explicitly recorded as unverified; they do not block filing or implementation. An executed failure remains FAIL. Never claim deployment acceptance from unit tests or read-only probes. Public receipts must use synthetic identities and omit secrets. ## Related remediation reports [1392: chain-trust](https://git.cl8y.com/code/cl8y-dex-terraclassic/issues/1392), [1398: economic-guards](https://git.cl8y.com/code/cl8y-dex-terraclassic/issues/1398). Each report owns its stated acceptance scope.
Author
Owner

Merge sweep 2026-10-05: the two existing October 4 audit reports are being preserved on main with the sanity receipt. They document findings; committing them does not implement remediation.

Remaining implementation: Pin bridge-debt markets independently and constrain issuer upgrade behavior. No bridge-debt contract changes are included in this merge. This issue stays open for that substantive work, not merely a verification hold.

Merge sweep 2026-10-05: the two existing October 4 audit reports are being preserved on main with the sanity receipt. They document findings; committing them does not implement remediation. Remaining implementation: Pin bridge-debt markets independently and constrain issuer upgrade behavior. No bridge-debt contract changes are included in this merge. This issue stays open for that substantive work, not merely a verification hold.
Author
Owner

PR #1411 and the final integration PR #1423 are merged into main. Source acceptance: 944 contract tests + strict all-target Clippy, 858 indexer tests across 29 suites, and 3,093 frontend tests + lint/build. Fresh pinned optimizer verification passed. Full receipt.

Independent market pins and issuance controls passed the integrated 944-test workspace and strict Clippy. make verify-issue-1393 passed 9/9, including two optimized LocalTerra market/repayment/upgrade rehearsals.

CI was skipped by explicit operator instruction. Native wrap-stack and production execution remain explicitly unverified. Deployment/history/release work is transferred to #1421 and existing #1384/#1385/#1386; the default query-gas repair is #1422. The source issue is complete and carries no verification-only hold; closure does not claim production deployment.

PR #1411 and the final integration PR #1423 are merged into main. Source acceptance: 944 contract tests + strict all-target Clippy, 858 indexer tests across 29 suites, and 3,093 frontend tests + lint/build. Fresh pinned optimizer verification passed. [Full receipt](https://git.cl8y.com/code/cl8y-dex-terraclassic/src/branch/main/docs/qa/merge-2026-10-06/README.md). Independent market pins and issuance controls passed the integrated 944-test workspace and strict Clippy. make verify-issue-1393 passed 9/9, including two optimized LocalTerra market/repayment/upgrade rehearsals. CI was skipped by explicit operator instruction. Native wrap-stack and production execution remain explicitly unverified. Deployment/history/release work is transferred to #1421 and existing #1384/#1385/#1386; the default query-gas repair is #1422. The source issue is complete and carries no verification-only hold; closure does not claim production deployment.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
code/cl8y-dex-terraclassic#1393
No description provided.