Skip to content

security(sdk): 0.19.2 worker-key binding + SIWE validation + verdict hashes; fix wallet SIWE regression#135

Merged
marinom2 merged 1 commit into
mainfrom
security/sdk-worker-key-binding
Jun 12, 2026
Merged

security(sdk): 0.19.2 worker-key binding + SIWE validation + verdict hashes; fix wallet SIWE regression#135
marinom2 merged 1 commit into
mainfrom
security/sdk-worker-key-binding

Conversation

@marinom2

Copy link
Copy Markdown
Owner

Foundation for migrating LightChallenge to the SDK: the SDK had the same worker-key MITM I fixed in the wallet, and it didn't expose the on-chain hashes an attestor needs. This fixes both, plus a live wallet regression.

SDK 0.19.2

  • Worker-key on-chain binding. openSession/runInference now bind the session key to the worker's CHAIN-REGISTERED encryption key (new verifyWorkerKeyOnChain, read from WorkerRegistry) instead of trusting the gateway's copy. A hostile proxy substituting its own key is rejected, closing a prompt/answer MITM. Verified live on mainnet: the real gateway key matches the chain, so genuine inference is unaffected (full run returned a verdict in ~55s).
  • SIWE challenge validation. assertSafeChallenge checks the gateway auth challenge names this account and a trusted gateway domain before signing, so a proxy can't harvest a signature scoped elsewhere.
  • Verdict hashes exposed. RunInferenceResult now carries responseHash + ciphertextHash (the worker's on-chain commitments from JobCompleted) so a challenge protocol can anchor the verdict on-chain without a second read.

Wallet SIWE regression fix (from #129)

The assertSafeChallenge I added in #129 hard-failed unless the challenge domain equalled lightnode.app - but I checked the live gateway and it signs as chat-api.<net>.lightchain.ai even through the proxy. So #129 broke the wallet's AI chat. Now the lightchain.ai gateway family is accepted (the address anti-replay check stays). The deployed wallet zip needs refreshing after this.

Verification

515 root tests (+7 new binding/SIWE), 156 wallet tests, tsc + SDK + wxt builds clean, and a live mainnet run confirming the binding accepts the real key, SIWE passes, and both hashes are returned.

… verdict hashes; fix wallet SIWE regression

SDK (same end-to-end hardening the wallet got, now in the published package so
LightChallenge and every SDK user can rely on it):
- openSession/runInference bind the session key to the worker's CHAIN-REGISTERED
  encryption key (new verifyWorkerKeyOnChain, read from WorkerRegistry) instead
  of trusting the gateway's copy. A hostile proxy that substitutes its own key
  is now rejected, closing a prompt/answer MITM. Verified live on mainnet: the
  real gateway key matches the chain, so genuine inference is unaffected.
- assertSafeChallenge validates the gateway's SIWE auth challenge (this account,
  a trusted gateway domain) before signing, so a proxy cannot harvest a
  signature scoped elsewhere.
- RunInferenceResult exposes responseHash + ciphertextHash (the worker's
  on-chain commitments from JobCompleted) so an attestor can anchor the verdict.

Wallet SIWE REGRESSION FIX: the assertSafeChallenge I added in #129 hard-failed
unless the challenge domain equalled 'lightnode.app', but the live gateway signs
as chat-api.<net>.lightchain.ai even through the proxy - so #129 broke the
wallet's AI chat. Accept the lightchain.ai gateway family (verified against the
live challenge). The address check (the real anti-replay protection) stays.

515 root tests + 156 wallet tests; tsc + builds clean; live mainnet run confirms
binding + SIWE + hashes all work.
@marinom2 marinom2 merged commit d0dbb29 into main Jun 12, 2026
1 of 2 checks passed
@marinom2 marinom2 deleted the security/sdk-worker-key-binding branch June 12, 2026 08:12
@vercel

vercel Bot commented Jun 12, 2026

Copy link
Copy Markdown

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

Project Deployment Actions Updated (UTC)
lightnode Building Building Preview, Comment Jun 12, 2026 8:12am

Request Review

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