Php Rsa Legacy Padding
Description
This detector identifies PHP code that uses RSA encryption functions with legacy or insecure padding schemes. Legacy padding schemes like PKCS#1 v1.5 are vulnerable to padding oracle attacks, which can lead to complete decryption of sensitive data without knowing the private key.
Detection Strategy
• Scans PHP source code for function calls that perform RSA encryption operations
• Identifies specific RSA encryption functions that are known to be vulnerable when used with legacy padding
• Checks if the RSA encryption function call uses legacy padding schemes (such as PKCS#1 v1.5) instead of secure alternatives like OAEP
• Reports a vulnerability when an RSA encryption function is called with legacy padding configuration
Vulnerable code example
<?php
// VULNERABLE: Using legacy PKCS#1 v1.5 padding vulnerable to Bleichenbacher attacks
function encryptData($data, $publicKey) {
openssl_public_encrypt($data, $encrypted, $publicKey, OPENSSL_PKCS1_PADDING);
return $encrypted;
}
...✅ Secure code example
<?php
// SAFE: Using OAEP padding which is resistant to padding oracle attacks
function encryptData($data, $publicKey) {
openssl_public_encrypt($data, $encrypted, $publicKey, OPENSSL_PKCS1_OAEP_PADDING);
return $encrypted;
}
...Search for vulnerabilities in your apps for free with Fluid Attacks' automated security testing! Start your 21-day free trial and discover the benefits of the Continuous Hacking Essential plan. If you prefer the Advanced plan, which includes the expertise of Fluid Attacks' hacking team, fill out this contact form.