Skip to content

RestStrategy registers all routes with permission_callback => __return_true #31

Description

@alexstandiford

Problem

RestStrategy registers every route with 'permission_callback' => '__return_true' and performs the real authorization inside the route callback via each controller's getMiddleware() (e.g. createAuthMiddlewareFromCurrentContext(...), which throws on an unauthorized request).

Functionally the data is protected — the middleware runs before the handler body and rejects unauthorized requests. But because permission_callback always returns true:

  • WordPress advertises every endpoint (including destructive DELETE/bulk routes) as publicly accessible in the REST API index/discovery.
  • Static analysis and the WordPress.org plugin-review scanners cannot see that authorization exists — __return_true on a mutating route is the single most-flagged REST pattern in review.
  • There is no WP-level backstop: if a controller ever fails to register its auth middleware, the route is wide open with no declarative permission check.

Desired outcome

WordPress's own permission gate should reflect the real authorization. The permission_callback should run the same auth resolution the in-callback middleware uses, so an unauthorized request is rejected at the permission stage and the endpoint is not advertised as public. This is also a defense-in-depth improvement over running auth only inside the callback body.

Notes

Surfaced by the Siren WordPress plugin (consumer of this package) during WordPress.org review-simulation. Not blocking Siren's submission (auth is enforced), but it generates a guaranteed reviewer flag and is a genuine layering issue.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions