Skip to content

Commit

Permalink
Merge pull request #76 from namse/patch-1
Browse files Browse the repository at this point in the history
Prevent using crypto for SharedArrayBuffer
  • Loading branch information
bjorn3 authored Jun 1, 2024
2 parents 7d86a13 + ee400dd commit 377fbeb
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/wasi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -829,7 +829,10 @@ export default class WASI {
self.inst.exports.memory.buffer,
).subarray(buf, buf + buf_len);

if ("crypto" in globalThis) {
if (
"crypto" in globalThis &&
!(self.inst.exports.memory.buffer instanceof SharedArrayBuffer)
) {
for (let i = 0; i < buf_len; i += 65536) {
crypto.getRandomValues(buffer8.subarray(i, i + 65536));
}
Expand Down

0 comments on commit 377fbeb

Please sign in to comment.