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

Insecure Randomness for the useof Math.random() in lcg API and defaultSource.js (security vulnerability) #45

Closed
shubhamvinayak opened this issue Jan 20, 2023 · 1 comment

Comments

@shubhamvinayak
Copy link

shubhamvinayak commented Jan 20, 2023

Since Math.random could potentially return the same value twice and it is not cryptographically secure causing the insecure randomness when we scan the code in the fortify tool.

Please confirm if there is any future plan to remove Math.random and use cryptographically secure code for getting random values.
just by using crypto API

const myArray = new Uint32Array(10);
crypto.getRandomValues(myArray);

lcg: https://github.com/d3/d3-random/blob/main/src/lcg.js#L6
deafultSource.js: https://github.com/d3/d3-random/blob/main/src/defaultSource.js#L1

Below APIs are dependent on the defaultsource which gives Math.random values
d3.uniform
d3.int
d3.normal
d3.logNormal
d3.irwinHall
d3.bates
d3.exponential
d3.pareto
d3.bernoulli
d3.geometric
d3.gamma
d3.beta
d3.binomial
d3.weibull
d3.cauchy
d3.logistic
d3.poisson

@shubhamvinayak shubhamvinayak changed the title Insecure Randomness for the useof Math.random() in lcg API (security vulnerability) Insecure Randomness for the useof Math.random() in lcg API and defaultSource.js (security vulnerability) Jan 20, 2023
@Fil
Copy link
Member

Fil commented Jan 20, 2023

All the random methods accept a user-defined source. See https://observablehq.com/@d3/random-source for usage examples (including crypto and seedrandom).

@Fil Fil closed this as not planned Won't fix, can't repro, duplicate, stale Jan 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants