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

Remove usage of Number constructor #3779

Open
dapplion opened this issue Feb 20, 2022 · 0 comments
Open

Remove usage of Number constructor #3779

dapplion opened this issue Feb 20, 2022 · 0 comments
Labels
good first issue Issues that are suitable for first-time contributors. help wanted The author indicates that additional help is wanted. prio-medium Resolve this some time soon (tm). scope-security Issues that fix security issues: DOS, key leak, CVEs.

Comments

@dapplion
Copy link
Contributor

The Number constructor is very unsafe because:

  • It takes any as parameter. If we change from passing a string to Number to some object Typescript will compile and we'll get NaN.

If you do a text search of the Number constructor there are many occurrences:

  • If Number arg is already an argument, remove
  • If Number arg is a string, use parseInt()
  • If Number arg is a bigint, use a custom util that types like bigintToNumber(bn: bigint): number

If the input of any of those functions is un-trusted data, verify the return is not NaN

@dapplion dapplion added the prio-medium Resolve this some time soon (tm). label Feb 20, 2022
@philknows philknows added good first issue Issues that are suitable for first-time contributors. help wanted The author indicates that additional help is wanted. scope-security Issues that fix security issues: DOS, key leak, CVEs. labels Oct 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Issues that are suitable for first-time contributors. help wanted The author indicates that additional help is wanted. prio-medium Resolve this some time soon (tm). scope-security Issues that fix security issues: DOS, key leak, CVEs.
Projects
None yet
Development

No branches or pull requests

2 participants