Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Site editor allows unauthorised edits #37126

Open
carlomanf opened this issue Dec 4, 2021 · 6 comments
Open

Site editor allows unauthorised edits #37126

carlomanf opened this issue Dec 4, 2021 · 6 comments
Labels
[Feature] Site Editor Related to the overarching Site Editor (formerly "full site editing") [Type] Bug An existing feature does not function as intended [Type] WP Core Ticket Requires an upstream change from WordPress. Core Trac ticket should be linked.

Comments

@carlomanf
Copy link

Description

The site editor appears to ignore meta capabilities that may be applied to template and template parts.

Step-by-step reproduction instructions

  1. Add a plugin with code similar to the below (where 338 is the ID of a template)
  2. Attempt to edit the template in the site editor
  3. Observe that the template was successfully edited

Screenshots, screen recording, code snippet

add_filter( 'map_meta_cap', 'test_function', 10, 4);
function test_function( $caps, $cap, $user_id, $args )
{
	if ( $cap === 'edit_post' && get_post( $args[0] )->ID === 338 ) return array( 'do_not_allow' );
	return $caps;
}

Environment info

core version 5.9-beta1-52318, plugin deactivated

Please confirm that you have searched existing issues in the repo.

Yes

Please confirm that you have tested with all plugins deactivated except Gutenberg.

No

@annezazu annezazu added [Feature] Full Site Editing [Feature] Site Editor Related to the overarching Site Editor (formerly "full site editing") [Type] Bug An existing feature does not function as intended labels Dec 15, 2021
@annezazu
Copy link
Contributor

Adding to the 5.9 project to be triaged further :)

@Mamaduka
Copy link
Member

Hi, @carlomanf

The templates REST API endpoint uses edit_theme_options for permission checks, and if I remember correctly, this is why we don't check meta caps.

Pinging @spacedmonkey in case my knowledge isn't up to date.

@spacedmonkey
Copy link
Member

There is already a core ticket for this [https://core.trac.wordpress.org/ticket/54516 #54516].

I have work in progress fix for this here - WordPress/wordpress-develop#2026

@annezazu annezazu added the [Type] WP Core Ticket Requires an upstream change from WordPress. Core Trac ticket should be linked. label Dec 15, 2021
@annezazu
Copy link
Contributor

Thank you both for chiming in and connecting dots. I'm going to close this out and defer to the core ticket to reduce confusion.

@carlomanf
Copy link
Author

carlomanf commented Oct 1, 2022

@annezazu I think this ticket should be re-opened. Although there is work being done on the core ticket, it will still be necessary to update the NPM packages here to work with the new API. This ticket can be used to track the client-side updates. What do you think?

@annezazu
Copy link
Contributor

annezazu commented Oct 3, 2022

I trust your read and will reopen now :). I'd always rather have more places something is reported for consistency than less. Thanks for following back up.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Site Editor Related to the overarching Site Editor (formerly "full site editing") [Type] Bug An existing feature does not function as intended [Type] WP Core Ticket Requires an upstream change from WordPress. Core Trac ticket should be linked.
Projects
None yet
Development

No branches or pull requests

4 participants