I was always sure that the PHP functions file_get_contents and readfile execute any PHP code in any files - regardless of the type of file - that are issued to it. I tried this on several settings and it always worked.
I got a question about this here , and the user seems to think that this is not the case.
I looked at the PHP documentation for functions and they don't mention code execution (what would I expect if this usually happens, as it has serious security implications).
I also searched for it and found many statements that functions do not execute PHP code. For instance:
readfile does not execute code on your server, so there is no problem. a source
The search for "php file_get_contents code execution" also returns various questions trying to execute the extracted PHP code, which seems strange if it really did execute any given PHP code.
I also found one question that asks about not executing PHP code, so the execution seems to be happening with others.
So my questions are:
- execute
file_get_contents and readfile execute php code in extracted files? - Does it depend on some php.ini settings? If so, what settings (s)?
- Does it depend on the version of PHP, and if so, which versions are affected?
- If this is not the case, what could be the reason that they are executing PHP code in my settings?
source share