Skip to content

fix(chains): validate untrusted RPC responses before decoding - #286

Open
gbengaeben wants to merge 4 commits into
wraith-protocol:developfrom
gbengaeben:fix/wave11-untrusted-rpc-validation
Open

gbengaeben wants to merge 4 commits into
wraith-protocol:developfrom
gbengaeben:fix/wave11-untrusted-rpc-validation

Conversation

@gbengaeben

@gbengaeben gbengaeben commented Nov 21, 2026 •

Copy link
Copy Markdown
Contributor

Closes #270

Summary

Wave 9 hardened Stellar RPC responses; EVM subgraph, Solana transaction-log and CKB indexer fetchers still cast or dereferenced untrusted fields before validation. This adds bounded runtime schemas for each of those sources so malformed data is rejected before it reaches address matching or key derivation.

  • Shared bounded helpers in src/chains/rpcValidation.ts: 1 MiB streamed body cap (declared-length and truncation checks), bounded record/array/string/hex/integer validators, and error construction from field paths only.
  • EVM: normalizes {data}, {result:{data}}, nested data and announcements.nodes envelopes; reports GraphQL error counts without echoing provider messages; enforces 20-byte addresses, 33-byte ephemeral keys and bounded metadata.
  • Solana: bounded fetch wrapper for @solana/web3.js, signature-page and meta.logMessages validation, standard/base64url log decoding, and truncated or oversized payload rejection.
  • CKB: {result}/{data} normalization, decimal/hex/bare identifiers, u64 capacity and u32 index bounds, 53-byte lock-args enforcement, and a repeated-cursor guard.
  • New RPCResponseError (WRAITH/NETWORK/RPC_RESPONSE) carries chain, operation and field; values are never echoed. Exported from the package root and documented in docs/errors.md.

Tests

New fixture suites for EVM, Solana and CKB cover missing, null, wrong-type, oversized (declared and streamed), truncated and adversarial responses, provider variants, and assert untrusted values never appear in error messages.

  • pnpm format:check pass
  • pnpm build pass
  • pnpm api:check pass
  • pnpm test pass (1726 tests)
  • Compatibility matrix, entry-point, companion-package and differential checks pass

No changes under reference/.

Add bounded runtime validation for EVM subgraph pages, Solana
transaction logs and CKB indexer cells so malformed or oversized
responses are rejected before they reach crypto paths. Errors use
the new RPCResponseError with chain and operation context, and
fixture tests cover missing, null, wrong-type, oversized, truncated
and adversarial payloads for each chain.

Closes wraith-protocol#270
@drips-wave

drips-wave Bot commented Nov 21, 2026

Copy link
Copy Markdown

@gbengaeben Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

Restore the typed UnsupportedCapabilityError when @solana/web3.js is unavailable and regenerate the root API report after the develop merge.
@gbengaeben

Copy link
Copy Markdown
Contributor Author

Please review and merge @truthixify
Thank You.

@truthixify truthixify left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Head 0bf765e screened clean for the known malware indicators; linked issue #270 is assigned to PR author @gbengaeben. Changes requested: createBoundedSolanaFetch awaits response.text() before enforcing the encoded byte limit. A chunked response without Content-Length is therefore fully buffered, defeating the required hard response-body bound. Stream and cap the body before materialization (the existing capped-reader pattern can be reused), and add an oversized no-Content-Length regression.

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.

[Wave 11] Finish untrusted RPC validation for EVM, Solana, and CKB

2 participants