adapter-stellar: the xdr-json WASM is fetched from unpkg and run with no integrity check

Abierto
#116 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
4/5
Tiempo estimado
3-5 días
Aptitud para principiantes
45/100
Tipo de issue
Error
Claridad
Bastante claro
Estado de actividad
Activo
Stack tecnológico
typescript, wasm

Línea de trabajo

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.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

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:

  1. 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.
  2. 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.
  3. 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.

Lenguaje dominante
TypeScript
Estrellas
2
Forks
2
Merge medio
6 h 33 min
PR fusionados (30 d)
11

Preparar el entorno

Este proyecto no incluye contenedor de desarrollo, Dockerfile ni guía de contribución, así que la configuración corre por tu cuenta: empieza por su README y consulta nuestra guía para la primera contribución para los pasos generales.

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de OpenZeppelin/openzeppelin-adapters

Todos los issues de OpenZeppelin/openzeppelin-adapters

Issues similares

Más issues de TypeScript

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.