[MDEV-19882] pam v2: auth_pam_tool truncates passwords that are not null-terminated Created: 2019-06-27 Updated: 2021-02-12 Resolved: 2019-10-28 |
|
| Status: | Closed |
| Project: | MariaDB Server |
| Component/s: | Plugin - pam |
| Affects Version/s: | 10.4.6, 10.4.8 |
| Fix Version/s: | 10.4.9 |
| Type: | Bug | Priority: | Major |
| Reporter: | Geoff Montee (Inactive) | Assignee: | Sergei Golubchik |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | None | ||
| Issue Links: |
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Description |
|
In MariaDB 10.4, version 2 of the pam plugin is provided. This plugin forks a new process and executes the auth_pam_tool utility that is now bundled with the server. Unfortunately, it seems to truncate passwords that are not null-terminated, because it always seems to assume that the last character is the NULL terminator. This is a problem because some implementations of mysql_clear_password don't seem to null-terminate passwords. The problem is fairly easy to reproduce. Configuring PAMWe can configure PAM using the steps from MDEV-19877. Create a Unix user account and set a password for the user:
Create the PAM service configuration:
And then you might need to execute some commands to work around
Configuring MariaDBWe can configure PAM to use PAM authentication for this user account using the steps from MDEV-19877. Let's install the pam plugin:
And let's create the relevant user:
Constructing the InputWe can construct the input for the auth_pam_tool tool using the information from MDEV-19877. Let's assume that the alice user's password is uGBXHxID3dJRALw2. Let's create input with a null-terminated password:
And let's also create input with a password that is not null-terminated:
And then confirm the contents of each file:
Running the ToolNext, we can run the auth_pam_tool tool and redirect the tool's stdin to the input files that we constructed. We can also attach strace to the process, so we can passwords the tool is reading and writing. First, run the tool with the good input:
The null-terminated password is properly read and passed to PAM:
Next, run the tool with the bad input:
The non-null-terminated password is properly read, but its last character is truncated when it is passed to PAM:
Checking SyslogThe syslog (i.e. /var/log/secure on RHEL or /var/log/auth.log on Debian/Ubuntu) also shows an authentication failure, since the auth_pam_tool
|
| Comments |
| Comment by Sergei Golubchik [ 2019-06-30 ] |
|
I didn't try to repeat all these steps with strace, but I tried a 64-character password and it worked. |
| Comment by Geoff Montee (Inactive) [ 2019-10-15 ] |
|
This bug is still present. See |
| Comment by Daniel Black [ 2021-02-12 ] |
|
Upstream php-7.4+ fix approved - https://github.com/php/php-src/pull/6667 |