Jump to content

Denying direct access to PHP files

Recommended Posts

I'm always weary of third party software recommending or requiring setting directory permissions to 777. Is it possible to deny direct access to PHP files in these directories or will it break the software?


Specifically using an Apache configuration like this, which would be fine providing the PHP files are only included and not accessed directly:

<Directory ~ /(var|www/images|www/admin/plugins|plugins)/>
    php_admin_flag engine off
    <Files *.php>
        Order Deny,Allow
        Deny from all

We've been bitten a few times with leaky software that has enabled PHP files to be created in writeable directories and executed to install web shells. This attempts to reduce that risk by disabling PHP execution/denying PHP access directly in the browser.

Edited by jamieburchell
More info
Link to comment
Share on other sites

  • 2 weeks later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...