core icon indicating copy to clipboard operation
core copied to clipboard

.htaccess is working but Owncloud keeps giving security warnings

Open KKyang opened this issue 11 years ago • 27 comments

OS: Ubuntu 14.04 Owncloud version: 8.1 Updated from Owncloud 8.0.5 Using MySQL

I think my .htaccess is working because if I changed the upload limit size of .htaccess, it actually effects the upload size of a file. Server also gives me permission denied if I try to access the folder apps by browser.

Expected Result

No error message.

Actual Result

Error message: Your data directory and your files are probably accessible from the Internet. The .htaccess file is not working. We strongly suggest that you configure your web server in a way that the data directory is no longer accessible or you move the data directory outside the web server document root.

Did I miss any thing?

Below is my apache ssl config

<IfModule mod_ssl.c>
<VirtualHost _default_:443>
        ServerName <.......>
        Header always add Strict-Transport-Security "max-age=15768000; includeSubDomains; preload"
        ServerAdmin <........>
        DocumentRoot /var/www/owncloud
        <Directory />
                Options FollowSymLinks
                AllowOverride None
        </Directory>
        <Directory /var/www/>
                Options Indexes FollowSymLinks MultiViews
                AllowOverride None
                Require all granted
        </Directory>
        ErrorLog ${APACHE_LOG_DIR}/error.log
        LogLevel warn
        CustomLog ${APACHE_LOG_DIR}/ssl_access.log combined
        SSLEngine on
        SSLCertificateFile    /etc/apache2/ssl/owncloud.pem
        SSLCertificateKeyFile /etc/apache2/ssl/owncloud.key
        <FilesMatch "\.(cgi|shtml|phtml|php)$">
                SSLOptions +StdEnvVars
        </FilesMatch>
        <Directory /usr/lib/cgi-bin>
                SSLOptions +StdEnvVars
        </Directory>
        BrowserMatch "MSIE [2-6]" \
                nokeepalive ssl-unclean-shutdown \
                downgrade-1.0 force-response-1.0
        BrowserMatch "MSIE [17-9]" ssl-unclean-shutdown
        <Directory /var/www/owncloud>
                Options Indexes FollowSymLinks MultiViews
                AllowOverride All
                Require all granted
                # add any possibly required additional directives here
                # e.g. the Satisfy directive (see below for details):
                Satisfy Any
        </Directory>
</VirtualHost>
</IfModule>

KKyang avatar Jul 15 '15 07:07 KKyang

Hi,

you can test that by accessing a known file like:

https://example.com/data/$username/files/yourfile

If you're getting an access denied there your .htaccess protection should work. Then there is a similar issue reported here: https://github.com/owncloud/core/issues/17604

ghost avatar Jul 15 '15 07:07 ghost

@RealRancor Because I store the data folder in another drive, I'm not able to test whether I can access or not. I update the post. I tried by entering the Url https://..../apps

The browser gives me Forbidden

Forbidden

You don't have permission to access /apps/ on this server.


Apache/2.4.7 (Ubuntu) Server at <......> Port 443

Just a bit annoying to see a warning showing up there. :)

KKyang avatar Jul 15 '15 07:07 KKyang

Because I store the data folder in another drive

Mhhh, maybe this is what you have in common with the user in the other report?

ghost avatar Jul 15 '15 07:07 ghost

Hmm, works for me.

I tried setting "datadirectory" to another path, but the admin page doesn't show the warning. Also I tried removing the local empty "data" folder, but I still don't see the warning.

PVince81 avatar Jul 15 '15 08:07 PVince81

@LukasReschke any clue?

PVince81 avatar Jul 27 '15 15:07 PVince81

Just as an idea because the same happened to me: in the global ssl.conf from Apache there were also some header settings that contradicted the .htaccess settings. After removing the "global" settings, the warnings went away.

nodomain avatar Jul 29 '15 06:07 nodomain

This warning is really annoying. My .htaccess is indeed working, I have AllowOverride all in all locations mentioned, data folder is outside owncloud and strong permissions are set according to admin documentation. Yet, I get this warning sometimes, then I delete htaccesstest.txt file in data folder and restart apache and error is gone. And it goes in circle.

mSys-mislav avatar Sep 02 '15 07:09 mSys-mislav

