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

CWE-330: Use of Insufficiently Random Values Documentation #698

Open
wants to merge 19 commits into
base: main
Choose a base branch
from

Conversation

BartyBoi1128
Copy link
Contributor

Documentation for CWE-330, and a few minor code changes

Signed-off-by: ebakrra <bartlomiej.karas@ericsson.com>
Copy link
Contributor

@myteron myteron left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated main readme.md !

Loads of empty lines with a single space. Please install black, format code and C&P into readme.md.

Suggest to update the MT to the publication, that is assuming the existing reference did not provide any more insights.

some formatting issues

BartyBoi1128 and others added 6 commits December 11, 2024 11:18
Updated the blank spaces.

Signed-off-by: BartyBoi1128 <58297160+BartyBoi1128@users.noreply.github.com>
Co-authored-by: myteron <myteron@gmail.com>
Signed-off-by: BartyBoi1128 <58297160+BartyBoi1128@users.noreply.github.com>
Co-authored-by: myteron <myteron@gmail.com>
Signed-off-by: BartyBoi1128 <58297160+BartyBoi1128@users.noreply.github.com>
Co-authored-by: myteron <myteron@gmail.com>
Signed-off-by: BartyBoi1128 <58297160+BartyBoi1128@users.noreply.github.com>
Co-authored-by: myteron <myteron@gmail.com>
Signed-off-by: BartyBoi1128 <58297160+BartyBoi1128@users.noreply.github.com>
Co-authored-by: myteron <myteron@gmail.com>
Signed-off-by: BartyBoi1128 <58297160+BartyBoi1128@users.noreply.github.com>
Copy link
Contributor

@myteron myteron left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

some formatting issues

myteron and others added 7 commits December 12, 2024 09:22
…communicate via review

Signed-off-by: Helge Wehder <helge.wehder@ericsson.com>
Copy link
Contributor

@myteron myteron left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All formatting fixed. no major content changes as such, only added sonar ref back in.

BartyBoi1128 and others added 5 commits December 23, 2024 12:07
Co-authored-by: Hubert Daniszewski <61824500+s19110@users.noreply.github.com>
Signed-off-by: BartyBoi1128 <58297160+BartyBoi1128@users.noreply.github.com>
Co-authored-by: Hubert Daniszewski <61824500+s19110@users.noreply.github.com>
Signed-off-by: BartyBoi1128 <58297160+BartyBoi1128@users.noreply.github.com>
Co-authored-by: Hubert Daniszewski <61824500+s19110@users.noreply.github.com>
Signed-off-by: BartyBoi1128 <58297160+BartyBoi1128@users.noreply.github.com>
Co-authored-by: Hubert Daniszewski <61824500+s19110@users.noreply.github.com>
Signed-off-by: BartyBoi1128 <58297160+BartyBoi1128@users.noreply.github.com>
Had one too many blank lines!

Signed-off-by: BartyBoi1128 <58297160+BartyBoi1128@users.noreply.github.com>
Python's `random` module is a standard library module that provides functions to generate pseudorandom numbers for various distributions. This module can lead to a vulnerability due to its predictability. The random module is based on the Mersenne Twister `MT19937`
[[MATSUMOTO, NISHIMURA 1998](https://dl.acm.org/doi/pdf/10.1145/272991.272995)], which is a deterministic algorithm, that, given a particular input, will always produce the same output [[Wikipedia 2024](https://en.wikipedia.org/wiki/Deterministic_algorithm)]. An attacker knowing or guessing the seed value can predict the entire sequence of the pseudorandom numbers. This also means that if two `Random` class objects are created using an identical seed, they will generate the same sequence of numbers, regardless of the Python environment.

Therefore, the `random` module is unsuitable for applications requiring high security as it does not incorporate cryptographic randomness, which means it is not resistant to reverse engineering. Its limited entropy makes it easier for attackers to deduce the internal state of the generator and predict future outputs.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Therefore, the `random` module is unsuitable for applications requiring high security as it does not incorporate cryptographic randomness, which means it is not resistant to reverse engineering. Its limited entropy makes it easier for attackers to deduce the internal state of the generator and predict future outputs.
Therefore, the `random` module is unsuitable for applications requiring security as it does not incorporate cryptographic randomness, which means it is predictable. Its use makes it easy for attackers to deduce the internal state of the generator and predict future outputs.

"Reverse engineering" isn't the issue. The problem is that you're using the wrong algorithm.


Therefore, the `random` module is unsuitable for applications requiring high security as it does not incorporate cryptographic randomness, which means it is not resistant to reverse engineering. Its limited entropy makes it easier for attackers to deduce the internal state of the generator and predict future outputs.

Instead, for generating random numbers, it is recommended to use a more robust option, such as Python's `secrets` module.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Instead, for generating random numbers, it is recommended to use a more robust option, such as Python's `secrets` module.
Instead, for generating random numbers for security purposes, use an appropriate option, such as Python's `secrets` module.

The random algorithm is robust, it's just robustly wrong when you use it for the wrong purpose.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants