Summary
Versions of openssl_encrypt before 1.4.0 use a non-standard PBKDF2 construction that performs one iteration per call inside an outer loop. This can weaken password-derived encryption keys and may allow attackers to crack passwords protecting legacy encrypted files more efficiently than with standard, properly parameterized PBKDF2.
Affected context
The issue can affect applications that use vulnerable openssl_encrypt versions to derive encryption keys from passwords, particularly when protecting legacy encrypted files. Risk depends on the use of password-based encryption, the construction's effective work factor, password strength, and whether an attacker can obtain encrypted data for offline analysis.
Exploit preconditions
- Attack surface: Password-based encryption of application data or files
- Required access: Access to ciphertext and any required encryption metadata; online access to the application is not necessarily required
- Trigger point: Offline password-guessing against data encrypted with the non-standard KDF
- Why exploitation is possible: The construction does not provide the formally analyzed security properties and work-factor behavior expected from standard PBKDF2 usage, allowing guesses to be evaluated more efficiently
Why this happens
The underlying bug is the use of a non-standard key derivation construction that invokes PBKDF2 with a single iteration per call inside an outer loop. Although the implementation may appear to increase work through repetition, this arrangement does not necessarily provide the same security guarantees as a standard PBKDF2 operation with a properly selected iteration count.
This maps to CWE-327: Use of a Broken or Risky Cryptographic Algorithm, because the implementation relies on a cryptographic construction whose security properties are not established in the intended way and may reduce resistance to password-guessing attacks.
Potential impact
- Attackers may recover passwords protecting legacy encrypted files
- Confidential application data may be disclosed
- Recovered passwords could enable access to other systems or accounts if reused
- Organizations may face increased exposure from long-lived encrypted archives
General mitigation guidance
Mitigation generally focuses on replacing non-standard password-based encryption with well-analyzed constructions and reducing reliance on weak or reused passwords.
Common defensive patterns include:
- Using standard KDF APIs with documented, calibrated work factors
- Considering memory-hard password derivation where the application and format support it
- Re-encrypting legacy files after successful authentication using the stronger construction
- Generating independent salts for each encrypted object
- Reducing trust in user-supplied KDF parameters by applying bounded, policy-controlled settings
- Separating encryption keys from passwords through managed key-encryption keys where practical
- Limiting process and storage privileges for services handling decrypted content
How teams detect issues like this
Organizations can identify this class of issue through:
- Static analysis for PBKDF2 calls configured with a single iteration or wrapped in custom repetition loops
- Code review of password-to-key conversion and legacy encryption-format handling
- Dependency and API inventory checks for vulnerable openssl_encrypt versions
- Tests that compare implemented parameters and serialization formats with approved cryptographic policies
- Policy enforcement requiring reviewed, standard KDF constructions and minimum work-factor requirements
Automated software composition analysis and cryptographic linting tools may help surface affected dependencies and unusual KDF patterns.

