We need to implement access() methods for all fields on all entities so that we have a consistent access API and in order to not expose sensitive data to unprivileged users. Use case example: REST module needs to determine whether to show or hide a particular field when a consumer requests an entity. Who should be able to see the node status flag (published/unpublished), who should be able to retrieve user email addresses from the user entity? Who is allowed to change the node author?
This issue is major since a missing access implementation can have security implications. Individual issues fixing access() might even be critical because of access bypass vulnerabilities.
Also, entity forms that include custom $elements for some fields instead of using widgets should set #access according to "field access rules", instead of hardcoding it as NodeFormController does currently.
Remaining tasks
- Collect a list of fields of all core entities.
- Create issues (one per entity) to implement the access checks for the fields on the entity.
- Track the issues here.
Related Issues
- #2029855: Missing access control for user base fields
- #2098355: Missing default access for all node fields
- #2064181: Filter format access bypass on POST/PATCH
- #2098419: Missing default access for all comment fields
- #2099259: Missing default access for all taxonomy term fields
- #2381835: Missing access control for base fields of block content entity
Comments
Comment #1
moshe weitzman commentedAdded #2028027: [META] Missing access control for base fields to issue summary. We need to create similar issues for other entities/fields.
Comment #2
fagotagging
Comment #2.0
fagoUpdated issue summary.
Comment #3
fagoSo what would be the best way to handle that, do it per field, per entity-type?
Imo per entity-type might be a good granularity.
Comment #3.0
fagoUpdated issue summary.
Comment #3.1
fagoUpdated issue summary.
Comment #4
smiletrl commentedHere's an alternative idea of tackling this issue. This idea depends upon #1994140: Unify entity field access and Field API access.
With that issue in, we may do this:
Thus, we don't have to create new fieldItemList classes for base fields. Also, it provides a central place to handle all operations access for base fields attached to a spcific Entity, e.g, user.
For a particular base field, e.g., user_name:Name, we can still use
$items::access()to check the access.Comment #4.0
smiletrl commentedUpdated issue summary.
Comment #5
fagoDiscussed how we approach that best with yched - it's a general question on how to best provide custom logic per field instance.
We've not been able to identify what's the best approach right now, but agreed that it would make most sense to move with create per field instance field item list classes for now.
We kind of dislike having the entity type module implementing a hook and obfuscating the default-access logic from the field / field definition as a whole.
Other options discussed have been
- add some method on the entity class that's called by default, but this will lead to ugly switch logic there as well
- provide a way to specify custom access callbacks on the field definition, which then could sit on the entity class but be organized more neatly, i.e. group fields with common access logic to use the same callback
-provide a mechanism to provide separate access logic class and define them on the field definition, analogously to validation constraints.
Comment #6
mustanggb commentedComment #7
yched commentedComment #8
catchComment #9
fagoComment #10
xjmComment #11
xjmComment #12
berdirSee comment in #2029855: Missing access control for user base fields
Comment #13
berdirFixing yoda speak
Comment #14
berdirThe API addition that we need from this is in. While this is still a critical bug that we have to sort out, I believe this and the sub issues are now longer beta targets, it doesn't matter when we fix this as long as we do it before 8.0.0.
Comment #15
larowlanCan't see reference to 'Block Content' entity in OP - should we have an issue for that too?
Comment #16
star-szrComment #17
catch@larowlan opened that issue, well spotted that it was missing.
Comment #18
catchAnd that issue is apparently not necessary.
Comment #19
xjmComment #20
berdirAll child issues were fixed.