core icon indicating copy to clipboard operation
core copied to clipboard

CSRF check failed

Open sonanchenko opened this issue 10 years ago • 81 comments

Dear Colleagues,

STR:

  1. Update to 9.1 version
  2. Try to log in using https://myhost/owncloud

Expected result: Logged in

Actual result: I receive "Access denied. CSRF check failed" after I click Enter.

Strange thing is that for http version everything is fine.

I've also switched to 9.2 alpha and now have owncloud-files-9.2.0-0.1.1.prealpha.20160822.noarch but the issue still in place.

Similar issues were discussed in #25557 and #25799 but @PVince81 asked me to create a new issue.

Here is the tech details:

OS: CentOS 6.8 x64 WebServer: httpd=2.2.27 DB: MariaDB-server-10.1.16 PHP: 5.5.38 Owncloud version: 9.2.0-0.1.1.prealpha.20160822 updated from 9.1 and older ones

APPS:

root /var/www/html/owncloud # sudo -u owncloud php occ app:list Enabled:

  • calendar: 1.3.2
  • comments: 0.3.0
  • dav: 0.2.5
  • direct_menu: 0.8.1
  • encryption: 1.3.0
  • federatedfilesharing: 0.3.0
  • federation: 0.1.0
  • files: 1.5.1
  • files_excel_reader: 0.1.0
  • files_mv: 0.8.2
  • files_sharing: 0.10.0
  • files_trashbin: 0.9.0
  • files_versions: 1.3.0
  • provisioning_api: 0.5.0
  • systemtags: 0.3.0
  • tasks: 0.9.2
  • updatenotification: 0.2.1

Disabled:

  • activity
  • bookmarks
  • calendarplus
  • contacts
  • documents
  • external
  • files_antivirus
  • files_external
  • files_pdfviewer
  • files_texteditor
  • files_videoplayer
  • firstrunwizard
  • gallery
  • galleryplus
  • notifications
  • ojsxc
  • ownnote
  • sharelinks
  • tasksplus
  • templateeditor
  • user_external
  • user_ldap
  • vids

CONFIG: root /var/www/html/owncloud # sudo -u owncloud php occ config:list system { "system": { "debug": true, "instanceid": "ocjl3amsodm7", "passwordsalt": "_REMOVED SENSITIVE VALUE", "secret": "_REMOVED SENSITIVE VALUE", "trusted_domains": [ "mydomain.com" ], "datadirectory": "/var/www/html/owncloud/data", "overwrite.cli.url": "https://mydomain.com/owncloud", "dbtype": "mysql", "version": "9.2.0.1", "dbname": "owncloud", "dbhost": "localhost", "dbtableprefix": "oc_", "dbuser": "_REMOVED SENSITIVE VALUE", "dbpassword": "_REMOVED SENSITIVE VALUE", "installed": true, "forcessl": true, "forceSSLforSubdomains": true, "mail_from_address": "root", "mail_smtpmode": "php", "mail_domain": "mydomain.com", "theme": "", "maintenance": false, "loglevel": 1, "trashbin_retention_obligation": "auto", "updatechecker": false, "htaccess.RewriteBase": "/owncloud" } }

As for logs - no new lines in owncloud.log and in httpd logs and browser ones there were no info about error also.


Please check and do not hesitate to ask if any additional information is required

sonanchenko avatar Aug 24 '16 10:08 sonanchenko

Can you check your access log and see whether it's using http or https when posting the login form ? The CSRF token is stored in the session, which is handled by the cookies. If the form is posted to a different domain / protocol, the session would be a different one and the CSRF token wouldn't match.

So far it looks like an environment/config issue. I assume you already checked http://central.owncloud.org/ and the forums for similar issues ? (https + csrf)

PVince81 avatar Aug 24 '16 15:08 PVince81

Hi, Sorry for re-opening.

I've checked logs - in httpd logs I see that everything is handled by https:

[26/Aug/2016:19:12:54 +0300] 31.135.132.106 TLSv1.2 ECDHE-RSA-AES128-GCM-SHA256 "POST /owncloud/index.php/login HTTP/1.1" 8965 [26/Aug/2016:19:12:55 +0300] 31.135.132.106 TLSv1.2 ECDHE-RSA-AES128-GCM-SHA256 "GET /owncloud/index.php/core/js/oc.js?v=e2c0a62bf817618e92f96d24613b7250 HTTP/1.1" 3934 [26/Aug/2016:19:12:56 +0300] 31.135.132.106 TLSv1.2 ECDHE-RSA-AES128-GCM-SHA256 "GET /owncloud/core/vendor/jquery/dist/jquery.min.map HTTP/1.1" 127576 [26/Aug/2016:19:12:58 +0300] 31.135.132.106 TLSv1.2 ECDHE-RSA-AES128-GCM-SHA256 "GET /owncloud/cron.php HTTP/1.1" 20

