The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Restricting PHP file names

Discussion in 'Security' started by M001, Jun 13, 2014.

  1. M001

    M001 Member

    Joined:
    Aug 30, 2011
    Messages:
    14
    Likes Received:
    0
    Trophy Points:
    1
    cPanel Access Level:
    Root Administrator
    Hi all,

    Lately I've been having some security issues with a software I am using, I believe the software might have some type of exploit that allows files to be uploaded to it's root directory. I don't want to say the name of the software at this point until that vendor has fully checked into it, but as a temporary solution I thought it might be possible to restrict file names of PHP files that are allowed to run under my cpanel account. Is this possible?

    i.e. if the attacker does upload a file called "shell.php", they won't be able to run it if it doesn't match a file name in the list of allows PHP files
     
  2. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    30,724
    Likes Received:
    660
    Trophy Points:
    113
    cPanel Access Level:
    Root Administrator
    Hello :)

    It might be possible, but I don't really think it would be an effective way of mitigating an attack. Instead, you should ensure Mod_Security is installed with a robust ruleset, and ensure overall security is increased by reviewing any warnings in the "Security Advisor" option within WHM. If it's an exploit within a script, check with the developer to see if a patch is available until a new release is pushed out.

    Thank you.
     
  3. quizknows

    quizknows Well-Known Member

    Joined:
    Oct 20, 2009
    Messages:
    940
    Likes Received:
    55
    Trophy Points:
    28
    cPanel Access Level:
    DataCenter Provider
    A good modsecurity rule set will help.

    You can deny a specific file name with a very basic modsecurity rule:

    SecRule REQUEST_URI "shell\.php" "id:2923545,deny"

    You could make additional rules; each needs a unique number after id:
     
  4. M001

    M001 Member

    Joined:
    Aug 30, 2011
    Messages:
    14
    Likes Received:
    0
    Trophy Points:
    1
    cPanel Access Level:
    Root Administrator
    I am having the developer/vendor check into it, but I want to continue using the software so I don't have any downtime. I thought about making rules that would block certain file names, but all they would have to do is rename the file, which is why I wanted to block all except the permitted file names. Is there any other ideas for this temporary fix? I currently do have mod_security installed for other things, but I don't know how to write many rules.
     
  5. quizknows

    quizknows Well-Known Member

    Joined:
    Oct 20, 2009
    Messages:
    940
    Likes Received:
    55
    Trophy Points:
    28
    cPanel Access Level:
    DataCenter Provider
    You could do it but it would be a pretty ugly rule. Better to properly investigate the point of entry at this point.
     
Loading...

Share This Page