Possible regression in native crypto paths in componentize-js 0.20.0 due to preview1 random_get stubbing
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 3/5
- Tiempo estimado
- 1-2 días
- Aptitud para principiantes
- 55/100
- Tipo de issue
- Error
- Claridad
- Bastante claro
- Estado de actividad
- Tranquilo
- Stack tecnológico
- javascript, rust, wasm
Línea de trabajo
Comienza con stub_preview1 en crates/spidermonkey-embedding-splicer/src/stub_wasi.rs y revisa la actualización de StarlingMonkey en el commit 499a888. Reproduce el caso de RSA importKey y luego compara el comportamiento con y sin hacer stubbing de preview1 random_get. Se considera completado cuando la ruta criptográfica nativa termina sin el trap de random_get y se verifica el comportamiento esperado.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Hi all,
@maxim-le and I hit a runtime trap in componentize-js 0.20.0 and wanted to share what we found in case we are understanding the behavior correctly. We may be missing context, so I’m filing this as a question / possible bug rather than assuming the current implementation is wrong.
Symptom
We see traps like:
wasm trap: wasm unreachable instruction executed
0: ... !random_get
This happens for WebCrypto operations that appear to go through native crypto code, for example RSA private-key crypto.subtle.importKey("pkcs8", ...).
A simplified repro for us is:
async function main() {
const pem = `-----BEGIN PRIVATE KEY-----
...
-----END PRIVATE KEY-----`;
const pemBody = pem
.replace(/-----BEGIN PRIVATE KEY-----/, "")
.replace(/-----END PRIVATE KEY-----/, "")
.replace(/[\r\n\s]/g, "");
const keyBytes = Uint8Array.from(atob(pemBody), c => c.charCodeAt(0));
const key = await crypto.subtle.importKey(
"pkcs8",
keyBytes.buffer,
{ name: "RSASSA-PKCS1-v1_5", hash: "SHA-256" },
false,
["sign"]
);
return { imported: true, type: key.type };
}
What we found
The relevant code seems to be in:
crates/spidermonkey-embedding-splicer/src/stub_wasi.rs
fn stub_preview1(module: &mut Module) -> Result<()> {
// random comes from prevew2 only in StarlingMonkey
stub_import(module, PREVIEW1, "random_get", unreachable_stub)?;
Ok(())
}
The stub predates 0.20.0 by a long time. The main notable change between 0.19.3 (The previous version we used) and 0.20.0 relevant to this area appears to be the StarlingMonkey update in 499a888 ("Update StarlingMonkey (#325)"), which is consistent with the issue only becoming observable for us in 0.20.0.
Current hypothesis
Our current guess is:
- componentize-js 0.20.0 bumped StarlingMonkey in a way that now exercises a native crypto / libc entropy path that actually reaches preview1
random_get - once that path is exercised, the existing stub becomes visible as a trap
What we verified locally
We tested a local patch that stops stubbing random_get, rebuilt the splicer artifacts, and reran the same RSA importKey case.
With that patch in place, the trap disappeared and the operation completed successfully.
Because of that, it seems plausible that preview1 random_get still needs to remain available for some native crypto paths, even if most JS-visible randomness is coming from preview2.
Question
Does this sound like a real bug from your perspective, or is there intended behavior here that we are overlooking?
If useful, I’m happy to open a follow-up PR :)
Thanks.
- Lenguaje dominante
- Rust
- Estrellas
- 392
- Forks
- 54
- Merge medio
- 3 d 5 h
- PR fusionados (30 d)
- 1
Guía de contribución
No hay ninguna guía de contribución indexada para este repositorio
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de bytecodealliance/ComponentizeJS
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
-
enhancement
Dificultad 4/5 3-5 días Aptitud para principiantes 56/100
-
Dificultad 3/5 1-2 días Aptitud para principiantes 52/100
-
Dificultad 4/5 3-5 días Aptitud para principiantes 45/100
-
Dificultad 4/5 3-5 días Aptitud para principiantes 48/100
bytecodealliance/ComponentizeJS#335 · 3 comentarios ·
Todos los issues de bytecodealliance/ComponentizeJS
Issues similares
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 84/100
Eynzof/Hermes-CN-Desktop#610 ·
-
bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
gitbutlerapp/gitbutler#15998 · 1 comentario ·
-
bug triage:deciding
Dificultad 1/5 Menos de una hora Aptitud para principiantes 88/100
open-telemetry/otel-arrow#4132 ·
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 88/100
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 84/100