High severityPHPHardcoded SecretsMEDIUM confidence
Hardcoded Crypto Key IV
A hardcoded encryption key and/or IV is passed to openssl_encrypt/decrypt (CWE-321).
Standards mapping
- OWASP Top 10
- A02:2021 - Cryptographic Failures
- OWASP ASVS
- V6.4.1 (L2)
Vulnerable vs. safe
Flagged by this check
return openssl_encrypt($data, "aes-256-cbc", "hardcodedkey123", 0, "1234567890123456");Passes - the safe pattern
return openssl_encrypt($data, "aes-256-gcm", getenv("APP_KEY"), 0, random_bytes(16), $tag);Why it matters & how to fix it
A hardcoded encryption key and/or IV is passed to openssl_encrypt/decrypt (CWE-321). A static key in source cannot be rotated and a reused/literal IV breaks confidentiality. Derive the key from a secret loaded at runtime and generate a fresh random IV per message with random_bytes(); prefer an authenticated mode such as aes-256-gcm.
References
Rule ID integsec-php-hardcoded-crypto-key-iv - engine: Opengrep - license: MIT - Copyright (c) IntegSec Inc.
TurboPentest runs this check automatically
Connect a GitHub repo and this check runs on every white-box pentest - AI-validated and reported with proof, from $99 per target.
Start a pentestRelated checks
- JavaScript / TypeScript - Hardcoded SecretsBasic Auth Credentials In URL
- JavaScript / TypeScript - Hardcoded SecretsDB Connection String With Credentials
- JavaScript / TypeScript - Hardcoded SecretsHardcoded Credential String
- JavaScript / TypeScript - Hardcoded SecretsHardcoded Crypto Key Or IV
- Python - Hardcoded SecretsBasic Auth Credentials In URL
- Python - Hardcoded SecretsDB Connection String Credentials