Bug #73978 [NEW]: openssl_decrypt triggers bug in PDO

From: Date: Mon, 23 Jan 2017 11:43:56 +0000
Subject: Bug #73978 [NEW]: openssl_decrypt triggers bug in PDO
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-206878@lists.php.net to get a copy of this message
From: schmittjoh at gmail dot com Operating system: Ubuntu 16.04 PHP version: 7.1.1 Package: PDO MySQL Bug Type: Bug Bug description:openssl_decrypt triggers bug in PDO Description: ------------ We get an SSL error when connecting to a secure MySQL server for some queries: Warning: PDOStatement::execute(): SSL operation failed with code 1. OpenSSL Error messages: error:0607A082:digital envelope routines:EVP_CIPHER_CTX_set_key_length:invalid key length error:0607A082:digital envelope routines:EVP_CIPHER_CTX_set_key_length:invalid key length The error happens for the next query after we used the openssl_decrypt function in our code. It seems like this function is not properly encapsulated or leaves some state behind which then triggers the error in PDO. I was not able to reproduce a test-case with values that would not expose our secret, but making a second call to openssl_decrypt with no meaningful values fixes it. Test script: --------------- // This query runs fine. $con->prepare("SELECT 1")->execute()->fetchColumn(); // This call leaves some state behind that causes error on second query. openssl_decrypt(/* real arguments here */); // Adding a call like this works around the bug. // openssl_decrypt('', 'AES-256-CBC', '', 0, ''); // Error on this query. $con->prepare("SELECT 1")->execute()->fetchColumn(); -- Edit bug report at https://bugs.php.net/bug.php?id=73978&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=73978&r=trysnapshot54 Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=73978&r=trysnapshot55 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=73978&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=73978&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=73978&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=73978&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=73978&r=needscript Try newer version: https://bugs.php.net/fix.php?id=73978&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=73978&r=support Expected behavior: https://bugs.php.net/fix.php?id=73978&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=73978&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=73978&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=73978&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=73978&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=73978&r=dst IIS Stability: https://bugs.php.net/fix.php?id=73978&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=73978&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=73978&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=73978&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=73978&r=mysqlcfg

« previous php.bugs (#206878) next »