1

We are running a web application in python using wsgi with apache2, and must submit to a penetration test. The testers will be exploring the potential for damage if the attackers gain shell access as the apache user.

Currently, the damage potential is enormous, as we have the credentials for the database, s3 service, etc. all stored in a text file readable by the apache user. This seems to be the default advice when setting up these sorts of applications, but is there a more secure way to do this?

I was thinking of using apache (as root) to pass environment variables with setenv to the wsgi app, but is this actually more secure? Any advice for this?

Thanks!

Will
  • 111
  • 3

2 Answers2

2

Make the apache user a no shell user:

Example:

chsh -s /sbin/nologin apache
JMC
  • 506
  • 6
  • 23
0

mod_wsgi has the ability to run as another user, so implement it and set up filesystem permissions appropriately.

If apache runs as root, make it drop privileges too and run under yet another account with no access to the wsgi files.

I wonder if you have to assess the damage incurred by the mod_wsgi use getting shelled :)

Edit: beware, chsh'ing apache user to nologin will not prevent shell access should the Apache process get hit by an exploit. I'd look into selinux if that's a major issue.

NekojiruSou
  • 344
  • 1
  • 2
  • 9