The author helps with an Apache rule: Order allow,deny Deny from all What would be the equivalent of this for Nginx?
location ~ "(^#.*#|~|\.sw[op])$" { return 401; } Or something along those lines. Nodesocket's answer is good as well: http://news.ycombinator.com/item?id=5164017
1% of CMS-Powered Sites Expose Their Database Passwords (2011)
51–60 of 94 posts
Re: 1% of CMS-Powered Sites Expose Their Database Passwords (2011)
#52Re: 1% of CMS-Powered Sites Expose Their Database Passwords (2011)
#53How utterly stupid do you have to be to engineer software that requires you to have configuration files in a publicly accessible folder? Even most shared hosts now will have a public_html folder and the ability to put sensitive stuff not inside it. The .htaccess hacks are great but they are just patching the symptom, and one slip up and you're back to square one. The best way to do configuration is to have it in envi…
Complete untrue. You can (and are advised to) move your wp-config.php above public_html. The reason its not done by default is because you just can't do this on many of the crappy hosting services, and it creates a barrier for entry for people making their first-ever site.
Re: 1% of CMS-Powered Sites Expose Their Database Passwords (2011)
#54The fundamental problem with many PHP applications is that the php files are located in document root, i.e. can be potentially served as static files. More correct approach would be to put them outside document root (e.g. APP_DIR/lib), and using index.php which requires them (e.g. APP_DIR/static/index.php).
That's not restricted to PHP, since it does not even depend on the language.
Re: 1% of CMS-Powered Sites Expose Their Database Passwords (2011)
#55The fundamental problem with many PHP applications is that the php files are located in document root, i.e. can be potentially served as static files. More correct approach would be to put them outside document root (e.g. APP_DIR/lib), and using index.php which requires them (e.g. APP_DIR/static/index.php).
For example with a Symfony app:
. - App root
./web/ - httpd doc root
./app/ - app files
./app/config/ - config files
Barring an exploit that lets you break out of the httpd doc root (not saying this is impossible), there is no way to request the config or app files directly.
Re: 1% of CMS-Powered Sites Expose Their Database Passwords (2011)
#56Earlier quoted context omitted.
A solution using xargs instead of exec: find . -name "*.swp" | xargs rm I believe find -exec forks and execs once for every file found, xargs may only fork and exec once, provided that all of the files find finds fit in a single command line. Hopefully not an issue in this case, but it can greatly speed up a deletion when you have a lot of files to find and delete. [EDIT] Doesn't properly handle spaces in filenames,…
Please don't run the command above, it doesn't handle spaces. You might delete something you didn't intend to delete. You need to add -print0 to find, and -0 to xargs to make it work properly: find . -name "*.swp" -print0 | xargs -0 rm But better would be to use -delete as I wrote above.
Re: 1% of CMS-Powered Sites Expose Their Database Passwords (2011)
#57How utterly stupid do you have to be to engineer software that requires you to have configuration files in a publicly accessible folder? Even most shared hosts now will have a public_html folder and the ability to put sensitive stuff not inside it. The .htaccess hacks are great but they are just patching the symptom, and one slip up and you're back to square one. The best way to do configuration is to have it in envi…
How utterly stupid do you have to be to engineer software that requires you to have configuration files in a publicly accessible folder? Even most shared hosts now will have a public_html folder and the ability to put sensitive stuff not inside it. Complete untrue. You can (and are advised to) move your wp-config.php above public_html . The reason its not done by default is because you just can't do this on many of t…
Re: 1% of CMS-Powered Sites Expose Their Database Passwords (2011)
#58Earlier quoted context omitted.
Excellent! Part of me wants to have a play and see how closely I can get a PHP/FPM/nginx to resemble my Python/uWSGI Emperor/nginx stack. You can do stuff like include /srv/*/pool.ini, right?
Yes you can. Dotdeb's php-fpm.ini even includes this line by default: ; To configure the pools it is recommended to have one .conf file per ; pool in the following directory: include=/etc/php5/fpm/pool.d/*.conf Then you could configure ENV inside FPM pool using the env directive: env[DB_HOST] = localhost env[DB_USER] = foobar env[DB_PASSWORD] = foobar ...and use something like this in e.g. Wordpress config: define('D…
Re: 1% of CMS-Powered Sites Expose Their Database Passwords (2011)
#59How utterly stupid do you have to be to engineer software that requires you to have configuration files in a publicly accessible folder? Even most shared hosts now will have a public_html folder and the ability to put sensitive stuff not inside it. The .htaccess hacks are great but they are just patching the symptom, and one slip up and you're back to square one. The best way to do configuration is to have it in envi…
Because your average graphics designer or blogger has no idea what Apache is, what public directories or file permissions are. They just want to run their own blog. That's why Wordpress (or PHP for that matter) is successful; it's easy to set up and get started.
Re: 1% of CMS-Powered Sites Expose Their Database Passwords (2011)
#60The author helps with an Apache rule: Order allow,deny Deny from all What would be the equivalent of this for Nginx?
location ~ "(^#.*#|~|\.sw[op])$" { return 401; } Or something along those lines. Nodesocket's answer is good as well: http://news.ycombinator.com/item?id=5164017
Simply giving the hacker less information (though not just depending on this) is a useful form of security. If you give them a 401, then they at least know that the file exists.