Author Topic: not sure  (Read 472 times)

Offline toxin

  • Level 20
  • *
  • Posts: 225
  • Reputation: +4/-2
    • View Profile
    • Encore Montreal
not sure
« on: March 16, 2010, 06:59:30 AM »
Is there a way to stop php from creating a file in a directory above the one it is in?
An example say i am on a host that has a path /home/dir1/hostsite.com/website.com
and in it a user places a script to write a file to /dir1/hostsite.com they now have a script they can use on hostsite.com to access and see other sites that may be hosted. A way around this I know of is to have my Main reselling host domain not be the one that is the this way they can not get to the url to run the script.

At this time not anything to do with my game but later on once i get it up I was thinking as a perk for guilds is to set up domain and host a SMF forum on it for them to use and link users info on it. SMF has a few additions that allow php to be used so this is something that can go bad if not not done right. The could just mod the themes to hack there way up. Hope any that read understands. I think the attack is http://en.wikipedia.org/wiki/Directory_traversal or something like it.


Offline Chris

  • Game Owner
  • Level 35
  • *
  • Posts: 2,134
  • Reputation: +26/-1
    • View Profile
Re: not sure
« Reply #1 on: March 16, 2010, 07:15:48 AM »
Letting users put php file on the same server the game is (no matter what restrictions you set) is a suicide. Make a subdomain and host it on a separate cheap sharedhost, then they can wreak havoc to their hearts' content.

Restriction of where a file can be created is almost irrelevant, php on its own is dangerous enough to hack as you want if you have access to it.

Offline dsheroh

  • Level 21
  • *
  • Posts: 235
  • Reputation: +6/-0
  • Perl Vicar
    • View Profile
    • Psi Rangers
Re: not sure
« Reply #2 on: March 16, 2010, 07:54:32 AM »
I'm not familiar with SMF, but it's possible that it may restrict users to a whitelisted subset of "known safe" PHP commands, in which case it could be secure, if done correctly and rigorously.  If not, then Chris's answer is pretty accurate:  Allowing untrusted users to install and execute arbitrary code (PHP or otherwise) is security suicide.

As for the actual question of limiting access to various paths, it would be possible to arrange something like that using some combination of Apache suexec, selinux ACLs, and/or chroot, but you'd really have to know what you're doing in order to give enough access to be functional without also giving enough access to be trivially exploitable.  If you're asking the question here, I'm going to assume that your sysadmin skills aren't up to the task, so I'll second Chris's recommendation to leave it to the professionals at the hosting companies.

Offline JGadrow

  • Level 35
  • **
  • Posts: 1,133
  • Reputation: +23/-2
    • View Profile
Re: not sure
« Reply #3 on: March 16, 2010, 08:13:07 AM »
This might sound like a stupid question but... Why not customize a forum a little to integrate it with your game? This would have the guild forum open up if that player is in a guild. In this way, each guild could have their own forum as you desire but you don't open up the security vulnerabilities.

Just a thought.
Idiocy - Never underestimate the power of stupid people in large groups.


Offline toxin

  • Level 20
  • *
  • Posts: 225
  • Reputation: +4/-2
    • View Profile
    • Encore Montreal
Re: not sure
« Reply #4 on: March 16, 2010, 08:54:32 AM »
@Chris Was not going to have it on same server as game that part i got on my own. I have a reseller account from a site and was going to set up on it apart from the game. I was just wanting to see if there was away so that the users do not destroy each others sites.

@dsheroh I have only did one real test for the SMF so there can be other salutations to have it where they can not use or restrict php usage on it. the only test i did what placed a file on one domain to write a file to a directory above that is on another domain. I am sure that is just one of many things that can go wrong. I read about chroot and got lost on it I also do not have root access so can not do.

@JGadrow Yes i have seen this on a few games and it works. The forum was just the start I was wanting to host players sites also. It may not even have anything to do with the game. Something like buy web hosting and domain for a year for $100. They get a web site and the game makes a little extra money.


I will just have to set it all up where the have no access to server.

 


SimplePortal 2.3.3 © 2008-2010, SimplePortal