How can I prevent Apache from exposing a user's password?

Posted by Marius Marais on Server Fault See other posts from Server Fault or by Marius Marais
Published on 2010-06-04T09:53:01Z Indexed on 2010/06/06 12:12 UTC
Read the original article Hit count: 178

Filed under:
|

When using basic authentication (specifically via LDAP, but htpasswd also) with Apache, it makes the REMOTE_USER variable available to the PHP / Ruby / Python code underneath -- this is very useful for offloading authentication to the webserver.

In our office environment we have lots of internal applications working like this over SSL, all quite secure. BUT: Apache exposes the PHP_AUTH_USER (=REMOTE_USER) and PHP_AUTH_PW variables to any application inside PHP. (PHP_AUTH_PW contains the plaintext password the user entered.) This means it's possible for the app to harvest usernames and passwords. Presumably the same information is available to Python and Ruby (all three are currently in use; PHP is being phased out).

So how can I prevent Apache from doing this?

One idea is to use Kerberos Negotiate authentication (which does not expose the password and has the benefit of being SSO), but that automatically falls back to Basic for some browsers (Chrome and in some cases Firefox), causing the password to be exposed again.

© Server Fault or respective owner

Related posts about apache

Related posts about authentication