{"id":"XE-1849","kind":"bounty","visibility":"public","source":"web","source_repo":"","source_ref":"","source_url":"","reporter_id":451,"title":"`marshalCanonical` silently defaults missing lease numeric fields to zero instead of erroring — a hand-built lease block encodes a value the caller never set","area":"sdk-docs-web","claimed_tier":"minor","assessed_tier":null,"verdict":null,"duplicate_of":null,"tracked":false,"internal_ref":"","internal_url":null,"status":"triaging","closed_reason":null,"github_state":"","disclosed_at":null,"award_xe":null,"award_approved":false,"paid_ref":"","created_at":"2026-11-09T07:57:20.167910+00:00","updated_at":"2026-11-14T22:57:04.296924+00:00","source_created_at":null,"told_at":"2026-11-10T14:00:35.084995+00:00","status_changed_at":"2026-11-10T14:00:33.371774+00:00","url":"https://bounty.xe.network/XE-1849","body":"## Title\r\n\r\n`marshalCanonical` silently defaults missing lease numeric fields to zero instead of erroring — a hand-built lease block encodes a value the caller never set\r\n\r\n## Summary\r\n\r\n`marshalCanonical` uses `required()` for `send` (destination, amount)\r\nand `burn` (amount), but the lease-family tails use `u64(value ?? 0n)`,\r\nwhich silently substitutes zero for a missing field. A hand-built\r\n`lease_accept`, `lease_settle`, `lease_renew` or `lease` block with a\r\nmissing `amount`, `duration`, `lockedR`, `lockedPayoutCap`,\r\n`lockedTwap`, `vcpus`, `memoryMb` or `diskGb` encodes successfully —\r\nand a missing amount encodes **identically to an explicit amount of\r\nzero**. The block is then signed and PoW'd (via the exposed\r\n`Xe.submit()`, documented \"for callers building a block by hand\") and\r\nrejected by the node, which expects the real lease cost / duration.\r\n\r\n## Impact\r\n\r\n- **Silent value substitution in the encoder.** The caller asks to\r\nencode a block without an amount and gets a block *with* amount 0 —\r\nthe encoder invents a value instead of refusing. Any caller building\r\nlease-family blocks by hand and omitting a field gets a doomed block\r\nafter paying the PoW cost.\r\n- **Scope limit (stated plainly).** The node's ledger re-validates\r\nlease amounts/costs/durations, so no invalid lease lands and no\r\nfunds move. Harm is wasted PoW plus a misleading encoding. The\r\nSDK's own high-level methods (`openLease`, `renewLease`, …) always\r\nset these fields, so the exposure is to direct `submit()` /\r\n`marshalCanonical` callers.\r\n\r\n## Severity reasoning\r\n\r\n- **Low, not Medium:** node backstop holds; no on-chain effect. The\r\ndefect is real — the encoder's own `required()` pattern exists for\r\nexactly this case and is applied inconsistently — but the trigger\r\nneeds a hand-built block.\r\n- **Low, not Minor:** the inconsistency is inside one function\r\n(`send`/`burn` require, lease-family defaults), and the missing ==\r\nexplicit-zero equivalence means no caller-side check can distinguish\r\nthe two after encoding.\r\n\r\n## Root cause\r\n\r\n`src/encoding.ts` `marshalCanonical`: the lease tails call\r\n`u64(block.amount)`, `u64(block.duration)`, `u64(block.lockedR)`, …,\r\nwhere `u64 = (value) => u64be(value ?? 0n)`. Only `source`/`destination`\r\ngo through `required()` on these paths.\r\n\r\n## Reproduction\r\n\r\nHarness `/tmp/sdk-r5/verify.mjs` (section B), no network. Run from the\r\nbuilt SDK:\r\n\r\n```sh\r\ncd ~/workspace/xe-bounty/sdk\r\nnode /tmp/sdk-r5/verify.mjs\r\n```\r\n\r\nObserved output:\r\n\r\n```\r\nPASS B-lease-numerics-default-zero lease_accept-no-amount encodes (186B); lease_settle-no-amount encodes; lease_renew-no-amount/duration encodes; lease-no-dims encodes;\r\nPASS B-control-send-requires-amount\r\nPASS B-missing-equals-zero missing amount == explicit 0\r\n```\r\n\r\nWhat the run shows:\r\n\r\n1. `lease_accept`, `lease_settle`, `lease_renew` (no amount/duration/\r\nlocked fields) and `lease` (no dims/duration) all encode without\r\nerror.\r\n2. Control: `send` without `amount` throws `requires amount`.\r\n3. A `lease_accept` with no amount is byte-identical to one with\r\n`amount: 0n`.\r\n\r\n## Dedup note\r\n\r\nChecked against the public ticket list (186 public tickets, max\r\nXE-1799, snapshot 2026-11-09 ~14:19 WIB; title sweep). No title match\r\nfor `marshalCanonical`, zero-defaults, or missing lease fields.\r\nClosest reports:\r\n\r\n- **XE-0464** — \"`toWire` silently drops a zero locked_r, so\r\n`renewLease` signs a `lease_renew` the node always rejects\". A\r\ndifferent layer (`toWire` wire mapping drops an *explicit* zero)\r\nfrom a different cause; this finding is about the *canonical\r\nencoder* inventing zeros for *missing* fields. The two compose (a\r\nmissing `lockedR` encodes as 0, then `toWire` drops it) but neither\r\nfix closes the other.\r\n- **SDK-6 / XE-1733** — `receive()` signs an unchecked pending. Same\r\nfamily (client builds a block it should have refused), different\r\nfunction and trigger.\r\n\r\nNo known report covers this defect. Private/sealed tickets are\r\ninvisible, so a sealed duplicate cannot be ruled out.\r\n\r\n## Suggested fix direction\r\n\r\n- Use `required()` for the lease-family numeric fields\r\n(`amount`, `duration`, `lockedR`, `lockedPayoutCap`, `lockedTwap`,\r\nand the lease dimensions) in `marshalCanonical`, matching `send` /\r\n`burn` — or document explicitly that missing means zero, if that is\r\never intended (it is not, for `amount`/`duration`).\r\n\r\n## Payout address\r\n\r\n```\r\n052e33e0ed9c43e2bdf07faff9a90d25642b51d53d96f49f5d45b81f6584b3da\r\n```\r\n\r\n## References (file:line; sdk @ 605c20a)\r\n\r\n| Location | What it shows |\r\n|---|---|\r\n| `src/encoding.ts` (`marshalCanonical`, `u64` helper) | `u64(value ?? 0n)` on lease tails; `required()` only for `source`/`destination` there |\r\n| `src/encoding.ts` (`send`/`burn` tails) | `required(block.amount, …)` — the pattern the lease tails omit |\r\n| `src/xe.ts` (`submit`) | Exposed for hand-built blocks — the reachable caller |\r\n| `/tmp/sdk-r5/verify.mjs` (section B) | Verification harness (ephemeral, see \"Reproduction\") |","patch_refs":[],"thread":[{"id":2133,"source":"desk","source_ref":"reply:1500","author":"Joseph Denne","team":true,"body":"Thank you for this report. We have read it against the code and it is being handled. The assessment and any award follow the fix. https://bounty.xe.network/XE-1849","created_at":"2026-11-10T14:00:19.792775+00:00"}]}