-1

I wonder how to patch the LFI problem in this code? Please suggest a good way to patch this vulnerability.

enter image description here

schroeder
  • 123,438
  • 55
  • 284
  • 319

1 Answers1

2

Directory traversal/local file inclusion attacks are just a symptom of the problem of failing to validate user input. Consider what you're doing: You're taking input from the Internet and blinding passing it to a function that expects a very particular type of input.

The short answer is: VALIDATE ALL USER INPUT.

The longer answer is, and in this case, verify that what is being POSTed in the Product variable is a legitimate file name in the appropriate directory.

This same premise is how SQL Injection works.

thepip3r
  • 633
  • 3
  • 8