<!-- XE-1849 · `marshalCanonical` silently defaults missing lease numeric fields to zero instead of erroring — a hand-built lease block encodes a value the caller never set · testnet -->
*Markdown view of <https://bounty.xe.network/XE-1849>. The page is the record; this is the same page for reading.*

XE-1849 · Bounty

# \`marshalCanonical\` silently defaults missing lease numeric fields to zero instead of erroring — a hand-built lease block encodes a value the caller never set

Triaging
claimed Minor
web
filed 2026-11-09 07:57 UTC
by Darkarmy921

Verdict
:   published when the fix ships

Tier
:   published when the fix ships

Claimed
:   Minor

Area
:   SDK / docs / web

Duplicate of
:   —

Tracked
:   —

Updated
:   2026-11-14 22:57 UTC

Told
:   2026-11-10 14:00 UTC

### Patches

None linked.

### History

- [211825](https://bounty.xe.network/log/211825) 2026-11-14 22:57 UTC proposal.adopted
- [211824](https://bounty.xe.network/log/211824) 2026-11-14 22:57 UTC ticket.award
- [84114](https://bounty.xe.network/log/84114) 2026-11-10 14:00 UTC proposal.adopted
- [84113](https://bounty.xe.network/log/84113) 2026-11-10 14:00 UTC reply.sent
- [83976](https://bounty.xe.network/log/83976) 2026-11-10 14:00 UTC proposal.adopted
- [83975](https://bounty.xe.network/log/83975) 2026-11-10 14:00 UTC ticket.status new → triaging
- [83665](https://bounty.xe.network/log/83665) 2026-11-10 14:00 UTC proposal.adopted
- [83664](https://bounty.xe.network/log/83664) 2026-11-10 14:00 UTC proposal.adopted
- [83663](https://bounty.xe.network/log/83663) 2026-11-10 14:00 UTC ticket.facts
- [83662](https://bounty.xe.network/log/83662) 2026-11-10 14:00 UTC proposal.adopted
- [83661](https://bounty.xe.network/log/83661) 2026-11-10 14:00 UTC ticket.facts
- [83660](https://bounty.xe.network/log/83660) 2026-11-10 14:00 UTC proposal.adopted

[Full history](https://bounty.xe.network/log?ref=XE-1849) · [JSON](https://bounty.xe.network/v1/tickets/XE-1849) · [markdown](https://bounty.xe.network/XE-1849.md)

### Report

## 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

## Summary

`marshalCanonical` uses `required()` for `send` (destination, amount)
and `burn` (amount), but the lease-family tails use `u64(value ?? 0n)`,
which silently substitutes zero for a missing field. A hand-built
`lease_accept`, `lease_settle`, `lease_renew` or `lease` block with a
missing `amount`, `duration`, `lockedR`, `lockedPayoutCap`,
`lockedTwap`, `vcpus`, `memoryMb` or `diskGb` encodes successfully —
and a missing amount encodes **identically to an explicit amount of
zero**. The block is then signed and PoW'd (via the exposed
`Xe.submit()`, documented "for callers building a block by hand") and
rejected by the node, which expects the real lease cost / duration.

## Impact

- **Silent value substitution in the encoder.** The caller asks to
  encode a block without an amount and gets a block *with* amount 0 —
  the encoder invents a value instead of refusing. Any caller building
  lease-family blocks by hand and omitting a field gets a doomed block
  after paying the PoW cost.
- **Scope limit (stated plainly).** The node's ledger re-validates
  lease amounts/costs/durations, so no invalid lease lands and no
  funds move. Harm is wasted PoW plus a misleading encoding. The
  SDK's own high-level methods (`openLease`, `renewLease`, …) always
  set these fields, so the exposure is to direct `submit()` /
  `marshalCanonical` callers.

## Severity reasoning

- **Low, not Medium:** node backstop holds; no on-chain effect. The
  defect is real — the encoder's own `required()` pattern exists for
  exactly this case and is applied inconsistently — but the trigger
  needs a hand-built block.
- **Low, not Minor:** the inconsistency is inside one function
  (`send`/`burn` require, lease-family defaults), and the missing \=\=
  explicit-zero equivalence means no caller-side check can distinguish
  the two after encoding.

## Root cause

`src/encoding.ts` `marshalCanonical`: the lease tails call
`u64(block.amount)`, `u64(block.duration)`, `u64(block.lockedR)`, …,
where `u64 = (value) => u64be(value ?? 0n)`. Only `source`/`destination`
go through `required()` on these paths.

## Reproduction

Harness `/tmp/sdk-r5/verify.mjs` (section B), no network. Run from the
built SDK:

```
cd ~/workspace/xe-bounty/sdk
node /tmp/sdk-r5/verify.mjs
```

Observed output:

```
PASS 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;
PASS B-control-send-requires-amount
PASS B-missing-equals-zero missing amount == explicit 0
```

What the run shows:

1. `lease_accept`, `lease_settle`, `lease_renew` (no amount/duration/
   locked fields) and `lease` (no dims/duration) all encode without
   error.
2. Control: `send` without `amount` throws `requires amount`.
3. A `lease_accept` with no amount is byte-identical to one with
   `amount: 0n`.

## Dedup note

Checked against the public ticket list (186 public tickets, max
XE-1799, snapshot 2026-11-09 \~14:19 WIB; title sweep). No title match
for `marshalCanonical`, zero-defaults, or missing lease fields.
Closest reports:

- **XE-0464** — "`toWire` silently drops a zero locked\_r, so
  `renewLease` signs a `lease_renew` the node always rejects". A
  different layer (`toWire` wire mapping drops an *explicit* zero)
  from a different cause; this finding is about the *canonical
  encoder* inventing zeros for *missing* fields. The two compose (a
  missing `lockedR` encodes as 0, then `toWire` drops it) but neither
  fix closes the other.
- **SDK-6 / XE-1733** — `receive()` signs an unchecked pending. Same
  family (client builds a block it should have refused), different
  function and trigger.

No known report covers this defect. Private/sealed tickets are
invisible, so a sealed duplicate cannot be ruled out.

## Suggested fix direction

- Use `required()` for the lease-family numeric fields
  (`amount`, `duration`, `lockedR`, `lockedPayoutCap`, `lockedTwap`,
  and the lease dimensions) in `marshalCanonical`, matching `send` /
  `burn` — or document explicitly that missing means zero, if that is
  ever intended (it is not, for `amount`/`duration`).

## Payout address

```
052e33e0ed9c43e2bdf07faff9a90d25642b51d53d96f49f5d45b81f6584b3da
```

## References (file:line; sdk @ 605c20a)

| Location | What it shows |
| --- | --- |
| `src/encoding.ts` (`marshalCanonical`, `u64` helper) | `u64(value ?? 0n)` on lease tails; `required()` only for `source`/`destination` there |
| `src/encoding.ts` (`send`/`burn` tails) | `required(block.amount, …)` — the pattern the lease tails omit |
| `src/xe.ts` (`submit`) | Exposed for hand-built blocks — the reachable caller |
| `/tmp/sdk-r5/verify.mjs` (section B) | Verification harness (ephemeral, see "Reproduction") |

### Thread

**Joseph Denne**team2026-11-10 14:00 UTCdesk

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
