Forbid execution of PHP files in subfolders by default (except those needed by core)

Created on 17 May 2012, almost 13 years ago
Updated 26 January 2025, 3 months ago

Problem/Motivation

Drupal uses the front controller pattern, meaning that all requests are handled by one entry point. This is index.php and some others like update.php or install.php. For a standard Drupal installation it therefore makes no sense to allow the direct execution of PHP files in subfolders. Quite the opposite: it poses a security risk especially to files directories where uploaded files could get executed (although files with the PHP extension should never get there in the first place). It can also have strange effects if there are custom developed *.php files (in most cases the log will be cluttered with PHP fatal errors because they don't work without Drupal). In Drupal 8 we are introducing even more files with the *.php extension (mostly containing classes for the autoloader), and we surely don't want to execute them on their own.

Proposed resolution

Add a rule to .htaccess to forbid execution of PHP files in subfolders.

Remaining tasks

Discussion and Feedback.

User interface changes

None.

API changes

None.

πŸ“Œ Task
Status

Fixed

Version

8.0 ⚰️

Component

base system

Created by

πŸ‡¦πŸ‡ΉAustria klausi πŸ‡¦πŸ‡Ή Vienna

Live updates comments and jobs are added and updated live.
  • Security improvements

    It makes Drupal less vulnerable to abuse or misuse. Note, this is the preferred tag, though the Security tag has a large body of issues tagged to it. Do NOT publicly disclose security vulnerabilities; contact the security team instead. Anyone (whether security team or not) can apply this tag to security improvements that do not directly present a vulnerability e.g. hardening an API to add filtering to reduce a common mistake in contributed modules.

Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024