WordPress / WordPress/WordPress-Coding-Standards

Ensure capabilities are checked in metabox saves

Open
#74 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Focus: Security Status: Needs investigation Type: Enhancement
Dominant language
PHP
Stars
2.8k
Forks
521
Avg merge
5d 20h
Merged PRs (30d)
1

Description

  • For each metabox registered with add_meta_box, flag if the save callback does not contain a cap check.

If the callback is a method like array( $obj, 'method' ), it will be to difficult to check programatically. However, if the method is for $this or if a bare global function name or closure is used, then it should be straightforward to locate the function in the same file.

PHPUnit would be a better way to check if a function calls current_user_can, as a test could run and then check to see if the map_meta_cap hook ran during the function's execution.

Per the VIP code review guidelines:

Capability checks need to validate that users can take the requested actions.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by locating the rule that inspects registrations made with add_meta_box and review how callback forms are represented. Use the listed cases—$this methods, bare global functions, and closures—as the initial scope, and investigate PHPUnit coverage using current_user_can and the map_meta_cap hook. Done means callbacks that can be inspected are flagged when they lack a capability check.

Written by the indexing model from the issue text.

Assessment

Tech stack
php
Domain
security, tooling
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.