PhpMyAdmin password_hash not matched from password_verify

52 views Asked by At

I searched a lot in web and in forum but I didn't find anything similar to my problem. I have a strange behavior of the function password_hash() used from phpMyAdmin when I manually add a new user.

If I insert the password and select the 'password_hash() PHP function' it produces an hash that then isn't verified from the php login script. enter image description here

If instead I crate the password within a test script like this

<?php
$a='123456789!';
echo password_hash($a, PASSWORD_DEFAULT);

and then I paste the hash into DB value it works.

In addition I made test creating the pasword in localhost environment with a test script (equal to the above one runned in the server) and by adding the value from phpMyAdmin hashing the value. Copying and pasting both passwords into server's DB makes the login work.

I also tried this script for testing hash (locally and in the server)

<?php
$pwd='123456789!';
$hash_remote = '$2y$10$sRLWZPLAYO0zz1i9xPARpe/hHOPOrZBeXrmTn9y/sewmsNX/dPKvi';
$hash_locale = '$2y$10$j1meOOT0AOpeeqNKcnieFe1ODKng42TmRwEGO.8/gja381WOKOIbu';
$hash_remote_php = '$2y$10$s8wSV3ZL/1yBFwt5nBTZX.PybeY3HG3w2SuCG4DsRY3ricvl8vc/K';
$hash_locale_php = '$2y$10$d8PErNifkli97BPLMDalYOXaQuZI25O.LWdAj4ImEdbBPdbIsogpC';

if (password_verify($pwd,$hash_remote)){
    echo "Remote Hash phpMyAdmin OK".PHP_EOL;
}else{
    echo "Remote Hash phpMyAdmin KO".PHP_EOL;
}

if (password_verify($pwd,$hash_locale)){
    echo "Locale Hash phpMyAdmin OK".PHP_EOL;
}else{
    echo "Locale Hash phpMyAdmin KO".PHP_EOL;
}

if (password_verify($pwd,$hash_remote_php)){
    echo "Remote Hash PHP OK".PHP_EOL;
}else{
    echo "Remote Hash PHP KO".PHP_EOL;
}

if (password_verify($pwd,$hash_locale_php)){
    echo "Locale Hash PHP OK".PHP_EOL;
}else{
    echo "Locale Hash PHP KO".PHP_EOL;
}

but result are always the same:

Remote Hash phpMyAdmin KO
Locale Hash phpMyAdmin OK
Remote Hash PHP OK
Locale Hash PHP OK

At this point I think is some configuration problem/difference, but i can't figure out what it can be.

The versions of the PHP/MariaDB are

LocalHost: PHP 8.0.30 | 10.4.32-MariaDB (windows 11)

ProductionServer: PHP 8.1.2-1ubuntu2.14 | 10.6.16-MariaDB (ubuntu 22.04)

0

There are 0 answers