Securing a web server for Joomla 4 of 4 PHP

Posted by: Ovidiu

Tagged in: Site administration , security , joomla , jentla

This is 4of 4 in our series of posts about securing a webserver for Joomla. Here are the four posts:

  1. Securing Linux
  2. Securing Apache
  3. Securing MySQL
  4. Securing PHP

 

PHP

We can increase the security of our PHP environment just by adding some settings in /etc/php.ini . This are a couple of the settings you can add to improve the security of your environment.

Hide PHP version information
It is better to hide the php version information because of scans that are done on systems to detect software versions that have some known bugs and use that info to compromise the system. To do this edit the following option:
expose_php = Off


Error logging

PHP can handle error reporting several ways: logging to a server log or log errors to the browser of the client. The second method can affect the security of your system because with some errors paths to files are revealed, so it's better to log the errors to a file on the server, to do this use these settings:
display_errors = Off
log_errors     = On

 

Disable dangerous functions
There are functions that you do not need for your application to run and that are a big security risk for the system. We can disable all uwanted functions from php by using this setting:
disable_functions = phpinfo, mail, dl ...

 

This is a list of functions you should consider removing if you are not using them:

  • curl_exec - perform a cURL session

  • curl_multi_exec - run the sub-connections of the current cURL handle

  • disk_free_space - returns available space on filesystem or disk partition

  • dl - loads a PHP extension at runtime

  • exec - execute an external command

  • fsockopen - open internet or unix domain socket connection

  • getmypid - gets PHP's process ID

  • getmyuid - gets PHP script owner's UID

  • highlight_file - syntax highlighting of a file

  • ignore_user_abort — Set whether a client disconnect should abort script execution

  • mail - send mail

  • parse_ini_file - parse a configuration file

  • passthru - execute an external program and display raw output

  • phpinfo - outputs a large amount of information about the current state of PHP

  • php_uname - returns information about the operating system PHP is running on

  • popen - opens process file point

  • posix_ctermid - get path name of controlling terminal

  • posix_getcwd - pathname of current directory

  • posix_getegid - return the effective group ID of the current process

  • posix_geteuid - return the effective user ID of the current process

  • Other posix functions: posix_getgrgid, posix_getgid, posix_getgrnam, posix_getgroups, posix_getlogin, posix_getpgid, posix_getppid, posix_getpwnam, posix_getpwuid, posix_getrlimit, posix_getsid, posix_getuid, posix_isatty, posix_kill, posix_mkfifo, posix_setegid, posix_seteuid, posix_setgid, posix

  • proc_open - execute a command and open file pointers for Input/Output

  • proc_close - close a process opened by proc_open and return the exit code of that process

  • Other functions involving processes: proc_close, proc_get_status, proc_nice, proc_terminate

  • shell_exec - execute command via shell and return the complete output as a string

  • show_source - show the source of a file

  • symlink - creates a symbolic link

  • system - execute an external program and display the output

  • virtual - perform an Apache sub-request

     

Register globals

This is what php.ini recommends:

 You should do your best to write your scripts so that they do not require
 register_globals to be on;  Using form variables as globals can easily lead
 to possible security problems, if the code is not very well thought of.

and I strongly aggree with that, so with that in mind we should set, if is not already set:

register_globals = Off

 

Limit resources

If you don't intend to upload files on the server through php you should disable file uploads.

file_uploads = Off

If you are going to do file uploads from php, then you should limit the file upload size to what value you think it will be good for you and also restrict the directory where this uploads are made, if possible

upload_tmp_dir = /var/php_tmp
upload_max_filezize = 2M

Remember that the upload temporary directory should be owned by apache user:

#chown apache: /var/php_tmp

You should also consider limiting the  resources your php scripts use:

; Maximum execution time of each script, in seconds
max_execution_time = 30

; Maximum amount of time each script may spend parsing request data
max_input_time = 60

; Maximum amount of memory a script may consume (8MB)
memory_limit = 8M

; Maximum size of POST data that PHP will accept.
post_max_size = 8M

 

Disable remote files includes
Top prevent remote scripts from being included and executed on your server you should disable remote files access from your php environment.
allow_url_fopen = Off
allow_url_include = Off

 

Restrict file access on server from php
Allow access for php only to specific portions of your file system, like you web directory or other shared libraries.
open_basedir = "/var/www/html/:/usr/local/php/"


Conclusion

This was the last of our 4 blogs regarding the security of a LAMP server, in this one we used the php settings to improve the security of any php environment, thus avoiding our php application from getting compromised and therefore the risk of the system to get breached. This setting depend much on what application you are running and what php functions it needs, so you would have to adapt this to your needs.

The articles shown just a few of the steps you could walk through in securing your LAMP sever, of course there are many security issues that are not covered by this posts, much of them depend on what you are running and there are a lot of variables that need to be taken in consideration. By making periodical security checks of your system you can set up a security implementation that works with your environment. This involves monitoring the system, creating alerts in case of any unusual behavior of your services, keeping an eye out for any new vulnerabilities that could affect your system/application and so on. This is an exhausting job, especially keeping up with every new vulnerability that appears, that's why there are tools which can help us in doing this.

One of this tools is "McAfee® SECURE™ for Websites Services" , this tool provides us the capability to check for any security vulnerabilities that our system could have and provides us documentation about the vulnerability and help in  solving it. This will be our next subject, why and how to use the McAfee tool to increase the security of our system and of course to increase the confidence in the services provided to our clients.

 

Comments (35)Add Comment
0
...
written by winter hats, February 22, 2012 at 6:07 PM
I am afraid to lose, I fear this time, http://www.amandahats.com/buy/winter-hats/ and I love it but memories. I could not forget the sweat on the pitch with the sway of the brothers, http://www.amandahats.com/buy/warm-winter-hats/ forget accompany me cry close friend,
0
...
written by Retro Air Jordans, February 22, 2012 at 5:33 PM
Yearning cheap air jordans for the talented poet fingertip touch air jordan shoes and take time; yearning for the birds retro jordans shoes fly eyes of thousands of miles; yearning Air Jordan 2011 for the sweet happiness of the retro air jordans lover of the beautiful night market in hand.
Can aspire to but that Air Jordan 1 is only aspire to, no real base pad, never pick the stars of the heart.
Life is so full of Air Jordan 3 regret, in the hustle and bustle of the end of the busy stumble Air Jordan 5 ups and downs, full of the unknown is gradually lost in the fantasy world and become a slave to womens air jordan shoes money.
People always like the pursuit does not ignore the existing light ink rendering life is like a landscape Retro Jordans 6 painting, everywhere poetic, but everywhere frustrated. Linger in the Red nike jordan shoes earthly humor stranded happiness.
Tears quiet, perhaps, Air Jordan 11 in the eyes waiting for the fall season; perhaps, the dream is to stay on the other Air Jordan 13 Retro side Looking forward to a sober moment; perhaps, the heart is excited about upcoming achievements glorious fleeting.
Life how much sadness implied which? And how much laughter air jordan 11 retro concords wandering mind?
Write endless worry, the comb unclear worry, Air Jordan 11 Cool Grey be filled love to listen to endless laughter together constitute the life colorful.
Shallow drop of ink to stay in the tip, waiting for the moment sway the brilliant achievements of the Air Jordan 21 picture. http://www.retrojordans6.org/
bertha
...
written by discount oakley sunglasses, February 22, 2012 at 11:03 AM
thank you for your share i think it's useful to the need one i like it
0
...
written by New Era Hats, February 21, 2012 at 7:34 PM
Two years ago, a certain day, I filled with the ruins of a sense. At that time, the uncle told me the story of a New Era Hats. It is said that a cold winter, a wall standing in front of Walker, blocking his way. Climb walls or without success, he chose the former, but has been climbing unsuccessful. Lost in the cold weather keeping warm Snapback Caps, the human ear is very easy to frostbite, and even life-threatening. The last monk decisively NFL Hats thrown on the other side of the wall, and then exhausted body strength jumped over not MLB Hats to retrieve the NHL Hats move. So far I still clearly remember the NBA Hats story. A lot of time is a drastic lack of courage!
0
...
written by saint jerseys, February 21, 2012 at 10:37 AM
Morten Andersen Jersey Patrick Robinson Jersey Pierre Thomas Jersey Reggie Bush Jersey Rickey Jackson Jersey Robert Meachem Jersey Roman Harper Jersey Saints Customized Jersey Scott Fujita Jersey Sedrick Ellis Jersey Tracy Porter Jersey
0
...
written by hermes victoria bag, February 20, 2012 at 4:53 PM
It really is easy to spot an real handbag while there are various "knockoffs". Hunt for quality connected with materials where designer handbags are designed. Then, check the structure itself. Designer affordable handbags carry this designer's trademark style in addition to their name in each and every stitch in addition to handbag framework. This is the obvious way to spot true designer affordable handbags from reports. Manufacturers aim their affordable handbags to past. They opt for materials connected with construction using a custom excellent basis of which can't simply be cloned. Poor excellent copies usually are rarely seeing that durable in addition to wear swifter. That's the important difference concerning quality intended handbags in addition to copies. A bag wardrobe can be as important seeing that other gadgets. It ought to include a range of styles by means of top designers as well as a complimentary choice of colors in addition to textures. A handbag is usually a necessity many women can't dwell without. Whether some sort of designer handbag is usually a clutch, carry-all or maybe tote, it articulates volumes of any woman's vogue and excellent sense.
0
...
written by breitling replica watches, February 14, 2012 at 4:52 PM
I like this article http://www.hellobreitling.com
0
...
written by renault can clip, February 13, 2012 at 3:19 PM
I should accustom you’ve advancing me by this article. I’m actually captivated by about one added superb article. I adore your internet armpit actually appreciably and accede you for animate males and girls up with every one of the casting beginning attack you are inventing.
0
...
written by nono, February 11, 2012 at 6:18 PM
I like your article, welcome to the cheap clothing:http://www.55ya.com/cheap_Jewelry_wholesale_online_websites.html

