Local File Inclusion (LFI)
Introduction
This article covers ways to secure the code from Local File Inclusion vulnerability on WordPress. This includes applying a proper function to check for the userβs input.
How to secure
In general, do not allow users to fully control string passed to these functions:
In some cases, where users can supply part of the string passed to the above functions, apply a proper limitation. The most ideal way to secure the code is a whitelist check on what .php
files can be included by the users. Make sure to also directly put a .php
string at the end of the formatted string, so users are only able to include a .php
file and not other files:
In some cases where users are allowed to include all of the .php
files inside a directory, applying a standard sanitization using the sanitize_file_name
function could also work: