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

Use of Insufficiently Random Values #691

Open
Shebuka opened this issue Dec 15, 2023 · 1 comment
Open

Use of Insufficiently Random Values #691

Shebuka opened this issue Dec 15, 2023 · 1 comment
Labels

Comments

@Shebuka
Copy link

Shebuka commented Dec 15, 2023

Steps to reproduce

  1. Use a static analyzer (like MobSF) on an exported ipa that uses SSZipArchive

Expected behavior

No report

Actual behavior

Binary makes use of the insecure Random function(s)

  • CWE: CWE-330: Use of Insufficiently Random Values
  • OWASP Top 10: M5: Insufficient Cryptography
  • OWASP MASVS: MSTG-CRYPTO-6

The binary may use the following insecure Random function(s) _random , _srand

Version of ZipArchive

Any

Problem

minzip uses insecure srand and random if none of the advanced random functions are defined to be available

Solution

Add HAVE_ARC4RANDOM_BUF or HAVE_ARC4RANDOM to GCC_PREPROCESSOR_DEFINITIONS

@Coeur
Copy link
Member

Coeur commented Dec 15, 2023

Well, it may be an issue with the static analyzer?
Sure, without HAVE_ARC4RANDOM_BUF, then mz_os_rand would be using rand() instead of arc4random_buf... but since MZ_ZIP_NO_CRYPTO is not defined, mz_os_rand is never actually used. Instead, it's SecRandomCopyBytes that is being used:

int32_t mz_crypt_rand(uint8_t *buf, int32_t size) {
if (SecRandomCopyBytes(kSecRandomDefault, size, buf) != errSecSuccess)

So we could declare HAVE_ARC4RANDOM_BUF to workaround the analyzer erroneous analysis, but there are no insufficiently random values presently in ZipArchive.

@Coeur Coeur added the easy label Dec 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants