Local File Inclusion

Local File Inclusion (LFI) allows a hacker to execute a file from another part of the site. A hacker may be able to upload a file to your site that includes some PHP code, and then use local file inclusion to trick your site into executing that code.

To simulate this type of attack, create a file in the /tmp folder of your Joomla! site called demo.php, and add the following code:

<?php
echo phpinfo();
die;

Now we are going to add some code to our folio.php file under /components/com_folio which will make it vulnerable to local file inclusion. Obviously this code isn't required for our component and is only to demonstrate the vulnerability. You can add this code near the top of the file.

if($controller = JRequest::getVar('controller')) ...

Get Learning Joomla! 3 Extension Development - Third Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.