E
E
ex3xeng2015-11-25 10:33:32
PHP
ex3xeng, 2015-11-25 10:33:32

Do I need to filter data file_exists(), file_get_contents()?

there is a diagram like this:

$file = (isset($_GET['file']) && !empty($_GET['file']) ? $_GET['file'] : false);
if ($file) {
   if (file_exists($file)) $file = file_get_contents($file);
}

while the get parameter is sent by the client, is it necessary to somehow filter the incoming data in this case? are errors possible?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alexey Ukolov, 2015-11-25
@alexey-m-ukolov

Of course, this is a classic mistake - you are actually letting the user read an arbitrary file on your server. This is a huge security hole.
Stepic.org has a course on web project security and it has a chapter on exactly this issue.

A
Alexey Hog, 2015-11-25
@Skiphog

Some information can be found here

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question