Encrypted password causes segmentation fault
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
libapache2-mod-auth-pgsql (Debian) |
Fix Released
|
Unknown
|
|||
libapache2-mod-auth-pgsql (Ubuntu) |
Fix Released
|
High
|
Andreas Hasenack | ||
Trusty |
Fix Released
|
High
|
Andreas Hasenack | ||
Xenial |
Fix Released
|
High
|
Andreas Hasenack | ||
Zesty |
Fix Released
|
High
|
Andreas Hasenack |
Bug Description
[Impact]
The libapache2-
Since this is an apache module, users might be tempted to use htpasswd(1) to generate such hashes. The option to generate SHA hashes (-s) in particular will generate a hash incompatible with crypt(3), which will then return NULL and cause the segfault in unpatched versions of this apache module.
The fix catches the situation when crypt(3) returns NULL and logs the event as an unsupported hash type being found, and denies the login.
[Test Case]
* install the packages on the Ubuntu release you are testing:
$ sudo apt install apache2 libapache2-
* create the database and populate it with the test users from the attached test-users.sql file:
$ sudo -u postgres -H createdb userdb
$ sudo -u postgres -H psql userdb -f test-users.sql
* Create the DB user we will use:
$ sudo -u postgres -H psql postgres -c "CREATE ROLE www UNENCRYPTED PASSWORD 'password' NOSUPERUSER NOCREATEDB NOCREATEROLE INHERIT LOGIN;"
* Grant access:
$ sudo -u postgres -H psql userdb -c "GRANT SELECT ON TABLE userlogin TO www;"
* Create the /var/www/
AuthType basic
AuthName "My Auth"
Require valid-user
AuthBasicProvider pgsql
Auth_PG_
Auth_PG_host 127.0.0.1
Auth_PG_port 5432
Auth_PG_user www
Auth_PG_pwd password
Auth_PG_database userdb
Auth_PG_encrypted on
Auth_PG_pwd_table UserLogin
Auth_PG_uid_field Username
Auth_PG_pwd_field ApachePassword
* Setup access in apache by editing /etc/apache2/
<Directory /var/www/html>
AllowOverride AuthConfig
</Directory>
* Enable the mod-auth-pgsql module:
$ sudo a2enmod 000_auth_pgsql
* Restart apache:
$ sudo service apache2 restart
To try each test login, use a loop like this:
$ for u in ubuntu-invalidhash ubuntu-md5 ubuntu-sha256 ubuntu-sha512 ubuntu-des; do echo -n "Testing $u... "; curl -f http://
Testing ubuntu-
Testing ubuntu-md5... 0
Testing ubuntu-sha256... 0
Testing ubuntu-sha512... 0
Testing ubuntu-des... 0
Error 52 means "empty reply from server". That's when apache segfaulted:
[Wed Jul 19 19:28:13.808711 2017] [core:notice] [pid 9499:tid 140330145511296] AH00051: child pid 9677 exit signal Segmentation fault (11), possible coredump in /etc/apache2
With the fixed version of libapache2-
$ for u in ubuntu-invalidhash ubuntu-md5 ubuntu-sha256 ubuntu-sha512 ubuntu-des; do echo -n "Testing $u... "; curl -f http://
Testing ubuntu-
Testing ubuntu-md5... 0
Testing ubuntu-sha256... 0
Testing ubuntu-sha512... 0
Testing ubuntu-des... 0
And we get this fact logged:
[Wed Jul 19 19:38:56.547337 2017] [auth_pgsql:error] [pid 10035:tid 140550732678912] [client 127.0.0.1:56946] [mod_auth_pgsql.c] - ERROR - PG user ubuntu-invalidhash: unsupported CRYPT format
[Regression Potential]
The patch seems pretty straight forward and uses a well documented crypt(3) return value in the case of errors.
This is a very old module that hasn't been built in a while (see [other info] below. It's possible that just by rebuilding it with the new environment available in each ubuntu release since vivid could introduce unknowns. Hopefully, if that happens, it will be immediately noticed by the people who use it and will test this SRU.
[Other Info]
Upstream doesn't have a bugtracker or public code hosting that I could find, so I forwarded the patch via email. No response so far.
This module hasn't been rebuilt since vivid and seems unmaintained, being at version 2.0.3 since the precise days:
libapache2-
libapache2-
libapache2-
libapache2-
libapache2-
libapache2-
libapache2-
- Debian's last changelog entry is from August 2013
- Fedora killed it in July 2011
- I couldn't find it in SuSE
Changed in apache2 (Ubuntu): | |
assignee: | nobody → Andreas Hasenack (ahasenack) |
status: | Triaged → In Progress |
Changed in libapache2-mod-auth-pgsql (Debian): | |
status: | Unknown → New |
Changed in libapache2-mod-auth-pgsql (Ubuntu): | |
status: | In Progress → Fix Committed |
Changed in libapache2-mod-auth-pgsql (Ubuntu Trusty): | |
assignee: | nobody → Andreas Hasenack (ahasenack) |
Changed in libapache2-mod-auth-pgsql (Ubuntu Xenial): | |
assignee: | nobody → Andreas Hasenack (ahasenack) |
Changed in libapache2-mod-auth-pgsql (Ubuntu Zesty): | |
assignee: | nobody → Andreas Hasenack (ahasenack) |
Changed in libapache2-mod-auth-pgsql (Ubuntu Trusty): | |
status: | New → In Progress |
Changed in libapache2-mod-auth-pgsql (Ubuntu Xenial): | |
status: | New → In Progress |
Changed in libapache2-mod-auth-pgsql (Ubuntu Zesty): | |
status: | New → In Progress |
Changed in libapache2-mod-auth-pgsql (Ubuntu Trusty): | |
importance: | Undecided → High |
Changed in libapache2-mod-auth-pgsql (Ubuntu Xenial): | |
importance: | Undecided → High |
Changed in libapache2-mod-auth-pgsql (Ubuntu Zesty): | |
importance: | Undecided → High |
description: | updated |
description: | updated |
description: | updated |
description: | updated |
description: | updated |
description: | updated |
description: | updated |
description: | updated |
tags: |
added: verification-done removed: verification-needed |
tags: | removed: server-next |
Changed in libapache2-mod-auth-pgsql (Debian): | |
status: | New → Fix Released |
Confirmed in my xenial testing:
==> /var/log/ apache2/ error.log <==
[Tue Jun 20 18:44:20.612899 2017] [core:notice] [pid 7038:tid 140431534086016] AH00051: child pid 7041 exit signal Segmentation fault (11), possible coredump in /etc/apache2