4

I've got the following piece of code in my web application:

$data = "dir/files/".$_GET['f'].".pdf";    

Couple of lines down I got:

if(file_exists($data)){    
include($data);

Could an attacker bypass that to exploit an RFI on my system? Or is it LFI only?

1

Best to whitelist (not blacklist) characters allowed in $_GET['f'].

if (preg_match("[^A-Za-z0-9_-]", $_GET['f'])) {
  fail();
} else {
  // your logic here
}

Notice that I didn't put "." or "/" in the whitelist. That was intentional.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.