Restrict file access to authorized php users

前端 未结 3 1172
旧时难觅i
旧时难觅i 2020-12-09 06:49

I\'ve inherited an application with a glaring security hole.

It has session-based security, but file uploads (which are user specific) are not secured in any way an

3条回答
  •  情书的邮戳
    2020-12-09 07:11

    I think you may need to write a script that will serve the images, then use htaccess to completely restrict access to the actual images from a browser.

    The script can take in the web path to the image, decide if the user has access, then use something like fpassthru to feed an actual image to the browser.

    All references to the images would need to be modified, however, to reference the serving script.

    So instead of accessing the images with /images/123/5423453245.jpg, it would be /image.php?images/123/5423453245.jpg

    Or something similar to that.

提交回复
热议问题