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

False positive for uses a weak PRNG in ds-math #741

Closed
krasi-georgiev opened this issue Dec 24, 2020 · 2 comments
Closed

False positive for uses a weak PRNG in ds-math #741

krasi-georgiev opened this issue Dec 24, 2020 · 2 comments

Comments

@krasi-georgiev
Copy link

Here is the code in question
https://github.com/dapphub/ds-math/blob/784079b72c4d782b022b3e893a7c5659aa35971a/src/math.sol#L73-L84

Running slither against this returns:

INFO:Detectors:
DSMath.rpow(uint256,uint256) (contracts/Main_merged.sol#5888-5898) uses a weak PRNG: "n % 2 != 0 (contracts/Main_merged.sol#5889)" 
DSMath.rpow(uint256,uint256) (contracts/Main_merged.sol#5888-5898) uses a weak PRNG: "n % 2 != 0 (contracts/Main_merged.sol#5894)" 
Reference: https://github.com/crytic/slither/wiki/Detector-Documentation#weak-PRNG

Which look like a false positive as there is no block.timestamp or block.hash used anywhere in the code.

@krasi-georgiev krasi-georgiev changed the title False positive for uses a weak PRNG False positive for uses a weak PRNG in ds-math Dec 24, 2020
@montyly
Copy link
Member

montyly commented Jan 4, 2021

Hi @krasi-georgiev. Thank you for reporting this.

Could you share the codebase where this result was found? I think it is either:

  • The output that is not explicit enough (ex: block.timestamp is used as a parameter of rpow somewhere, but the detector shows only rpow and not the caller)
  • A false positive

@krasi-georgiev
Copy link
Author

krasi-georgiev commented Jan 4, 2021

Thanks for the update. I have already provided the link in the first comment
dapphub/ds-math@784079b/src/math.sol#L73-L84

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

No branches or pull requests

2 participants