diff options
author | Ferdinand Thiessen <rpm@fthiessen.de> | 2023-01-26 21:08:10 +0100 |
---|---|---|
committer | Ferdinand Thiessen <rpm@fthiessen.de> | 2023-02-16 22:55:18 +0100 |
commit | f655f83c840f30781999cd84d800cb2cc27983bf (patch) | |
tree | 8df8276fc81af6224b936482109ca49be9cb5013 /lib/private/AppFramework | |
parent | 57c974f421e8a409ef728fae0b1ac670a70c7f11 (diff) | |
download | nextcloud-server-f655f83c840f30781999cd84d800cb2cc27983bf.tar.gz nextcloud-server-f655f83c840f30781999cd84d800cb2cc27983bf.zip |
fix(CORS): CORS should only be bypassed on `PublicPage` if not logged in to prevent CSRF attack vectors
Signed-off-by: Ferdinand Thiessen <rpm@fthiessen.de>
Diffstat (limited to 'lib/private/AppFramework')
-rw-r--r-- | lib/private/AppFramework/Middleware/Security/CORSMiddleware.php | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/lib/private/AppFramework/Middleware/Security/CORSMiddleware.php b/lib/private/AppFramework/Middleware/Security/CORSMiddleware.php index 2476f4ec9b3..30ba8d8d6e4 100644 --- a/lib/private/AppFramework/Middleware/Security/CORSMiddleware.php +++ b/lib/private/AppFramework/Middleware/Security/CORSMiddleware.php @@ -83,7 +83,7 @@ class CORSMiddleware extends Middleware { public function beforeController($controller, $methodName) { // ensure that @CORS annotated API routes are not used in conjunction // with session authentication since this enables CSRF attack vectors - if ($this->reflector->hasAnnotation('CORS') && !$this->reflector->hasAnnotation('PublicPage')) { + if ($this->reflector->hasAnnotation('CORS') && (!$this->reflector->hasAnnotation('PublicPage') || $this->session->isLoggedIn())) { $user = array_key_exists('PHP_AUTH_USER', $this->request->server) ? $this->request->server['PHP_AUTH_USER'] : null; $pass = array_key_exists('PHP_AUTH_PW', $this->request->server) ? $this->request->server['PHP_AUTH_PW'] : null; |