Skip to content

fix: guard against invalid CBOR in addTransaction and transaction card#227

Merged
QSchlegel merged 1 commit into
preprodfrom
fix/invalid-tx-cbor-211
Apr 23, 2026
Merged

fix: guard against invalid CBOR in addTransaction and transaction card#227
QSchlegel merged 1 commit into
preprodfrom
fix/invalid-tx-cbor-211

Conversation

@QSchlegel
Copy link
Copy Markdown
Collaborator

Summary

Two-part defense against the bug reported in #211, where a transaction added via POST /api/v1/addTransaction with a non-standard 4-element CBOR wrapper was persisted as-is, then later crashed the Transactions page for the wallet — locking up its UTxOs with no way to recover because the Delete button lived on the same page that was crashing.

  • src/pages/api/v1/addTransaction.ts: reject unparseable txCbor (via csl.Transaction.from_hex) and unparseable txJson up front with HTTP 400, so no more malformed rows can be created.
  • src/components/pages/wallet/transactions/transaction-card.tsx: wrap JSON.parse(transaction.txJson) in try/catch. On failure, render a degraded "Unreadable transaction" card that still exposes a Reject & Delete button wired to the existing deleteTransaction mutation, so already-poisoned wallets can recover.
  • Adds src/__tests__/addTransaction.test.ts covering the four new validation branches plus the happy path.

Closes #211

Test plan

  • npx jest src/__tests__/addTransaction.test.ts — 5/5 pass
  • Full npx jest — no new failures introduced (pre-existing unrelated failures in apiSecurity, botBallotsUpsert, governanceActiveProposals, multisigSDK, signTransaction remain)
  • npx tsc --noEmit — no new errors on touched files
  • Manual: POST /api/v1/addTransaction with junk txCbor → 400 {error: "Invalid transaction CBOR: ..."}
  • Manual (preprod): open the Transactions page for a wallet with a known bad row (e.g. cmmoyccbt0003le04veswn9b5, cmmuuxyg40001l204bmcb6jim from Bug: Added transactions via API -> Cannot load 'Transactions' page #211) and confirm the page loads, the bad row shows the degraded card, and Reject & Delete frees its UTxOs.

🤖 Generated with Claude Code

Reject unparseable txCbor/txJson at the addTransaction API boundary so a
malformed 4-element CBOR can never be persisted, and render a degraded
card with a Reject button when an existing row's txJson cannot be
parsed, so a single bad row no longer crashes the whole Transactions
page and locks up its UTxOs.

Closes #211

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@vercel
Copy link
Copy Markdown

vercel Bot commented Apr 23, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
multisig Ready Ready Preview, Comment Apr 23, 2026 0:08am

Request Review

@QSchlegel QSchlegel merged commit 0d16c71 into preprod Apr 23, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant