adapter-stellar: the xdr-json WASM is fetched from unpkg and run with no integrity check
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 45/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Active
- Tech stack
- typescript, wasm
- Domain
- blockchain, security
Research direction
Start in packages/adapter-stellar/src/sac/xdr.ts, especially the CDN URL and init(CDN_WASM_URL) calls, and read the comment at the top of the file. Compare the options in the issue against the package version range and existing SAC load error handling. Done means the chosen approach prevents unverified WASM from running and reports failures through the SAC load error with the reason on cause.
Written by the indexing model from the issue text.
Description
What happens
To load a Stellar Asset Contract, the adapter encodes the SAC spec with @stellar/stellar-xdr-json, whose WASM is not bundled. It is fetched at run time from https://unpkg.com/@stellar/stellar-xdr-json@<installed version>/stellar_xdr_json_bg.wasm and instantiated as served: sac/xdr.ts L28-L30 (the URL) and L53 (init(CDN_WASM_URL)).
Nothing checks that the bytes are the ones published for that version. The version in the URL follows the installed package, but the content is not verified.
Why it matters
- The app runs code from a third-party CDN in the user's browser, in the same page that builds and signs transactions. If unpkg, or anything on the path to it, serves different bytes, the adapter runs them.
- The WASM produces the SAC interface the app shows and encodes against, so a wrong module can change which functions and argument types a user sees for a token contract.
- Availability is a separate, smaller point: if unpkg is down or blocked by a Content Security Policy, SACs do not load. That already fails with a clear error and is not what this issue is about.
Suggested fix
Options, to be weighed by whoever picks this up:
- Verify before instantiating: fetch the bytes, compare their SHA-256 with a hash the adapter ships for that package version, and refuse on mismatch. The adapter depends on a version range, so it needs either a hash per known version (and a decision on what an unknown version does) or an exact pin.
- Let the consumer supply the WASM (a URL or the bytes), so an app can host it under its own policy. This also helps strict-CSP apps.
- Bundle the WASM. Ruled out so far for bundle size and bundler compatibility (see the comment at the top of
xdr.ts); listed for completeness.
Whichever is chosen, a failed check should surface as the existing SAC load error, with the reason on cause.
- Dominant language
- TypeScript
- Stars
- 2
- Forks
- 2
- Avg merge
- 6h 33m
- Merged PRs (30d)
- 11
Getting set up
This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from OpenZeppelin/openzeppelin-adapters
-
Difficulty 2/5 1-3 hours Newbie friendliness 77/100
OpenZeppelin/openzeppelin-adapters#114 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
OpenZeppelin/openzeppelin-adapters#90 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
OpenZeppelin/openzeppelin-adapters#72 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
OpenZeppelin/openzeppelin-adapters#47 ·
Maintainers usually reply within 1 day
-
Difficulty 4/5 3-5 days Newbie friendliness 54/100
OpenZeppelin/openzeppelin-adapters#115 ·
Maintainers usually reply within 1 day
All issues in OpenZeppelin/openzeppelin-adapters
Similar issues
-
Codex使用可 かんたん コード
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
ryuki-moro/Nicomaru#348 ·
Maintainers usually reply within 1 day
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 77/100
Maintainers usually reply within 1 day
-
Bug
Difficulty 1/5 Under an hour Newbie friendliness 84/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
-
area-integrations
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
Maintainers usually reply within 1 day