You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
bug #7556 Improve security of batchDelete() action (javiereguiluz)
This PR was squashed before being merged into the 4.x branch.
Discussion
----------
Improve security of batchDelete() action
Commits
-------
4cde4cd Improve security of batchDelete() action
// the instanceof guard must run even when $this->instance is null. Otherwise
310
+
// a caller can store an instance whose class does not match $this->fqcn, and
311
+
// downstream code (authorization, DB operations) that trusts either side of
312
+
// that pair may be redirected to the wrong entity (this is a CWE-441 (Confused Deputy) attack vector)
313
+
if (null !== $newEntityInstance && !$newEntityInstanceinstanceof$this->fqcn) {
310
314
thrownew \InvalidArgumentException(sprintf('The new entity instance must be of the same type as the previous instance (original instance: "%s", new instance: "%s").', $this->fqcn, $newEntityInstance::class));
311
315
}
312
316
@@ -331,7 +335,12 @@ public function newWithInstance(/* object */ $newEntityInstance): self
331
335
);
332
336
}
333
337
334
-
if (null !== $this->instance && !$newEntityInstanceinstanceof$this->fqcn) {
338
+
// the instanceof guard must run even when $this->instance is null. Otherwise
339
+
// a caller that wraps an entity into a DTO whose $fqcn was set from a different
340
+
// source (e.g. batch actions, where the FQCN comes from the admin context but
341
+
// the instance comes from a repository lookup) can silently produce a DTO
342
+
// whose $fqcn does not match its $instance (this is a CWE-441 (Confused Deputy) attack vector).
343
+
if (!$newEntityInstanceinstanceof$this->fqcn) {
335
344
thrownew \InvalidArgumentException(sprintf('The new entity instance must be of the same type as the previous instance (original instance: "%s", new instance: "%s").', $this->fqcn, $newEntityInstance::class));
0 commit comments