Sanitize file path in PHP

后端 未结 7 993
夕颜
夕颜 2020-12-01 11:00

Greetings, I\'m hoping to make my tiny program secure so that potential malicious users cannot view sensitive files on the server.

    $path = \"/home/gsmcm         


        
相关标签:
7条回答
  • 2020-12-01 11:25

    Even if you are using realpath, you should still strip all ".." before using it. Otherwise an attacker can read your servers entire directory structure with brute force, e.g. "valid_folder/../../test_if_this_folder_name_exists/valid_folder" - if the application accepts this path, the attacker knows that the folder exists.

    0 讨论(0)
提交回复
热议问题