-
-
Notifications
You must be signed in to change notification settings - Fork 3.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
MySQL SSL issues #12293
Comments
Hi, thanks for your report and detailed research. Please see below... On 6/2/16 8:24 AM, Kordován Szabolcs wrote:
As far as I'm aware, PHP doesn't need MYSQLI_CLIENT_SSL when calling
There was some incompatibility between MySQL and OpenSSL (see [2]),
Interesting.
This also makes me think about some sort of OpenSSL problem.
From phpinfo() could you please provide your OpenSSL version? Mine is From the main page of phpMyAdmin, could you please provide "Database Regards, 1 - |
Hi, Sorry for delay. Server: fone2 (127.0.0.1 via TCP/IP) Apache/2.4.18 (Ubuntu) openssl OpenSSL support enabled If you have to authenticate with certification you use mysqli_ssl_set(). In this case you need private key and certification. But if you want only a secure communication (like https) you don't need these. Only need mysqli_client_ssl flag to use ssl. Regards, |
I really wonder how changing useOpenSSL can help in this case. When it's false, we use phpseclib, which prefers openssl as well, so you end up using same library, just through phpseclib and not directly... |
It seems that for some PHP versions this flag is needed even though it's not documented like this. Anyway this flag doesn't cause any harm, so lets keep it enabled. Issue #12293 Signed-off-by: Michal Čihař <michal@cihar.com>
I've added the MYSQLI_CLIENT_SSL flag. It indeed seems to be needed in some PHP versions. Unfortunately the handling of SSL connection in MySQL heavily depends on how PHP is compiled and what version is that and there seems to be case where the flag is needed. Anyway it doesn't cause any harm, so let's keep it added. |
Issue #12293 Signed-off-by: Michal Čihař <michal@cihar.com>
Reportedly fixed by above commit: Dne 9.6.2016 v 14:19 Kordován Szabolcs napsal(a):
|
I'm actually still experiencing this issue:
I get this with an AES-256-CBC key sent from MySQL Server. I use an intermediate and root CA combined in a PEM file. 2048 RSA is used for my server cert and key. Server type: MySQL C:\ProgramFiles\wamp\3.0.6_x64\apps\phpmyadmin4.6.4\libraries\plugins\auth\AuthenticationCookie.php
By not using OpenSSL in AuthenticationCookie.php, phpseclib is used. This is the only way I do not get the invalid key length error. .\phpmyadmin4.6.4\libraries\plugins\auth\AuthenticationCookie.php
Looking in phpseclib, openssl is used first if available, but what is also important is the key length is set based on the AES key size (note that key size is in bytes here, so 32 is 256 bit)
key_length is later used in
So the code should be adjusted to dynamically determine the key length (instead of just guessing AES-128-CBC) and maybe even scrap the custom useOpenSSL()altogether, phpseclib already seems to handle it. PS. I don't know PHP that well, so if you have to keep the useOpenSSL() for a specific reason then please explain. My fix for now is to |
The custom useOpenSSL logic is there to make the dependency on phpseclib optional (this was requested especially by Linux distributors). Anyway this looks like something is seriously broken in the PHP openssl or MySQL/ssl API as I really don't see why encrypting using some specific parameters should change settings used by MySQL driver. |
Okay, in the end it is bug in our code, but hidden by PHP API weirdness:
|
Issue #12293 Signed-off-by: Michal Čihař <michal@cihar.com>
Issue #12293 Signed-off-by: Michal Čihař <michal@cihar.com>
This ensures we generate compatible data in both cases. Issue #12293 Signed-off-by: Michal Čihař <michal@cihar.com>
Thanks for the prompt fix! I realize that mysqlnd should stay connected now, but won't I still be seeing the key_length error displayed in the UI all the time? Should we be using the same key lengths for the cookie encryption and the mysql connection to avoid these errors from consistently appearing? |
No, because I've fixed wrong key usage as well (in 30cd5fc). The problem is not in using different keys for different operations, the problem is that errors persist in the PHP's openssl layer - we did use wrong key length for our chosen cipher and it did set error message, which we did not pick up, but was later picked up by the mysqlnd driver. |
* Do not delete session on fatal error I see no reason why this should be done, the fatal error is used in following cases: * Very early when there is no session (eg. missing extension) * Invalid value for parameters * Invalid invocation like too big request In neither case session removal will do any good. Signed-off-by: Michal Čihař <michal@cihar.com> * Do not use control link when working with stored procedures Fixed stored procedure execution. Fixes phpmyadmin#12813 Signed-off-by: Michal Čihař <michal@cihar.com> * Fix early fatal errors We can not rely on whole stack being ready. Fixes phpmyadmin#12810 Signed-off-by: Michal Čihař <michal@cihar.com> * Fix display of custom header and footer in certain edge cases. Issues phpmyadmin#12801 and phpmyadmin#12802 Signed-off-by: Isaac Bennetch <bennetch@gmail.com> * Translated using Weblate (Dutch) Currently translated at 100.0% (3222 of 3222 strings) [CI skip] * Translated using Weblate (Dutch) Currently translated at 100.0% (3239 of 3239 strings) [CI skip] * Translated using Weblate (French) Currently translated at 100.0% (3222 of 3222 strings) [CI skip] * Translated using Weblate (French) Currently translated at 100.0% (3239 of 3239 strings) [CI skip] * Translated using Weblate (French) Currently translated at 100.0% (3222 of 3222 strings) [CI skip] * MySQL allows precision to be specified for DATETIME, TIME type fields too Fix phpmyadmin#12814 Ref : http://dev.mysql.com/doc/refman/5.7/en/fractional-seconds.html Signed-off-by: Deven Bansod <devenbansod.bits@gmail.com> * ChangeLog for phpmyadmin#12814 Signed-off-by: Deven Bansod <devenbansod.bits@gmail.com> * Share code for cascading ajax flag Signed-off-by: Michal Čihař <michal@cihar.com> * Get response instance just once Signed-off-by: Michal Čihař <michal@cihar.com> * Register shutdown directly on singleton instance This avoids additional call in the shutdown handler. Signed-off-by: Michal Čihař <michal@cihar.com> * Simplify checking for ajax request Signed-off-by: Michal Čihař <michal@cihar.com> * Include token in all filter requests Fixes phpmyadmin#12786 Signed-off-by: Michal Čihař <michal@cihar.com> * Fix documentation markup Signed-off-by: Isaac Bennetch <bennetch@gmail.com> * Hints about using Composer for library dependencies Signed-off-by: Isaac Bennetch <bennetch@gmail.com> * Use documentation link instead of wiki for Composer details Signed-off-by: Isaac Bennetch <bennetch@gmail.com> * Uncomment mistakenly commented Selenium testing setting Signed-off-by: Deven Bansod <devenbansod.bits@gmail.com> * Translated using Weblate (Spanish) Currently translated at 100.0% (3222 of 3222 strings) [CI skip] * Translated using Weblate (Spanish) Currently translated at 99.8% (3234 of 3239 strings) [CI skip] * Remove .htaccess from tests Issue phpmyadmin#12348 Signed-off-by: Michal Čihař <michal@cihar.com> * Add source release support See phpmyadmin#12348 Signed-off-by: Michal Čihař <michal@cihar.com> * Share code for rendering custom header and footer Fixes phpmyadmin#12802 Signed-off-by: Michal Čihař <michal@cihar.com> * Fix empty password login for http authetication Fixes phpmyadmin#12828 Signed-off-by: Michal Čihař <michal@cihar.com> * Honor user configured connection collation * the user set collation is now honored * default value has been changed to utf8mb4 * it is downgraded to utf8 if server does not support it Fixes phpmyadmin#12826 Signed-off-by: Michal Čihař <michal@cihar.com> * Fix HTTP auth test expectations Signed-off-by: Michal Čihař <michal@cihar.com> * Remove default value for js parameter The null is there implicitely anyway. Fixes phpmyadmin#12829 Signed-off-by: Michal Čihař <michal@cihar.com> * Add some missing html encoding Issue phpmyadmin#12804 Signed-off-by: Michal Čihař <michal@cihar.com> * Feature: phpmyadmin#12069: Filtering tables on table listing of particular database. Signed-off-by: Yunus Çağrı <ycagriyurdakul@gmail.com> * Feature: phpmyadmin#12069: Filtering tables on table listing of particular database. Signed-off-by: Yunus Çağrı <ycagriyurdakul@gmail.com> * Determine whether to use openssl just once Issue phpmyadmin#12293 Signed-off-by: Michal Čihař <michal@cihar.com> * Correctly report OpenSSL errors from cookie encryption Without calling openssl_error_string() we pollute openssl global state and some other library might report this as failure (eg. mysqlnd driver when connecting to SSL enabled server). Fixes phpmyadmin#12293 Signed-off-by: Michal Čihař <michal@cihar.com> * Use same encryption key with openssl and phpseclib Issue phpmyadmin#12293 Signed-off-by: Michal Čihař <michal@cihar.com> * Test both with and without phpseclib This ensures we generate compatible data in both cases. Issue phpmyadmin#12293 Signed-off-by: Michal Čihař <michal@cihar.com> * Use Header class for headers manipulation * Added mocking of response object * Rectified mistake of calling method once * implemented mock properly * replaced header with response header Issue phpmyadmin#12079 Signed-off-by: Osaid osaid.nasir@gmail.com * Inline javascript codes are removed. Each is used for table search Signed-off-by: Yunus Çağrı <ycagriyurdakul@gmail.com> * Update db_structure.js * Tab spaces are removed. Signed-off-by: Yunus Çağrı <ycagriyurdakul@gmail.com> * Unbind event on page unload Issue phpmyadmin#12838, phpmyadmin#12069 Signed-off-by: Michal Čihař <michal@cihar.com> * Use existing filtering template for table filtering Issue phpmyadmin#12838, phpmyadmin#12069 Signed-off-by: Michal Čihař <michal@cihar.com> * Changelog for issues phpmyadmin#12838 and phpmyadmin#12069 Signed-off-by: Michal Čihař <michal@cihar.com>
Okay, sounds all fixed :) Thanks. |
Hi, I come to this issue to report this fix is work for me ... and request another fix My case is try to connect to AWS RDS with SSL by mysqli same problem/error message was reported at here(the mailing list), #11553 and #12146
After login by correct username and password
when I go back to login page, this message come up
before apply this fix, 2 step to "quick fix" my problem
libraries/dbi/DBIMysqli.php
libraries/plugins/auth/AuthenticationCookie.php
And now, this fix is fixed by a correct way on my step 2 (different key to use on openssl) Thank you very much |
I'm wondering if you actually got the latest code that has the fix, because I don't think 4.6.6 is released yet, unless you got their latest dev code from GitHub. The That being said you bring an excellent point on if ($cfg['Server']['ssl']) {
$client_flags |= MYSQLI_CLIENT_SSL;
if (!empty($cfg['Server']['ssl_key'])) {
mysqli_ssl_set(
$link,
$cfg['Server']['ssl_key'],
$cfg['Server']['ssl_cert'],
$cfg['Server']['ssl_ca'],
$cfg['Server']['ssl_ca_path'],
$cfg['Server']['ssl_ciphers']
);
} SSL verification of the CA should not just depend on the client having a private key, maybe the client just wants to verify the server. This is a security flaw in |
Certainly it's another bug in the code. I'd really prefer if new issues got reported separately as this issue is covering more and more bugs... Also I don't think it's security flaw - it will use only system built in certification authorities to verify the certificate and it will refuse to connect if it fails to do so. |
From the mailing list at https://lists.phpmyadmin.net/pipermail/developers/2016-June/019564.html
Hi,
I had a problem with secure connection to sql server.
I use mysqli extension, I configured
server['ssl'] = true
. I have a user 'szabolcs' in sql who needs ssl.First I received
After this I got the following error:
PMA uses openssel functions to encrypt values in cookie if openssl functions exist, other case PMA uses Crypt\AES. With Crypt\AES PMA works fine.
I don't know the exact source of this problem. I think openssl functions have a bug.
Because the mysqli connection with ssl is successful After connection in common.inc.php
$auth_plugin->storeUserCredentials()
is called. This function stores the username and password and other parameters into cookie. To encrypt:I think the problem is that openssl_encrypt change the cipher to AES-128-CBC globally. It means the cipher of mysqli connection is also modified. This is why mysqli_query failed after encryption.
Here is my solution:
Regards,
Szabolcs
The text was updated successfully, but these errors were encountered: