Skip to content
This repository was archived by the owner on Jan 22, 2018. It is now read-only.

Commit 7f389bf

Browse files
committed
SA-CORE-2017-002 by alexpott, xjm, larowlan, Wim Leers, samuel.mortenson, Berdir, dawehner, tstoeckler, catch
1 parent 5d3fb8a commit 7f389bf

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

lib/Drupal/Core/Entity/EntityAccessControlHandler.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,19 @@ public function fieldAccess($operation, FieldDefinitionInterface $field_definiti
303303
// Get the default access restriction that lives within this field.
304304
$default = $items ? $items->defaultAccess($operation, $account) : AccessResult::allowed();
305305

306+
// Explicitly disallow changing the entity ID and entity UUID.
307+
if ($operation === 'edit') {
308+
if ($field_definition->getName() === $this->entityType->getKey('id')) {
309+
return $return_as_object ? AccessResult::forbidden('The entity ID cannot be changed') : FALSE;
310+
}
311+
elseif ($field_definition->getName() === $this->entityType->getKey('uuid')) {
312+
// UUIDs can be set when creating an entity.
313+
if ($items && ($entity = $items->getEntity()) && !$entity->isNew()) {
314+
return $return_as_object ? AccessResult::forbidden('The entity UUID cannot be changed')->addCacheableDependency($entity) : FALSE;
315+
}
316+
}
317+
}
318+
306319
// Get the default access restriction as specified by the access control
307320
// handler.
308321
$entity_default = $this->checkFieldAccess($operation, $field_definition, $account, $items);

0 commit comments

Comments
 (0)