SDK toAddress accepts any 64-hex with no checksum so a typo destination is silent
Report
Summary
toAddress is the SDK gate that every send and lease destination is supposed to pass before the wallet will sign. At sdk/src/types.ts:24-35 it only runs assertHex64 (/^[0-9a-f]{64}$/) and never checksums or compares against a derived address, so two adjacent hex characters swapped still pass. A derived control address is accepted, and the swapped-nibble form of that same address is also accepted and returned unchanged. Wallet.create plus toAddress on user-typed hex is the ordinary send path. GitHub #47 is rate limit per peer ID; this is a client-side destination check the SDK never does.
Affected components
sdk/src/types.ts:24-35 toAddress (assertHex64 only, no checksum or derived-address compare) at sdk 0dbc92ecff709bee79768e4e37788c682a0f4525.
Impact
A single mistyped pair of hex characters sends the amount to an address nobody holds. The SDK will sign and submit it. Worst case is total loss of that send; there is no later checksum to bounce it.
PoC
#!/usr/bin/env node
/** A4 — SDK addresses carry no checksum; a swapped-hex destination is accepted. */
import { toAddress, deriveAddress, Wallet } from './sdk.mjs'
const PIN = '0dbc92ecff709bee79768e4e37788c682a0f4525'
console.log(`PROVENANCE: sdk=${PIN} file=poc/round3/a4_address_checksum.mjs`)
const w = Wallet.create()
const good = w.address
console.log(`CONTROL derived address=${good} toAddress(good) ok`)
const again = toAddress(good)
if (again !== good) throw new Error('toAddress rejected a derived address')
const swapped = good.slice(0, 2) + good[3] + good[2] + good.slice(4)
console.log(`ATTACK swapped[2:4] ${good.slice(2, 4)} -> ${swapped.slice(2, 4)} dest=${swapped}`)
let accepted = false
let err = ''
try {
const a = toAddress(swapped)
accepted = a === swapped
console.log(`ATTACK toAddress(swapped)=${a}`)
} catch (e) {
err = String(e)
console.log(`ATTACK toAddress threw ${err}`)
}
const stillHex64 = /^[0-9a-f]{64}$/.test(swapped)
const different = swapped !== good
if (accepted && stillHex64 && different) {
console.log('PASS: swapped-hex destination accepted by toAddress; CONTROL derived address also accepted')
console.log('VERDICT=CONFIRMED')
process.exit(0)
}
console.log(`KILL: accepted=${accepted} err=${err}`)
console.log('VERDICT=KILLED')
process.exit(0)
ATTACK swapped[2:4] 4a -> a4 dest=18a477f7618d020c4fb7aedc3f610a472e7ba9f06537d21276ac82b3bde6e8c6
ATTACK toAddress(swapped)=18a477f7618d020c4fb7aedc3f610a472e7ba9f06537d21276ac82b3bde6e8c6
PASS: swapped-hex destination accepted by toAddress
Suggested fix
Checksum the 64-hex, or require it to match a derived address, before toAddress returns. Reject a destination that is only well-formed hex.
Thread
Thanks for raising this. The SDK accepts the address format the protocol currently defines, which has no checksum; whether to introduce a checksummed encoding is a design question we have recorded for the team to decide. We will update https://bounty.xe.network/XE-0933 with the outcome.