owncloud / core

:cloud: ownCloud web server core (Files, DAV, etc.)
https://owncloud.com
GNU Affero General Public License v3.0
8.36k stars 2.06k forks source link

[QA] hardened .htaccess breaks index.php-less setup when ownCloud URL has a subfolder #40696

Closed jnweiger closed 1 year ago

jnweiger commented 1 year ago

Seen with 10.12.0 (regression)

Only the combination of both "index.php-less setup" and "base URL with a folder" is affected. Either one alone, or none of the two works fine.

jnweiger commented 1 year ago

Manual Workaround (when the RewriteBase is /breakme):

--- .htaccess.orig  2023-03-24 01:38:00.365951896 +0000
+++ .htaccess   2023-03-24 01:38:37.613819235 +0000
@@ -104,19 +104,19 @@
   RewriteRule ^core/js/oc.js$ index.php [PT,E=PATH_INFO:$1]
   RewriteRule ^core/preview.png$ index.php [PT,E=PATH_INFO:$1]
   RewriteCond %{REQUEST_URI} !\.(css|js|svg|gif|png|html|ttf|woff|ico|jpg|jpeg|json|properties)$
-  RewriteCond %{REQUEST_URI} !^/core/img/favicon\.ico$
-  RewriteCond %{REQUEST_URI} !^/robots\.txt$
-  RewriteCond %{REQUEST_URI} !^/remote\.php
-  RewriteCond %{REQUEST_URI} !^/public\.php
-  RewriteCond %{REQUEST_URI} !^/cron\.php
-  RewriteCond %{REQUEST_URI} !^/core/ajax/update\.php
-  RewriteCond %{REQUEST_URI} !^/status\.php$
-  RewriteCond %{REQUEST_URI} !^/ocs/v1\.php
-  RewriteCond %{REQUEST_URI} !^/ocs/v2\.php
-  RewriteCond %{REQUEST_URI} !^/updater/
-  RewriteCond %{REQUEST_URI} !^/ocs-provider/
-  RewriteCond %{REQUEST_URI} !^/ocm-provider/
-  RewriteCond %{REQUEST_URI} !^/\.well-known/(acme-challenge|pki-validation)/.*
+  RewriteCond %{REQUEST_URI} !^/breakme/core/img/favicon\.ico$
+  RewriteCond %{REQUEST_URI} !^/breakme/robots\.txt$
+  RewriteCond %{REQUEST_URI} !^/breakme/remote\.php
+  RewriteCond %{REQUEST_URI} !^/breakme/public\.php
+  RewriteCond %{REQUEST_URI} !^/breakme/cron\.php
+  RewriteCond %{REQUEST_URI} !^/breakme/core/ajax/update\.php
+  RewriteCond %{REQUEST_URI} !^/breakme/status\.php$
+  RewriteCond %{REQUEST_URI} !^/breakme/ocs/v1\.php
+  RewriteCond %{REQUEST_URI} !^/breakme/ocs/v2\.php
+  RewriteCond %{REQUEST_URI} !^/breakme/updater/
+  RewriteCond %{REQUEST_URI} !^/breakme/ocs-provider/
+  RewriteCond %{REQUEST_URI} !^/breakme/ocm-provider/
+  RewriteCond %{REQUEST_URI} !^/breakme/\.well-known/(acme-challenge|pki-validation)/.*
   RewriteRule . index.php [PT,E=PATH_INFO:$1]
   RewriteBase /breakme
   <IfModule mod_env.c>
pako81 commented 1 year ago

Caused by https://github.com/owncloud/core/pull/40584

IljaN commented 1 year ago

So this is fixed if we prepend every rule which starts with !^ with $rewriteBase?

pako81 commented 1 year ago

So we should probably prepend the RewriteConds in https://github.com/owncloud/core/blob/master/lib/private/Setup.php#L501-L513 with $rewriteBase ?

IljaN commented 1 year ago

yes

jnweiger commented 1 year ago

@mmattel this is a good entry for the known issues section in the release notes.

suggested Workaround: