Security risks of having public phpinfo() page?

5,635

It would entirely depend on how confident you are about your PHP install. If you think it is rock solid, even if an attacker knows everything about your PHP install, then you could leave it in place.

But really, why would you leave this in place on a production system anyway? There may be exploits you are not aware of in your version of PHP - people may now or in future scan for your version of PHP, or particular options you have enabled, because they know how to carry out these exploits. So by keeping this up publically, you added yourself to their hitlist.

If you want to keep it up, you can put it in a password protected directory, or just switch it on when you need it. Given the small cost of these options, I wouldn't take the risk of keeping it public.

Share:
5,635
Nick Peranzi
Author by

Nick Peranzi

Updated on September 17, 2022

Comments

  • Nick Peranzi
    Nick Peranzi almost 2 years

    I have a publicly accessible page which just has

    <?php phpinfo(); >
    

    I use it for debugging purposes while we're in beta, but is there any harm in leaving it accessible when its a live site?

  • danlefree
    danlefree over 13 years
    Wrapping the function call in a conditional usually does the trick - i.e. <?php if ( $_SERVER['REMOTE_ADDR'] == '1.2.3.4' ) phpinfo(); ?> (where 1.2.3.4 is your IP address)
  • Nick Peranzi
    Nick Peranzi over 13 years
    Thanks @dunxd - and thanks @danlefree for the tip... there are so many sites that still expose their phpinfos!
  • dunxd
    dunxd over 13 years
    There are a lot of sites that expose phpmyadmin too - don't follow the examples of low security of other people. They may not value their data or integrity of their server as much as you value yours.
  • justinhartman
    justinhartman over 6 years
    While @dunxd's solution is thorough and perfect I really like @danlefree's solution to the problem. I'm not sure why I never thought of this before and I will be using this model going forward. To remain on topic, I also wanted to add I too am of the opinion that exposing PHP publically in a phpinfo() function is not a wise idea.