Fix unauthenticated access to REST API endpoints#1315
Open
jbrejcha wants to merge 1 commit intohtmlburger:developmentfrom
Open
Fix unauthenticated access to REST API endpoints#1315jbrejcha wants to merge 1 commit intohtmlburger:developmentfrom
jbrejcha wants to merge 1 commit intohtmlburger:developmentfrom
Conversation
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' );
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
allow_access()returnedtrueunconditionally, 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/1without 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:This keeps the fix non-breaking for anyone who relies on the current open-access behaviour while making the secure default opt-in.