Skip to content

Check: Allowing Direct File Access to plugin files #603

@davidperezgar

Description

@davidperezgar

This check consists to avoid direct file access if someone directly queries a file.

For files that only contain a PHP class the risk of something funky happening when directly accessed is pretty small. For files that contain procedural code, functions and function calls, the chance of security risks is a lot bigger.

We can avoid this by putting this code at the top of all PHP files that could potentially execute code if accessed directly :
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly

What we do actually in the internal scanner:

  1. Check that is not an uninstall file.
  2. Check that is valid for direct access.
  3. Look for ABPATH or WPINC, otherwise it's wrong.

Finally in results we say all files that does not contain this header.

Metadata

Metadata

Assignees

Labels

ChecksAudit/test of the particular part of the plugin[Team] PluginsIssues owned by Plugins Team

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions