WebProWorld Part of WebProNews.com
Page One Link To Us Edit Profile Private Messages Archives FAQ RSS Feeds  
 

Go Back   WebProWorld > Webmaster, IT and Security Discussion > Internet Security Discussion Forum
Subscribe to the Newsletter FREE!


Register FAQ Members List Calendar Arcade Chatbox Mark Forums Read

Internet Security Discussion Forum This forum is for the discussion of security related issues. If you find a new Phishing scheme, spyware, virus or malicious site - let us know about it. If any of the above found you... here's where you ask for help.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 03-02-2007, 09:08 PM
edhan's Avatar
WebProWorld Veteran
 

Join Date: Aug 2003
Location: Singapore
Posts: 549
edhan RepRank 1
Default Security breach

My clients have installed programs on the web server that needs to give 777 permission. After checking, we discover that it has opened an opportunity for hacker to upload their spam files and have control over the server.

Is there any way of protecting the server where 777 permission is needed?
Reply With Quote
  #2 (permalink)  
Old 05-09-2007, 07:29 PM
WebProWorld New Member
 

Join Date: May 2007
Posts: 5
99debra99 RepRank 0
Default

You can try password protecting the file.

This can be done in your control panel of your hosting.
Reply With Quote
  #3 (permalink)  
Old 05-09-2007, 10:21 PM
edhan's Avatar
WebProWorld Veteran
 

Join Date: Aug 2003
Location: Singapore
Posts: 549
edhan RepRank 1
Default

The file needs to be written by the script, password protect will prevent it from updating.

I am wondering how the person can exploit it and upload files into the server.
Reply With Quote
  #4 (permalink)  
Old 05-10-2007, 05:01 AM
WebProWorld Pro
 

Join Date: Sep 2005
Location: Manchester, UK
Posts: 257
mikesmith76 RepRank 0
Default

just a quick note, you never need to set the permissions of any file / directory to 777 just to update them from php. Find out what user the script is running under and change the owner of the file in question, then you can set more restrictive permissions.
Reply With Quote
  #5 (permalink)  
Old 05-10-2007, 07:44 AM
edhan's Avatar
WebProWorld Veteran
 

Join Date: Aug 2003
Location: Singapore
Posts: 549
edhan RepRank 1
Default

I will check with him. He is using those CMS program where it is needed to set 777. I too have used some of those CMS program and also needs to set as 777. I did try to using 755 instead but it didn't work. So I have to set it as 777.
Reply With Quote
  #6 (permalink)  
Old 05-15-2007, 05:47 PM
wige's Avatar
Moderator
WebProWorld Moderator
 

Join Date: Jun 2006
Location: United States
Posts: 1,782
wige RepRank 4wige RepRank 4wige RepRank 4wige RepRank 4
Default

777 is usually not needed, and is typically recommended because it is easier than painstakingly going through and manually setting up individual permissions. Note also, setting the permissions to 777 can make the FILE vulnerable, but not the system. If an unauthorized user modified the file that was set as 777, they comprimised another service on the server first. Fix the permissions, yes, but also do a security audit ASAP to find what else got compromised. It may be something as simple as closing a port, or as bad as a script that does not do enough validation.
__________________
The best way to learn anything, is to question everything.
Reply With Quote
  #7 (permalink)  
Old 05-15-2007, 10:42 PM
edhan's Avatar
WebProWorld Veteran
 

Join Date: Aug 2003
Location: Singapore
Posts: 549
edhan RepRank 1
Default

As I am not a programmer so I can't really help much. Most of the BBs scripts require 777 permission for upload folder and cache folder. These are 3rd party software and it is stated in the install instructions to have the permission set 777 therefore leaving us no choice but to follow. Unless we do not want to use those scripts otherwise there is no other alternative. Do you know of any good scripts that does not require setting of 777?
Reply With Quote
  #8 (permalink)  
Old 05-17-2007, 05:10 PM
wige's Avatar
Moderator
WebProWorld Moderator
 

