Simple Machines Community Forum

SMF Support => SMF 2.0.x Support => Topic started by: Am' on May 11, 2010, 02:13:24 PM

Title: secure the Settings.php file
Post by: Am' on May 11, 2010, 02:13:24 PM
Hi,


someone knows how to secure the Settings.php file?

e.g. rename and move it to the /Sources folder ...

is it possible?

Thank you in advance
Title: Re: secure the Settings.php file
Post by: Chas Large on May 13, 2010, 05:56:33 AM
This should be safe to leave where it is as it's protected by your forum's .htaccess file.
Title: Re: secure the Settings.php file
Post by: Arantor on May 13, 2010, 10:44:02 AM
Can I ask what you hope to achieve by it?

Apart from the fact you will need to modify multiple places in SMF, and the file needs to be writable at times for handling changes like maintenance mode, there is a larger problem.

It contains your passwords, sure enough. But the user Apache runs as must be able to read the files. That means it has to be accessible by Apache, along with all the other files. No matter where you move it to, it's still potentially going to be available to any other user on a shared server - it's not avoidable, unless the host has properly locked everything down, in which case moving it still doesn't really benefit you.
Title: Re: secure the Settings.php file
Post by: Son of Man on May 14, 2010, 04:31:05 PM
What I would like to know is if the info contained in that file can be used by a hacker to modifiy, damage, or delete the forum. 
Title: Re: secure the Settings.php file
Post by: Chas Large on May 14, 2010, 04:45:04 PM
Potentially yes, BUT only if they could gain access to it. They would need to get past the .htaccess file if they were just browsing or as Arantor stated, they would need to have root access to a shared server if the forum was hosted on a shared server.

If it was at all doubtful about the security of this file then there would be no SMF forums working anywhere, they'd all be hacked.

There is no need to worry about it.
Title: Re: secure the Settings.php file
Post by: Arantor on May 14, 2010, 04:51:42 PM
Quote from: Chas Large on May 14, 2010, 04:45:04 PM
Potentially yes, BUT only if they could gain access to it. They would need to get past the .htaccess file if they were just browsing or as Arantor stated, they would need to have root access to a shared server if the forum was hosted on a shared server.

If it was at all doubtful about the security of this file then there would be no SMF forums working anywhere, they'd all be hacked.

There is no need to worry about it.

No, I think you misunderstand me.

On a *badly configured* host, it is a RAMPANT problem. The bulk of sites that get "hacked" are because the host hasn't secured the server properly so anyone can read/write the files in SMF and inject malicious code. To be fair some shared servers are OK. Some really aren't, and the worst oversellers tend to be in this category.

Funnily enough, Settings.php tends to get ignored because it's easier to modify user visible files to spread malicious payload.

Properly configured hosts lock down who can read/write files, meaning two users on the same system can't read each other's files.
Title: Re: secure the Settings.php file
Post by: Son of Man on May 14, 2010, 10:16:29 PM
Quote from: Chas Large on May 14, 2010, 04:45:04 PM
There is no need to worry about it.

Thanks, Chas!  : )
Title: Re: secure the Settings.php file
Post by: Son of Man on May 15, 2010, 09:49:44 PM
A guy named Steve told me that when SMF crashes, backups up these files are created and that anyone who knows where to look will be able to find and read them.  For example, the Settings.php file is off-limits to visitors of the forum, but Settings.php~ backup file can be viewed by anyone.  The impression that I've got so far is that if i found a forum with a viewable to anyone Settings.php~ backup file, then it's no problem, right??? 

Also, does SMF have a setting to keep that file from being generated?
Title: Re: secure the Settings.php file
Post by: busterone on May 15, 2010, 10:33:24 PM
Not on a correctly set up host, it will not display to anyone via http. You need ftp access and the right credentials to view that file.
Title: Re: secure the Settings.php file
Post by: Son of Man on May 16, 2010, 12:10:15 AM
Then it looks like his host is not set up correctly, because I can read the backup of that file.  It contains his database name, database username, and database password. 

Thanks for all the help, guys.  : )
Title: Re: secure the Settings.php file
Post by: busterone on May 16, 2010, 12:49:39 AM
Definitely set up wrong. His site is a hacker's paradise waiting to be taken over.
Title: Re: secure the Settings.php file
Post by: Kays on May 16, 2010, 04:32:37 AM
Quote
For example, the Settings.php file is off-limits to visitors of the forum, but Settings.php~ backup file can be viewed by anyone.  The impression that I've got so far is that if i found a forum with a viewable to anyone Settings.php~ backup file, then it's no problem, right???

A file with a tide "~" after it is created as a backup by a mod. The standard Settings backup file is called Settings_bak.php and should not be accessible. There should not be a Settings.php~ file at the root of one's forums.
Title: Re: secure the Settings.php file
Post by: Am' on May 16, 2010, 04:33:06 AM
how protect settings.php and settings_back.php with a htacces ? What are the risks (operating smf) if I do that?
Title: Re: secure the Settings.php file
Post by: Kays on May 16, 2010, 04:45:56 AM
That should work. Create an .htaccess file add the following to it and place it at the root of your forums.


Options -indexes

<Files Settings.php>
order allow,deny
deny from all
</Files>

<Files Settings_bak.php>
order allow,deny
deny from all
</Files>
Title: Re: secure the Settings.php file
Post by: Am' on May 16, 2010, 04:48:04 AM
ok thx

why "Options -indexes" ?
Title: Re: secure the Settings.php file
Post by: Kays on May 16, 2010, 04:54:50 AM
If there's no index file in a folder, it will display the file and folder listing if people access it directly. This will prevent people from browsing folders without an index file. Just an extra precaution I like to take
Title: Re: secure the Settings.php file
Post by: Am' on May 16, 2010, 05:06:31 AM
ok

it should be placed by default in the all package smf ....
Title: Re: secure the Settings.php file
Post by: Kays on May 16, 2010, 05:31:46 AM
Place it at the root of your forums. The same place as Settings.php.
Title: Re: secure the Settings.php file
Post by: Am' on May 16, 2010, 06:14:36 AM
Quote from: Kays on May 16, 2010, 05:31:46 AM
Place it at the root of your forums. The same place as Settings.php.

yes i  know

it's a proposition for a Feature Requests  :P :P
Title: Re: secure the Settings.php file
Post by: Arantor on May 16, 2010, 06:33:44 AM
Firstly, Settings.php~ can only be created if either a) a mod changes Settings.php directly (which it shouldn't, ever) or b) a user edits it manually (whereupon most hosts create the file automatically)

If the host is properly configured, browsing Settings.php or Settings_bak.php will achieve nothing. The *only* circumstance where it would is if the server is drastically misconfigured and isn't processing PHP at all. In which case you've probably got bigger things to worry about anyway.