Me too! Same issue, but I can't get the error to go away no matter what I try. The good news is that my files are not really accessible, according to the test described by @RealRancor. I can't remember, but I thought I saw a PHP file somewhere, the one that does the .htaccess test and writes htaccesstest.txt, which uses hardcoded paths to /var/www/owncloud/data. Maybe that's a clue to why this test is failing? By the way, I've fully blown away my ownCloud install and reinstalled from scratch, manually moving all of my data back. The only thing that didn't change was my Apache config, so I suspect that is involved.

linucksrox avatar Sep 05 '15 19:09 linucksrox

@linucksrox The check is not using a fixed file path to the datadir:

https://github.com/owncloud/core/blob/v8.1.1/lib/private/util.php#L1144-L1149

How did you moved the datadir to another place?

ghost avatar Sep 05 '15 19:09 ghost

Oops, that makes sense in the php file. Yes, my data directory was originally /mnt/backup/owncloud/[username] but then in an attempt to resolve this issue I moved that to /mnt/backup/owncloud/data/[username]. I did update the owncloud config file and and apache config references to /var/www/owncloud/data to point to /mnt/backup/owncloud/data.

linucksrox avatar Sep 05 '15 19:09 linucksrox

I wish I knew what changed, because I don't remember making any configuration changes in the past three days (except on a reverse proxy server pointing to this vm but running in a totally separate vm). However, when looking back at the admin console today (I've been ignoring it), there are no more warning messages. Does this warning get cached somewhere or something crazy?

linucksrox avatar Sep 08 '15 19:09 linucksrox

@RealRancor I installed version 8.1.3.0 on a linux platform with apache2.4.3, and I got a similar issue: warning about htaccess not working.

In my case, I understood why:

  • if I create a file test.txt in the folder data and I test the url https://myDDNS/data/test.txt, I get a forbidden access. So my htaccess is really working
  • my server web is behind a router without loopback feature and block any url with my ddns if I try from my LAN.
  • If I open the admin page from a remote host (so out of my LAN), isHtaccessWorking will use my ddns set in $WEBROOT to build the url to try to get the content of htaccesstest.txt.
  • As my server web is hosting on a NAS server behind the router, getUrlContent fails with a not handled error :isHraccessWorking does not run the other code lines after the calling getUrlContent (htaccesstest.txt is not deleted).

Jocko-plugout avatar Oct 15 '15 10:10 Jocko-plugout

@Jocko-plugout You need to ping someone else as i don't have any knowledge about the oC internals.

ghost avatar Oct 15 '15 10:10 ghost

@Jocko-plugout I am facing the same scenario as you described (no error when accessing owncloud from LAN, but the error comes out when accessing owncloud from a remote host), just wondering if you have any fixes for this problem?

nyklspree avatar Dec 28 '15 09:12 nyklspree

Duplicate of #20199-> workaround is to remove the file htaccesstest.txt in the data directory

MorrisJobke avatar Jan 06 '16 08:01 MorrisJobke

~~Fix is in https://github.com/owncloud/core/pull/21479~~

MorrisJobke avatar Jan 06 '16 08:01 MorrisJobke

I get this as well on my demo server. Though I set strong permissions it doesn't seem to work.

root@owncloud:/var/www/html/owncloud/data# ll
total 24
drwxr-x---  4 www-data www-data 4096 jan 14 23:13 ./
drwxr-x--- 14 root     www-data 4096 jan 14 23:00 ../
-rw-r--r--  1 root     www-data  284 jan 13 00:51 .htaccess
-rw-r-----  1 www-data www-data    0 jan 13 00:51 index.html
-rw-r-----  1 www-data www-data    0 jan 13 00:51 .ocdata
-rw-r-----  1 www-data www-data  283 jan 14 23:05 owncloud.log
drwxr-x---  5 www-data www-data 4096 jan 13 00:51 testuser/
drwxr-x---  2 www-data www-data 4096 jan 13 00:51 updater_backup/

Is there any fix?

Server ownCloud 8.2.2 fresh install. Ubuntu 14.04.3 PHP 7

enoch85 avatar Jan 14 '16 22:01 enoch85

@enoch85 Your .htaccess is not working so its unrelated to this issue. Strong permissions also won't help here.

ghost avatar Jan 15 '16 06:01 ghost

@RealRancor Ok then please help. What could be the issue? I've tried adding a htaccesstest.txt to the daatadir, but it won't help. Any suggestions? Fresh install as stated above. --^ cc @LukasReschke

enoch85 avatar Jan 15 '16 09:01 enoch85

@enoch85 The issue tracker shouldn't be used for webserver config issues ;-)

ghost avatar Jan 15 '16 10:01 ghost