0
...
written by best replica burberry, February 09, 2012 at 1:17 AM
http://www.womenhandbags2u.com...-c-20.html state that point is really a most significant part of the existence, as well as we must be mindful about this nicely. If you do not contemplate it you are able to in no way obtain achievement that you experienced. All of us can't handle the existence without having these types of useful http://www.womenhandbags2u.com...c-81.html.
0
...
written by Panerai Radiomir replica , February 09, 2012 at 12:39 AM
http://www.imitation-watches4u...-c-58.html state that point is really a most significant part of the existence, as well as we must be mindful about this nicely. If you do not contemplate it you are able to in no way obtain achievement that you experienced. All of us can't handle the existence without having these types of useful http://www.imitation-watches4u...c-57.html.
0
...
written by north face clearance, January 31, 2012 at 11:40 AM
Excited to be successful, small jiujiancilang once again resorted to the locations of all skills through the knife speed fast Battōjutsu. closely followed by see locations of the knife cut in the north face of the neck, and then made the sound bite of a rattle, waved briefly followed by small jiujiancilang knife, silver flashed and then you see a section of things flying out.The north face's head, of course, impossible silver light shining, in fact out is not really the head of the north face, but a little jiujiancilang knife. don't get me wrong,
0
...
written by czxczx, January 14, 2012 at 1:55 PM
I always thought one of the main things to count when you write a blog is learning how to complement the ideas with imageshttp://www.cwatchc.com
0
...
written by louis vuitton monogram mini lin diaper bag, January 11, 2012 at 7:02 PM
Thank you for your article, I hope to see you again to share.Do not forget that it isn't just very strong handbag but will also very lustrous sorts of bag in anyway. Recommend a Beautiful website, click here, you can find the http://www.love-replicas.com/l...3_121.html and http://www.love-replicas.com/l...3_25.html.
0
...
written by Belstaff Outlet, January 10, 2012 at 6:15 PM
So nice article!
0
...
written by china wholesale, January 10, 2012 at 6:15 PM
Hi, the article is so wonderful, I am interested in it. I will pay attention to your articles.
0
...
written by nba snapback hats, January 07, 2012 at 12:46 PM
Don’t neglect the factors you as quickly when you owned. Treasure the factors you cannot get. Don't quit the factors that belong for you and retain people lost factors in memory. gss3w43s%6
0
...
written by Snapbacks Hats, January 06, 2012 at 12:35 PM
This is really interesting, You are a very skilled blogger.i like to read http://www.nflsnapbacksale.org/ informative blogs and this blog is also so good and helpful.thanks for taking time to http://www.nflsnapbacksale.org/ discus this topic
0
...
written by mori lee, January 04, 2012 at 4:52 PM
Especially designer's http://www.bestbridalprice.co....-8195.html wedding dress, will most likely be a large shock for you, isn't it? select the http://www.bestbridalprice.co....-7946.html of designer.
0
...
written by mori lee, January 04, 2012 at 4:50 PM
Very good website. I lately engineered mine and i experienced been looking for some principles and you also gave me a few of. brief http://www.bestbridalprice.co.uk/ bridal gown , typically make you grow to be a whole lot more nifty and young,isn'it?If you don't possess a far better choice,you can attempt for the brief http://www.bestbridalprice.co.uk/.
0
...
written by Maggie Sottero gown, January 04, 2012 at 4:48 PM
Thank you so a lot!! It’s very useful ~ Today, strapless neckline http://www.manndybridal.com/ bridal gownes are obtainable in princess reduce http://www.manndybridal.com/ wedding dresses
0
...
written by Maggie Sottero gown, January 04, 2012 at 4:46 PM

