password in php document
Moderator: General Moderators
password in php document
I'm a new user of php and mysql, and
have a question that concerns me about security. When writing the php document to
connect to mysql, the password is written in the document itself. This is not a problem for outside sites since the php engine processes the documents. But how do I protect the password from internal users? Since it's served out by the server, it has the word read permission so users on the system could determine where it was located and read the file. Is there a way to keep from placing the password in the document?
have a question that concerns me about security. When writing the php document to
connect to mysql, the password is written in the document itself. This is not a problem for outside sites since the php engine processes the documents. But how do I protect the password from internal users? Since it's served out by the server, it has the word read permission so users on the system could determine where it was located and read the file. Is there a way to keep from placing the password in the document?
- Johnm
- Forum Contributor
- Posts: 344
- Joined: Mon May 13, 2002 12:05 pm
- Location: Michigan, USA
- Contact:
First, storing it outside the web tree is a good idea but chmod 711 file.php will allow it to be executed by anyone but only read by the owner and root. Make the owner root and things are pretty locked down.
make it a dot file ex:( mv file.php .file.php) and it makes the file a little more discrete.
John M
make it a dot file ex:( mv file.php .file.php) and it makes the file a little more discrete.
John M
permissions on php files
I've tried only having execute access on
the php file, however the server won't pick up the file and execute it without the world read permission. Moving it out of the www tree is an idea that I can try, but the problem is that I would still have to give permission for the web server user to access the file, and users on the system would be able to read the file and determine where I hid the portion with the password.
the php file, however the server won't pick up the file and execute it without the world read permission. Moving it out of the www tree is an idea that I can try, but the problem is that I would still have to give permission for the web server user to access the file, and users on the system would be able to read the file and determine where I hid the portion with the password.
Just off the top of my head, and I'm not really familiar with this stuff so if I'm beeing stupid tell me 
If the user running the web-server is the only user having read-access to the file how would someone go about reading it directly from the file-system and not through apache?
If read through apache it won't show the code anyhow (as long as the file is named .php that is)
Am I way off here, and if so, why?
I would like an answer to this as well
If the user running the web-server is the only user having read-access to the file how would someone go about reading it directly from the file-system and not through apache?
If read through apache it won't show the code anyhow (as long as the file is named .php that is)
Am I way off here, and if so, why?
I would like an answer to this as well
permissions
The reason for the world read permission
is that the apache server is running as
user nobody, the least privileged user on
the system. In order for a file to be served
out by the server, it must have permissions
that allow nobody to read it. One partial fix would be to make nobody the ower of the
php file, but this will not work as a full solution because I (as sysadmin) can change the owner of the file to nobody, but
other users can't. I really like the way php and mysql work, but there is sensitive data
stored in the databases I will be using so I want to make sure that I am the only one that can access the database.
is that the apache server is running as
user nobody, the least privileged user on
the system. In order for a file to be served
out by the server, it must have permissions
that allow nobody to read it. One partial fix would be to make nobody the ower of the
php file, but this will not work as a full solution because I (as sysadmin) can change the owner of the file to nobody, but
other users can't. I really like the way php and mysql work, but there is sensitive data
stored in the databases I will be using so I want to make sure that I am the only one that can access the database.
Hmmm...
But how can a users access the web-tree on the server without going through apache?
I guess the web-tree isn't NFS-shared and the users usually don't have physical access to the server.
Of course, if the users have access to a shell on the server....do they?
Would then a dedicated web-server with no shell-access be a sollution?
What about serving those particular files from a dedicated, yet outdated, machine with read-access only to the web-server? Or from a NFS-share readable only from the IP of the web-server?
I'm reaching, I know, but I see the problem and that I may be faced with it, so I try to understand, ok?
Rincewind
But how can a users access the web-tree on the server without going through apache?
I guess the web-tree isn't NFS-shared and the users usually don't have physical access to the server.
Of course, if the users have access to a shell on the server....do they?
Would then a dedicated web-server with no shell-access be a sollution?
What about serving those particular files from a dedicated, yet outdated, machine with read-access only to the web-server? Or from a NFS-share readable only from the IP of the web-server?
I'm reaching, I know, but I see the problem and that I may be faced with it, so I try to understand, ok?
Rincewind
web tree
The problem with isolating the files is that the users on the system are allowed to have their own web space, and they would be presented with the same problem since there has to be access for the webuser to read the php file.
server
The problem with that is it won't work for
other users on the system. The only
solution I can come up with is to write a
setuid program that users on the system
can filter their files through that will set the
user to the webuser.
other users on the system. The only
solution I can come up with is to write a
setuid program that users on the system
can filter their files through that will set the
user to the webuser.
- Johnm
- Forum Contributor
- Posts: 344
- Joined: Mon May 13, 2002 12:05 pm
- Location: Michigan, USA
- Contact:
Multiple files with a script to ensure that they are updated properly?
Just a thought. You can define access to each users web space directory specifically.
I guess that I am not sure that I understand the problem as we have multiple websites for our business with specific permissions even down to the user level to control who sees what and when.
John M
Just a thought. You can define access to each users web space directory specifically.
I guess that I am not sure that I understand the problem as we have multiple websites for our business with specific permissions even down to the user level to control who sees what and when.
John M