Also, I have not found any useful info on central.owncloud.org that may be connected with my issue. (I've only added opcache.save-comments that is suggested at https://central.owncloud.org/t/known-problems-with-php-webserver-modules-or-configs/835)

Could you please help me with my issue ?

I appreciate any help you can provide. What other info about my system can be useful ?

sonanchenko avatar Aug 26 '16 16:08 sonanchenko

After reinstalling 9.1 from scratch, I got one time the same error when trying to logon. When retrying it worked and I have no clue why. My working nginx config did not change between killing and reinstalling the instance.

mmattel avatar Sep 01 '16 14:09 mmattel

hi2all

any updates on this issue ? 9.2 alpha is also affected with this issue (

sonanchenko avatar Sep 17 '16 14:09 sonanchenko

Could you guys all post your configs so we can see what is similar ?

From the first config I see this:

"forcessl": true,
"forceSSLforSubdomains": true,

I suppose you're all using the exact same options ?

PVince81 avatar Sep 19 '16 07:09 PVince81

The issue is still present in the just released 9.1.1 (session cookies were cleared before testing). I only use

'forcessl' => true,

But not "forceSSLforSubdomains" I disabled and enabled the forcessl value, no difference. Note that this apache itself has a rewrite rule for https

RewriteRule ^/owncloud(.*) https://%{SERVER_NAME}/owncloud$1 [R,L]

So forcessl inside OC is not really necessary in my case Is there any option to log the login procedure?

thommierother avatar Sep 21 '16 13:09 thommierother

Here is my config regarding the "CSRF check failed" issue, after upgrading from 9.0 to 9.1 and persistent after upgrade to 9.1.1:

root@mydomain:/var/www/owncloud# sudo -u www-data php occ config:list system { "system": { "updatechecker": false, "instanceid": "ocwnXXXXXXX", "passwordsalt": "_REMOVED SENSITIVE VALUE", "secret": "_REMOVED SENSITIVE VALUE", "trusted_domains": [ "mydomain.com" ], "datadirectory": "/var/www/owncloud/data", "overwrite.cli.url": "https://cloud.mydomain.com", "dbtype": "mysql", "version": "9.1.1.3", "dbname": "ownclouddb", "dbhost": "localhost", "dbtableprefix": "oc_", "dbuser": "_REMOVED SENSITIVE VALUE", "dbpassword": "_REMOVED SENSITIVE VALUE", "logtimezone": "UTC", "installed": true, "mail_from_address": "info", "mail_smtpmode": "php", "mail_domain": "cloud.mydomain.com", "maintenance": false, "loglevel": 3, "htaccess.RewriteBase": "/", "theme": "" } }

lolnerd avatar Sep 22 '16 08:09 lolnerd

I have the same problem here with 9.1.1. "Access forbidden CSRF check failed"

after successful login.

ycollet avatar Sep 27 '16 15:09 ycollet

I found an old topic related to CSRF check failed in the forum: https://forum.owncloud.org/viewtopic.php?f=26&t=21889&start=10

ycollet avatar Sep 27 '16 15:09 ycollet

that don't work. Have some problem with OC 9.1.1 Fresh install on ubuntu 16.04 tls 2016-09-28_082157

lep86 avatar Sep 28 '16 03:09 lep86

Same problem here - just upgrade from 9.0.2 to 9.1.0 and got CSRF check failed....

takenek avatar Sep 30 '16 10:09 takenek

I rebooted my server and everything went fine. I don't know if this was due to an openssl update ...

ycollet avatar Sep 30 '16 11:09 ycollet

I was having the same issue from an out of box installation on CentOS and discovered that 2 cookies which were set when first accessing the login page had the "Secure" flag on. Because I have not installed the SSL certificate at that time and running on a plain HTTP connection, I realized that the browser was simply not sending the cookies to the server due to the "Secure flag".

This is a bug for non-ssl installations, secure flag should not be set when plain http is used by owncloud.

tudorthe1ntruder avatar Oct 02 '16 17:10 tudorthe1ntruder

No - my server use only SSL and got this issue. take a look: https://owncloud.taken.pl

takenek avatar Oct 02 '16 20:10 takenek

no solutions? :(

lep86 avatar Oct 04 '16 06:10 lep86

I'm also on an SSL-only installation and still get this error.

lolnerd avatar Oct 04 '16 08:10 lolnerd

Can someone provide exact steps how to reproduce this on a local test instance ? Additionally to config.php, also provide Apache configs (SSL, ports, etc) and the name of the URLs (including protocol) that were used when logging in, and also which URLs they get redirected to.

alternative: provide a docker or vagrant VM where the issue is happening to make debugging easier.

Thanks

PVince81 avatar Oct 04 '16 09:10 PVince81

If I use firefox navigator (https://myowncloud on Debian) I obtain the "Access forbidden CSRF check failed". If I use the chrome navigator (same address, same ubuntu PC) I can log in!

ghost avatar Oct 04 '16 09:10 ghost

Hello again: the firefox extension "owncloud bookmark 0.0.6" generate this error! I remove the extension and I can log in again on my owncloud server!

ghost avatar Oct 04 '16 09:10 ghost

@PVince81 I've come across this on a setup in which the front-end reverse proxy is applying the SSL layer and the request is forwarded to a non-SSL apache server. So I guess this is a problem with how headers reach the CSRF check code.

tomascohen avatar Oct 08 '16 22:10 tomascohen