Skip to content

Commit 0e709bb

Browse files
committed
fix(symfony): security regression when ResourceAccessChecker is decorated (#7896)
Commit 359a128 introduced a regression when ResourceAccessChecker is decorated, and security/securityPostDenormalize are using object in is_granted expression. The issue arise since AccessCheckerProvider violates the Liskov substitution principle by assuming that if the (previously unknown) interface ObjectVariableCheckerInterface is not defined, then the pre_read optimization can be used without an object instance.
1 parent 7cc01a6 commit 0e709bb

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/Symfony/Security/State/AccessCheckerProvider.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,14 @@ public function provide(Operation $operation, array $uriVariables = [], array $c
8585
];
8686
}
8787

88-
if ('pre_read' === $this->event && $this->resourceAccessChecker instanceof ObjectVariableCheckerInterface && $this->resourceAccessChecker->usesObjectVariable($isGranted, $resourceAccessCheckerContext)) {
88+
// Skip pre_read optimization when object is used via granted (or usage is not predicatable)
89+
if (
90+
'pre_read' === $this->event
91+
&& (
92+
!$this->resourceAccessChecker instanceof ObjectVariableCheckerInterface
93+
|| $this->resourceAccessChecker->usesObjectVariable($isGranted, $resourceAccessCheckerContext)
94+
)
95+
) {
8996
return $this->decorated->provide($operation, $uriVariables, $context);
9097
}
9198

0 commit comments

Comments
 (0)