{"id":"XE-1730","kind":"bounty","visibility":"public","source":"web","source_repo":"","source_ref":"","source_url":"","reporter_id":451,"title":"Node-supplied provider certificates are never verified: the SDK prices and signs a lease from a forged certificate","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-09T01:37:19.565383+00:00","updated_at":"2026-11-14T22:57:04.296924+00:00","source_created_at":null,"told_at":null,"status_changed_at":"2026-11-14T22:56:52.905298+00:00","url":"https://bounty.xe.network/XE-1730","body":"## Summary\r\n\r\n`XeClient.certificate()` takes whatever the node returns for `/certificate/<provider>` and hands it to the caller as a trusted `Certificate`, and `Xe.openLease()` prices the lease from that certificate and signs the lease block — with **no verification of any kind**. A forged certificate (hash `f…f` that was never issued, a `provider` field naming a different account than the one requested, a price multiplier of 999999 — 100× the legal maximum — and no signature at all) was accepted without error, and `openLease()` then priced and signed a lease at the forged price (amount 667,000 micro-XUSD for 1 vCPU / 512 MB / 10 GB for 60 s). The typed `Certificate` carries only `hash`, `provider`, `priceMultiplierMilli` and `expiresAt`; `toCertificate` keeps the raw record but the SDK never checks the signature, never checks that the certificate's provider is the provider that was asked for, and never checks the multiplier against its legal range. There is no `verifyCertificate` function anywhere in the SDK source: verification is impossible in principle from the typed object, and no code path attempts it.\r\n\r\nOne half of the original recon claim is **refuted** and is not part of this finding: the attestation half. Timekeeper attestations *are* verified — `gatherAttestations` checks the signing key and the signature before using an attestation, and a garbage attestation is rejected (see \"Refuted half\" below). This report covers **only the provider-certificate half**, which was reproduced.\r\n\r\nAn honest node re-validates the lease before it lands (see \"Node backstop\"), so a forged certificate cannot move funds on an honest node. The remaining harm is against a malicious or compromised node: it can make the SDK quote, and the caller sign, a lease at a false price — and the caller has no SDK-side signal that anything is wrong.\r\n\r\n## Impact\r\n\r\n- **A malicious or compromised node can make the SDK quote and sign a lease at a false price.** The caller asked to lease from provider P; the node returns a certificate naming a different provider with a 999999× multiplier; the SDK prices from it (667,000 micro-XUSD for a 60-second 1-vCPU lease that should cost 667 at a 1.0× multiplier) and signs the lease block embedding the forged hash. The only SDK-side guard is the caller's own `maxPricePerMinute` ceiling, which is optional — and a caller who set no ceiling gets no warning at all.\r\n- **Escrow is committed on the strength of an unverified claim.** The lease block locks XUSD escrow for the forged amount. On an honest node the block is rejected at submission (node backstop), so the escrow never lands — but the caller has signed a block asserting a price the certificate never supported, and against a node the caller trusts (or a node that *is* the provider) there is no independent check.\r\n- **No funds move on an honest node.** The ledger looks the certificate up by hash in its own store, checks provider and expiry, and recomputes the cost — a forged certificate fails all three. That is why the severity is Low, not Medium.\r\n\r\n## Severity reasoning\r\n\r\n- **Low, not Medium:** the forged certificate is rejected by the honest node's own validation before anything lands, so no funds move and no lease is created. The defect needs a malicious or compromised node to matter, and the SDK's threat model already places some trust in the node it talks to.\r\n- **Low, not Minor:** the missing check is total — not a weak check, but the absence of any verification function in the SDK — and it sits on the money path: the certificate is literally what a lease is priced against. A caller leasing from a node it does not fully trust (the normal case for an agent renting a machine from a stranger's provider) has no SDK-side way to know the price is genuine. The fix is also cheap: check the provider field, the multiplier range, and the signature against the provider's key.\r\n\r\n## Root cause\r\n\r\n1. **`toCertificate` discards everything verifiable.** `src/client.ts:463-470` maps the raw record to `{ hash, provider, priceMultiplierMilli, expiresAt, raw }`. The `Certificate` interface (`src/client.ts:54-66`) has no `signature`, no `score`, and no provider-public-key field. The raw record is kept, but no code reads a signature from it.\r\n2. **No verify function exists.** A grep over `src/` finds no `verifyCertificate` and no verification of a certificate anywhere. Contrast attestations, where `verifyAttestation` exists and is called (see \"Refuted half\").\r\n3. **`openLease()` trusts the certificate it is handed.** `src/xe.ts:266-283`: it fetches `certificate(provider)`, checks only expiry (`expiresAt !== 0n && expiresAt <= nowNs()`, `:272-274`) — which a forged certificate defeats by setting `expiresAt: 0` (\"no expiry\") — then prices with `pricePerMinute(dims, certificate.priceMultiplierMilli)` (`src/lease.ts:17-18`, `leaseCost` at `:35-44`) and signs a lease block embedding `certificateHash: certificate.hash`. It never checks that `certificate.provider === provider`, never checks the multiplier against its legal range (500–10000, `xe/perf/certificate.go:56-57`), and never verifies a signature.\r\n\r\n### Refuted half (stated plainly — NOT part of this finding)\r\n\r\nThe recon claim also covered timekeeper attestations. That half is **refuted**: `src/attestation.ts:14-19` (`verifyAttestation`) verifies the signature over the lease hash and timestamp, and `gatherAttestations` (`src/attestation.ts:79-110`, check at `:94`) rejects any attestation whose public key is not the timekeeper's or whose signature does not verify. The harness confirmed it: `verifyAttestation` on a bogus signature (`'00'×64`) returns `false`, and `gatherAttestations` threw `gathered 0 of 1 attestations: http://mock-tk: attestation did not verify`. Do not file the attestation half as a bug.\r\n\r\n### Node backstop (why no funds move on an honest node)\r\n\r\n`validateAndAddLease` (`xe/core/ledger.go:1506`, certificate checks at `:1529-1553`) looks the certificate up by hash in the node's own store (`certificate %s not found`, `:1537`), checks that it belongs to the lease destination (`certificate %s belongs to %s, not lease destination %s`), checks expiry against the block timestamp, and recomputes the cost from the stored multiplier (`lease cost mismatch: expected %d (multiplier %d), got %d`, `:1552`). A forged hash fails the lookup; a wrong provider fails the provider check; a 999999 multiplier fails the cost recompute.\r\n\r\n## Reproduction\r\n\r\n### A. Harness run (primary evidence — PASS, 0 failures)\r\n\r\nScript `/tmp/sdk-verify/verify.mjs` (SDK-2 section), run from the built SDK (`~/workspace/xe-bounty/sdk`, `dist/` already built). Mock fetch only, no network, no live node. The mock answers `/certificate/<provider>` with a forged certificate: hash `'f'×64`, provider = a *different* freshly created wallet, `price_multiplier_milli: '999999'`, `expires_at: '0'`, no signature field at all:\r\n\r\n```sh\r\ncd ~/workspace/xe-bounty/sdk\r\nnode /tmp/sdk-verify/verify.mjs\r\n```\r\n\r\nObserved output (re-run 2026-11-09):\r\n\r\n```\r\n=== SDK-2: provider certificate ===\r\nclient.certificate() returned forged cert without error: {\"hash\":\"ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff\",\"provider\":\"939238ab11617e747d10dffaf9a07dd28116e8d899c1e1b8f9e792882cc5df29\",\"priceMultiplierMilli\":\"999999\",\"expiresAt\":\"0\",\"raw\":{\"hash\":\"ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff\",\"provider\":\"939238ab11617e747d10dffaf9a07dd28116e8d899c1e1b8f9e792882cc5df29\",\"price_multiplier_milli\":\"999999\",\"expires_at\":\"0\"}}\r\nPASS SDK-2 cert: client.certificate accepts forged cert (wrong provider, mult 999999, no sig) provider=939238ab1161 mult=999999\r\nopenLease submitted wire: {\"type\":\"lease\",\"account\":\"0d26b6e68feacfbd06aa7efba18b7f86810fbfbbb634716d7b6eb80f5a66d9c5\",\"previous\":\"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"balance\":999999333000,\"timestamp\":1794186424070000000,\"asset\":\"XUSD\",\"hash\":\"af7dc77757e027760c96dc70c68b4b972effc2b6eea8cf94843443ca4b61332c\",\"signature\":\"1a62bbdcdb808b91dce67bbab37bf759d5be5c21aaf6ac5a32e20d6accb4b8eea4a165d1427c725a3eec1f19251960a234d28cf16225d9cae7f3a72472fc1d04\",\"pow_nonce\":1572465068282574300,\"destination\":\"27dc6bbda544ee54c1c2f72a9229932f49df43c9bb26bef3b69270ccd37d28d3\",\"amount\":667000,\"vcpus\":1,\"memory_mb\":512,\"disk_gb\":10,\"duration\":60,\"certificate_hash\":\"ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff\"}\r\nPASS SDK-2 openLease: signs lease priced from forged cert, hash embedded cert_hash=ffffffffffff amount=667000 dest==provider=true\r\nPASS SDK-2: no verifyCertificate/verify function exists in SDK src grep: no verify*Certificate in src/; toCertificate (client.ts:463) drops signature/provider_pub_key/score\r\nPASS SDK-2 attestation control: verifyAttestation(bogus sig)=false\r\ngatherAttestations(bogus) threw: gathered 0 of 1 attestations: http://mock-tk: attestation did not verify\r\nPASS SDK-2 attestation control: gatherAttestations rejects bogus attestation gathered 0 of 1 attestations: http://mock-tk: attestation did not verify\r\n```\r\n\r\nWhat the run shows:\r\n\r\n1. `client.certificate()` returned the forged certificate without error — wrong provider, multiplier 999999 (legal range 500–10000), no signature.\r\n2. `openLease({ provider, vcpus: 1, memoryMb: 512, diskGb: 10, durationSecs: 60 })` priced the lease from the forged multiplier: `leaseCost` = `ceil(667 × 999999 / 1000)` = **667,000** micro-XUSD (at a 1.0× multiplier the same lease costs 667), and signed a lease block embedding `certificate_hash: 'f'×64` with `amount: 667000`.\r\n3. The attestation control confirms the refuted half: a bogus attestation is rejected by `verifyAttestation` (`false`) and by `gatherAttestations` (throws `attestation did not verify`).\r\n\r\n### B. Honesty notes and preconditions\r\n\r\n- **Precondition (stated plainly):** the forged certificate must come from the node the SDK is talking to — i.e. a malicious or compromised node (or a node that is itself the provider). An honest node serves only certificates it issued, and its ledger rejects a forged one at submission.\r\n- **No live node was used.** Mock fetch in-process; no live testnet traffic, no real provider, no real lease, no real funds.\r\n- **The `maxPricePerMinute` ceiling is not a substitute.** It is optional, caller-supplied, and a ceiling on the *price*, not a verification of the *certificate* — it cannot tell a genuine 999× quote from a forged one below the ceiling.\r\n\r\n## Dedup note\r\n\r\nNo live desk-list check was performed in this drafting pass — the dedup below is against the closest items named in the verification record, and the live list should be re-checked before submission. No known report covers this finding:\r\n\r\n- **XE-1655** (`BlockLeaseRenew` absent from `ValidateStagedBlock`) — node-side staged validation for a lease block type, a different check in a different component.\r\n- **XE-2** (staged lease arm: no certificate/cost checks in `ValidateStagedBlock`) — node-side staging gap, again a different component; the SDK-side absence of any certificate verification is the distinct claim here.\r\n\r\nNo known report covers the SDK accepting and pricing from an unverified provider certificate. The attestation half is refuted (see above) and must not be filed.\r\n\r\n## Suggested fix direction\r\n\r\n- Verify the certificate in the SDK before pricing from it: check that `certificate.provider` is the provider that was requested, that `priceMultiplierMilli` is within the legal range (500–10000), and that the certificate's signature verifies against the provider's key (the signature/score fields need to survive `toCertificate` into the typed `Certificate`, or be verified from `raw`).\r\n- Reject in `certificate()` / `certificateByHash()` (fail at read time, so every consumer inherits the check) rather than only in `openLease()`.\r\n- Keep the node as a second line of defence — it already re-validates — but do not rely on it as the only line: the SDK should not sign a lease priced from a certificate it never checked.\r\n\r\n## Payout address\r\n\r\n052e33e0ed9c43e2bdf07faff9a90d25642b51d53d96f49f5d45b81f6584b3da\r\n\r\n## References (file:line; sdk @ 605c20a, xe @ HEAD as checked 2026-11-09)\r\n\r\n| Location | What it shows |\r\n|---|---|\r\n| `sdk/src/client.ts:54-66` | `Certificate` interface: hash, provider, priceMultiplierMilli, expiresAt only — no signature/score |\r\n| `sdk/src/client.ts:313-315` | `certificate()`: returns `toCertificate(...)` with no verification |\r\n| `sdk/src/client.ts:463-470` | `toCertificate`: maps only the four fields (+ raw); nothing verifiable is carried typed |\r\n| `sdk/src/xe.ts:266-283` | `openLease()`: expiry-only check (`:272-274`), then prices and signs from the certificate |\r\n| `sdk/src/lease.ts:17-18,35-44` | `pricePerMinute` / `leaseCost`: price is a pure function of the certificate multiplier |\r\n| `sdk/src/attestation.ts:14-19` | `verifyAttestation`: signature verification (the refuted half — this *does* exist) |\r\n| `sdk/src/attestation.ts:79-110` | `gatherAttestations`: rejects attestations whose key/signature do not verify (`:94`) |\r\n| `xe/perf/certificate.go:56-57` | Legal multiplier range: `PriceMultiplierMin = 500`, `PriceMultiplierMax = 10000` |\r\n| `xe/core/ledger.go:1506,1529-1553` | `validateAndAddLease`: cert lookup by hash, provider + expiry checks, cost recompute |\r\n| `/tmp/sdk-verify/verify.mjs` | SDK-2 harness section (forged cert, 999999 multiplier, amount 667000; 0 failures) — ephemeral, see \"Reproduction\" for the verbatim output |","patch_refs":[],"thread":[]}