Join Date: Jun 2006
Location: United States
Posts: 1,782
wige RepRank 4wige RepRank 4wige RepRank 4wige RepRank 4
Default

My point is more that setting the file as 777 is not, in and of itself, a security hole. All the 777 setting does is say that any process or user on the computer/server can view/edit/delete the file. If a malicious user made changes, there are two possible reasons. Either the program that is intended to edit the file did a bad job of checking the data it was writing and allowed the bad data, or something else on your server has been attacked, and because of the 777 setting, the attacker was able to modify the file.

In most configurations, you want things like bulletin board files and log files to only be editeable by one or two programs - the ones that actually generate the forum or log the events - to prevent attackers from modifying the files after an attack. Developers often take a more lax approach to non-critical files, giving up a small amount of security in exchange for a program that is easier to install. In these cases, you can usually set the permissions to be more restrictive, even if the program's documentation indicates otherwise. You simply have to have a good working knowledge of the program and the operating system to set it up just right.

The primary concern at this point should be to determine how the file was modified, to prevent future issues. Unfortunately, since the file was set to 777, any service could have been used to make the changes. A security audit should be able to determine possible points of attack, though.
__________________
The best way to learn anything, is to question everything.
Reply With Quote
  #9 (permalink)  
Old 05-17-2007, 11:11 PM
edhan's Avatar
WebProWorld Veteran
 

Join Date: Aug 2003
Location: Singapore
Posts: 549
edhan RepRank 1
Default

Yes, I do agree that 777 permission expose to danger. But unfortunately most of the bbs script requires such setting. On several occasions, I attempt to change it to 666 or 755 but still without success. Therefore I am wondering since these scripts allow it to set 777, is there any way we can avoid being attack or how do we monitor if there is an attack being done?
Reply With Quote
  #10 (permalink)  
Old 05-18-2007, 10:56 AM
wige's Avatar
Moderator
WebProWorld Moderator
 

Join Date: Jun 2006
Location: United States
Posts: 1,782
wige RepRank 4wige RepRank 4wige RepRank 4wige RepRank 4
Default

Typically, what happens is you own or rent an off-site server that you upload your files to with FTP. The web server (usually Apache) then runs the forum scripts which try to edit the files you uploaded. The FTP program has one username, and the webserver has another. Unless the file you uploaded (which has an owner of your username, typically) is set to 777, the web server can't make the needed changes. Most servers, Apache uses the username and group "apache". If you have command line access (such as telnet) to the server, you can change the owner of the file using the chown command. After you upload the bbs files, chown them all so they are owned by the web server. That way the server can edit them as needed. HOWEVER, before you change the owner, use chmod and make sure read is set to all (7). Otherwise, after you change the owner, your FTP user will not be able to download the file. Also bear in mind, this change is final, you will not be able to delete or edit the file directly. You would actually have to create a script and upload it, and have the server delete the file.

As far as identifying the attack, this depends on the server and the method of the attack. What type of file was altered - a configuration file, a log, or a file containing bulletin board text? Also, do you have a shared or dedicated server, or is this a server you own?
__________________
The best way to learn anything, is to question everything.
Reply With Quote
  #11 (permalink)  
Old 05-18-2007, 02:52 PM
Vectorman211's Avatar
WebProWorld Member
 

Join Date: Jul 2006
Posts: 89
Vectorman211 RepRank 2
Default

The code in the script is handling the exception if it detects that the perms are not 0777. I would find this code and change it because there is NEVER a reason to set any file to 0777, ESPECIALLY directories.

Try this though:

chown username.apache /path_to_directory
chmod 0664 /path_to_directory

Where username = your username and path_to_directory = ....duh.

I don't think you'll need execute permissions right?

It is possible that apache does not run as the username apache on your webhost but in most cases it is.
__________________
http://www.wis-tech.net
Reply With Quote
Reply

  WebProWorld > Webmaster, IT and Security Discussion > Internet Security Discussion Forum
Tags: ,



Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Search Engine Optimization by vBSEO 3.2.0