I will visit your blog regularly for some latest post.If you have made the choice to splurge on the $5000 http://www.manndybridal.com/pr...1502.html, be good to choose add-ons that do it justice. just one superb notion will be to purchase custom girl diamond jewelry that will highlight just one of the most perfect attributes of your http://www.manndybridal.com/al...p-429.html wedding dress .Perfect collocation can let you become more beautiful.
0
...
written by jewelry, December 27, 2011 at 5:26 PM
The decision of one's http://www.jewelora.com/wholes...c-2_5.html is considered as necessary as the choice of the http://www.jewelora.com/wholes...5_49.html.
0
...
written by replica hysek watches, December 26, 2011 at 6:38 PM
I just could not leave your site before suggesting that I extremely enjoyed the standard info an individual provide for your guests? Is going to be back often in order to inspect new postshttp://www.store-replica.com/hysek.html
0
...
written by replica patek philippe watch, December 24, 2011 at 3:29 AM
Thank you for sharing contents of the article very well.They are loaded with the comparable fashion not to mention approximate quality being the original timepieces but cheaper prices. Click it to move your mouse, you will see http://www.ok-swisswatches.com...33_36.html and http://www.ok-swisswatches.com...3_35.html.
0
...
written by Best Replica Watches, December 21, 2011 at 4:23 PM
That is very valuable stuff. With thanks for all the determination to offer these types of helpful information here.http://www.store-replica.com
0
...
written by replica captive de cartier, December 20, 2011 at 5:27 PM
I like this website, and I can benefit a lot from it!
0
...
written by Home Security Houston, December 19, 2011 at 4:36 PM
I love your blog, you should add an RSS feed feature so I can get automatic notifications of new blogs. If you set one up please email me! i will bookmark you for now. Again Excellent Blog!Houston Home Security
0
...
written by wholesale jewelry, December 13, 2011 at 11:21 PM
When you wear incomparable http://www.jewelora.com/wholesale-ring-c-10.html you won't just standout between the audience, but you'll also look superb as well as http://www.jewelora.com/wholes...-c-32.html so.
0
...
written by replica cartier tank watches, December 09, 2011 at 6:51 PM
Given that every one of the intricate layout with the http://www.misswatches2u.com/corum-c-46.html, totally useful and also correct timekeeping, they may be sought after and extremely well-known. Sociable position of men and women consider they may be symbolic regarding style and also trend. They may be the actual counterfeit regarding traditional http://www.misswatches2u.com/, using a first-class engineering and also fantastic toughness.
0
...
written by cheap omega watches, December 02, 2011 at 7:00 PM
http://www.justcheapwatches.co...-Sale.html

I have been keeping track of your site for a long time I read these articles, this is an

interesting reading I will continue to pay attention to it more
0
...
written by cartier replica watches ch, November 28, 2011 at 3:47 PM
I appreciate for your post! I hope you will keep it on. I also want to make friends with you and share my favorite replica! http://www.hello-rolex.com/cartier-c-9.html
0
...
written by Replica Breitling Watches, November 18, 2011 at 11:57 AM
For those people who choose to own a watch, Swiss made ones are well-liked Of the several Swiss created watches, the most well-liked 1 is the trademark Breitling watches.
0
...
written by Online pharmacy reviews, November 17, 2011 at 6:14 AM
I enjoyed following the whole entry, I always thought one of the main things to count when you write a blog is learning how to complement the ideas with images, that's exploiting at the maximum the possibilities of a ciber-space! Good work on this entry!
0
...
written by cheap dvds online, October 13, 2011 at 8:56 PM
Thanks for the information you've shared. I believe that I’ve learned a lot from the points.

Write comment
smaller | bigger

security code
Write the displayed characters


busy