Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix random #142

Merged
merged 5 commits into from
Feb 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions bin/wasm-node/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

### Fixed

- Fix randomness not being implemented properly, leading to the same random numbers always being generated. This issues leads to all instances of smoldot (even on different machines) always using the same networking key, which would lead to connectivity issues when multiple instances of smoldot connect to the same full node. Note that because perfect forward secrecy is used, it is not possible to retroactively decipher networking communications. Additionally, the fact that the same random numbers are always generated made smoldot vulnerable to HashDoS attacks. ([#142](https://github.com/smol-dot/smoldot/pull/142))
- JSON-RPC requests without a `params` field are no longer invalid. ([#13](https://github.com/smol-dot/smoldot/pull/13))
- Fix Merkle proofs whose trie root node has a size inferior to 32 bytes being considered as invalid. ([#3046](https://github.com/paritytech/smoldot/pull/3046))

Expand Down
6 changes: 3 additions & 3 deletions bin/wasm-node/javascript/src/instance/bindings-wasi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,10 @@ export default (config: Config): WebAssembly.ModuleImports => {
len >>>= 0;

const baseBuffer = new Uint8Array(instance.exports.memory.buffer)
.slice(ptr, ptr + len);
.subarray(ptr, ptr + len);
for (let iter = 0; iter < len; iter += 65536) {
// `baseBuffer.slice` automatically saturates at the end of the buffer
config.getRandomValues(baseBuffer.slice(iter, iter + 65536))
// `baseBuffer.subarray` automatically saturates at the end of the buffer
config.getRandomValues(baseBuffer.subarray(iter, iter + 65536))
}

return 0;
Expand Down