Skip to content

Fix unauthenticated access to REST API endpoints#1315

Open
jbrejcha wants to merge 1 commit intohtmlburger:developmentfrom
jbrejcha:fix/rest-api-unauthenticated-access
Open

Fix unauthenticated access to REST API endpoints#1315
jbrejcha wants to merge 1 commit intohtmlburger:developmentfrom
jbrejcha:fix/rest-api-unauthenticated-access

Conversation

@jbrejcha
Copy link
Copy Markdown

Problem

allow_access() returned true unconditionally, meaning any unauthenticated visitor could read Carbon Fields data (post meta, user meta, term meta, comment meta) for any object ID — including admin user meta — whenever the developer marked a field with ->set_visible_in_rest_api(true).

Example: GET /wp-json/carbon-fields/v1/users/1 without any authentication returns all exposed CF fields for the admin account.

Fix

Require is_user_logged_in() by default. Sites that intentionally expose fields on public (unauthenticated) endpoints can opt out via a new filter:

add_filter( 'carbon_fields_rest_api_allow_public_access', '__return_true' );

This keeps the fix non-breaking for anyone who relies on the current open-access behaviour while making the secure default opt-in.

allow_access() returned true unconditionally, allowing any unauthenticated
request to read Carbon Fields data (post meta, user meta, term meta, comment
meta) for any object ID — including admin user meta — as long as the field
had set_visible_in_rest_api(true) set by the developer.

Require is_user_logged_in() by default. Sites that intentionally expose
fields on public endpoints can opt out via the new filter:

  add_filter( 'carbon_fields_rest_api_allow_public_access', '__return_true' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant