-
Notifications
You must be signed in to change notification settings - Fork 26
Open
Labels
Description
The example code given for the PHP documentation has a massive security hole.
$response = FroalaEditor_File::delete($_POST['src']);
public static function delete($src) {
$filePath = $_SERVER['DOCUMENT_ROOT'] . $src;
// Check if file exists.
if (file_exists($filePath)) {
// Delete file.
return unlink($filePath);
}
return true;
}
That code allows anyone who knows what the delete URL is, to delete any file off the server, that PHP has permissions to delete.
This is sub-optimal.
Even though it is just example code, there should be some example lines that check that the file being deleted is under the appropriate directory, and probably also a note that there should be a permissions check to ensure the user is allowed to delete images.