Repository navigation
fix(chains): validate untrusted RPC responses before decoding - #286
gbengaeben wants to merge 4 commits into
Conversation
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
|
@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! 🚀 |
Restore the typed UnsupportedCapabilityError when @solana/web3.js is unavailable and regenerate the root API report after the develop merge.
|
Please review and merge @truthixify |
truthixify
left a comment
There was a problem hiding this comment.
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.
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.
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.{data},{result:{data}}, nesteddataandannouncements.nodesenvelopes; reports GraphQL error counts without echoing provider messages; enforces 20-byte addresses, 33-byte ephemeral keys and bounded metadata.@solana/web3.js, signature-page andmeta.logMessagesvalidation, standard/base64url log decoding, and truncated or oversized payload rejection.{result}/{data}normalization, decimal/hex/bare identifiers, u64 capacity and u32 index bounds, 53-byte lock-args enforcement, and a repeated-cursor guard.RPCResponseError(WRAITH/NETWORK/RPC_RESPONSE) carrieschain,operationandfield; values are never echoed. Exported from the package root and documented indocs/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:checkpasspnpm buildpasspnpm api:checkpasspnpm testpass (1726 tests)No changes under
reference/.