Description
Target Language
cpp
Library Repository / Documentation URL
To be determined from the linked findings
Data Extension Name (Optional)
cwe-327, CWE-328, CWE-338, CWE-780.model.yml
Library Modules / Components
See linked findings for the frameworks involved.
Data Extension Description
AI Scan reported 4 medium-severity CWE-327, CWE-328, CWE-338, CWE-780 (weak crypto randomness) finding(s) in C/C++ public synthetic repositories that the baseline CodeQL default-setup scan did not report. Gap categories: missing-crypto-api-model-wincrypt, query-absent-weak-prng-security-use. Existing queries considered: cpp/weak-cryptographic-algorithm.
Why CodeQL appears to have missed these (unverified until reproduced with a test database):
- 327 pattern: The bad() function derives a key with CALG_DES and decrypts data using CryptDecrypt with single DES (56-bit effective key). DES is cryptographically broken and brute-forceable; a modern algorithm such as AES should be used instead. Equivalent flaws exist in th
- 328 pattern: The bad() function hashes the user-supplied password with CryptCreateHash(..., CALG_MD5, ...). MD5 is a broken, unsalted, fast hash that is trivially reversible via rainbow tables/collisions and must not be used for password or integrity protection.
- 780 pattern: bad() encrypts a payload with an RSA key via CryptEncrypt() without specifying CRYPT_OAEP, so the legacy PKCS#1 v1.5 padding is used. PKCS#1 v1.5 encryption padding is vulnerable to Bleichenbacher-style adaptive chosen-ciphertext attacks; OAEP padding should b
- 338 pattern: CWE338_Weak_PRNG__w32_01_bad() uses rand() to produce a value used as if it were random/unpredictable. rand() is a statistical, non-cryptographic PRNG whose output is predictable; use a CSPRNG (CryptGenRandom / getrandom / /dev/urandom) for any security-releva
Linked findings (gap-key: cpp/data-extension-create/weak-crypto-randomness)
| Repo | CWE | Severity | AI scan alert | Summary |
|---|---|---|---|---|
| juliet-test-suite-c | CWE-327 | medium | https://github.com/codeql-forks-felickz/juliet-test-suite-c/security/code-scanning/29 | The bad() function derives a key with CALG_DES and decrypts data using CryptDecrypt with single DES (56-bit effective key). DES is cryptographically broken and brute-forceable; a modern algorithm such as AES should be used instead. Equivalent flaws exist in the sibling 3DES and RC5 test cases in this directory. |
| juliet-test-suite-c | CWE-328 | medium | https://github.com/codeql-forks-felickz/juliet-test-suite-c/security/code-scanning/31 | The bad() function hashes the user-supplied password with CryptCreateHash(..., CALG_MD5, ...). MD5 is a broken, unsalted, fast hash that is trivially reversible via rainbow tables/collisions and must not be used for password or integrity protection. |
| juliet-test-suite-c | CWE-780 | medium | https://github.com/codeql-forks-felickz/juliet-test-suite-c/security/code-scanning/54 | bad() encrypts a payload with an RSA key via CryptEncrypt() without specifying CRYPT_OAEP, so the legacy PKCS#1 v1.5 padding is used. PKCS#1 v1.5 encryption padding is vulnerable to Bleichenbacher-style adaptive chosen-ciphertext attacks; OAEP padding should be used instead. |
| juliet-test-suite-c | CWE-338 | medium | https://github.com/codeql-forks-felickz/juliet-test-suite-c/security/code-scanning/30 | CWE338_Weak_PRNG__w32_01_bad() uses rand() to produce a value used as if it were random/unpredictable. rand() is a statistical, non-cryptographic PRNG whose output is predictable; use a CSPRNG (CryptGenRandom / getrandom / /dev/urandom) for any security-relevant randomness. |
Findings come from AI Scan on public synthetic apps. Hypotheses above are unverified until reproduced with a test database. Verify first whether CodeQL already covers a case (for example via a different query or threat model) before adding code.
Handling decision
- Type: Data Extension Create
- Decision: Add a data extension (model-as-data). An existing query should report these once the library is modeled; add the missing sources, sinks, summaries or barriers as extension rows.
- Recommended actions across the findings: add-data-extension (3), write-new-query (1)
Patterns in this gap
wincrypt-weak-algorithms(3 findings), for example juliet-test-suite-c testcases/CWE327_Use_Broken_Crypto/CWE327_Use_Broken_Crypto__w32_DES_01.cweak-prng-rand(1 finding), for example juliet-test-suite-c testcases/CWE338_Weak_PRNG/CWE338_Weak_PRNG__w32_01.c
Finding details
Each finding below has its own context so the agent can work from this issue alone.
1. juliet-test-suite-c testcases/CWE327_Use_Broken_Crypto/CWE327_Use_Broken_Crypto__w32_DES_01.c:86 (CWE-327, medium)
- AI Scan alert: https://github.com/codeql-forks-felickz/juliet-test-suite-c/security/code-scanning/29
- AI Scan message: The bad() function derives a key with CALG_DES and decrypts data using CryptDecrypt with single DES (56-bit effective key). DES is cryptographically broken and brute-forceable; a modern algorithm such as AES should be used instead. Equivalent flaws exist in the sibling 3DES and RC5 test cases in this directory.
- Why CodeQL appears to miss it: missing-crypto-api-model-wincrypt: 327 pattern: The bad() function derives a key with CALG_DES and decrypts data using CryptDecrypt with single DES (56-bit effective key). DES is cryptographically broken and brute-forceable; a modern algorithm such as AES should be used instead. Equivalent flaws exist in th
- Existing CodeQL queries considered: cpp/weak-cryptographic-algorithm
- Recommended action from the comparison: add-data-extension (classification confidence: medium)
2. juliet-test-suite-c testcases/CWE328_Reversible_One_Way_Hash/CWE328_Reversible_One_Way_Hash__w32_MD5_01.c:83 (CWE-328, medium)
- AI Scan alert: https://github.com/codeql-forks-felickz/juliet-test-suite-c/security/code-scanning/31
- AI Scan message: The bad() function hashes the user-supplied password with CryptCreateHash(..., CALG_MD5, ...). MD5 is a broken, unsalted, fast hash that is trivially reversible via rainbow tables/collisions and must not be used for password or integrity protection.
- Why CodeQL appears to miss it: missing-crypto-api-model-wincrypt: 328 pattern: The bad() function hashes the user-supplied password with CryptCreateHash(..., CALG_MD5, ...). MD5 is a broken, unsalted, fast hash that is trivially reversible via rainbow tables/collisions and must not be used for password or integrity protection.
- Existing CodeQL queries considered: cpp/weak-cryptographic-algorithm
- Recommended action from the comparison: add-data-extension (classification confidence: medium)
3. juliet-test-suite-c testcases/CWE780_Use_of_RSA_Algorithm_Without_OAEP/CWE780_Use_of_RSA_Algorithm_Without_OAEP__w32_01.c:69 (CWE-780, medium)
- AI Scan alert: https://github.com/codeql-forks-felickz/juliet-test-suite-c/security/code-scanning/54
- AI Scan message: bad() encrypts a payload with an RSA key via CryptEncrypt() without specifying CRYPT_OAEP, so the legacy PKCS#1 v1.5 padding is used. PKCS#1 v1.5 encryption padding is vulnerable to Bleichenbacher-style adaptive chosen-ciphertext attacks; OAEP padding should be used instead.
- Why CodeQL appears to miss it: missing-crypto-api-model-wincrypt: 780 pattern: bad() encrypts a payload with an RSA key via CryptEncrypt() without specifying CRYPT_OAEP, so the legacy PKCS#1 v1.5 padding is used. PKCS#1 v1.5 encryption padding is vulnerable to Bleichenbacher-style adaptive chosen-ciphertext attacks; OAEP padding should b
- Recommended action from the comparison: add-data-extension (classification confidence: low)
4. juliet-test-suite-c testcases/CWE338_Weak_PRNG/CWE338_Weak_PRNG__w32_01.c:28 (CWE-338, medium)
- AI Scan alert: https://github.com/codeql-forks-felickz/juliet-test-suite-c/security/code-scanning/30
- AI Scan message: CWE338_Weak_PRNG__w32_01_bad() uses rand() to produce a value used as if it were random/unpredictable. rand() is a statistical, non-cryptographic PRNG whose output is predictable; use a CSPRNG (CryptGenRandom / getrandom / /dev/urandom) for any security-relevant randomness.
- Why CodeQL appears to miss it: query-absent-weak-prng-security-use: 338 pattern: CWE338_Weak_PRNG__w32_01_bad() uses rand() to produce a value used as if it were random/unpredictable. rand() is a statistical, non-cryptographic PRNG whose output is predictable; use a CSPRNG (CryptGenRandom / getrandom / /dev/urandom) for any security-releva
- Recommended action from the comparison: write-new-query (classification confidence: low)
Code Examples
See the linked alerts above for the vulnerable pattern; reduce each to a minimal test case with a safe counterpart that should not alert.
Additional References (Optional)
https://cwe.mitre.org/data/definitions/327.html
Code of Conduct
- I agree to follow this project's Code of Conduct
Activity
felickz commentedon Nov 3, 2026
Upstream triage
precision:lowAudit-grade or weak signal. Community Packs, always tags:experimental.
tags:experimental
Goes to Community Packs: performance, false-positive or synthetic-only concerns.
Community Packs, experimental. Recommended for the Community Packs repository, not
github/codeql. The issue is labeledtags:experimentalfor this.Linked pull request: #326
Why. Framed as data extensions, but the PR adds three new queries driven by custom extensible predicates, not rows for existing CodeQL models. SHA-1 and MD5 are flagged for any hash, RSA keys are tracked only from CryptGenKey and CryptDeriveKey, and the PRNG query flags every used rand() result. Stock cpp/weak-cryptographic-algorithm already matches DES and RC4 names. Suitable only as experimental Community Packs queries.
highin the pull request). WeakPrng reports every used rand/random result (audit grade, declared low). WinCryptWeakAlgorithm flags any CALG_MD5/SHA1 hash, including non-security use (medium). The RSA query follows only CryptGenKey/CryptDeriveKey keys (medium, narrow).Concerns, overlap and next steps
False-positive concerns
Heuristics used
What an upstream change would look like. Community Packs cpp/src/<category>/ with three separate queries and tests in cpp/test/ (keep the stub wincrypt.h). The custom extensible predicates do not map to github/codeql MaD, so inline the lists or keep the dataExtensions wiring in the pack.
Before opening an upstream pull request
Split note. WinCryptWeakAlgorithm medium, WinCryptRsaWithoutOaep medium (narrow), WeakPrng low (audit). All three belong in Community Packs; WeakPrng is the weakest and could be dropped.
Change from the initial guess. When this issue was opened the coarse destination guess was
github/codeql. Reading the actual pull request changed it to Community Packs.This is a recommendation only. A human reviews it before any pull request is opened against
github/codeqlor the Community Packs repository.