Skip to content

CSRF check failed #25927

Closed
Closed

Description

@sonanchenko

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

Activity

  1. PVince81 commented on Aug 24, 2016

    @PVince81
    Contributor

    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)

  2. sonanchenko commented on Aug 26, 2016

    @sonanchenko
    Author

    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 ?

  3. mmattel commented on Sep 1, 2016

    @mmattel
    Contributor

    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.

  4. sonanchenko commented on Sep 17, 2016

    @sonanchenko
    Author

    hi2all

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

  5. PVince81 commented on Sep 19, 2016

    @PVince81
    Contributor

    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 ?

  6. thommierother commented on Sep 21, 2016

    @thommierother

    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?

  7. lolnerd commented on Sep 22, 2016

    @lolnerd

    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": ""
    }
    }

  8. ycollet commented on Sep 27, 2016

    @ycollet

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

    after successful login.

  9. ycollet commented on Sep 27, 2016

    @ycollet
  10. lep86 commented on Sep 28, 2016

    @lep86

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

  11. takenek commented on Sep 30, 2016

    @takenek

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

  12. ycollet commented on Sep 30, 2016

    @ycollet

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

  13. tudorthe1ntruder commented on Oct 2, 2016

    @tudorthe1ntruder

    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.

  14. takenek commented on Oct 2, 2016

    @takenek

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

  15. 73 remaining items

  16. ckhung commented on Sep 29, 2017

    @ckhung

    Just a quick note for those who might have made the same mistake as me: after seeing @sorintelecom's note, I also tried chromium and then realized that it was because I was fiddling with privacy options in firefox and inadvertently disabled all cookies. For me, re-enabling cookie in firefox solved the problem. Maybe if owncloud's code checks for the ability to write cookie and print a more clear error message, it will be easier to debug further problems?

  17. cars10 commented on Oct 4, 2017

    @cars10

    Edit: solved! See below.
    I still experience the same issue and cannot find a way to fix it.
    I was on 9.1.6, the issue already persisted there. i then upgraded to 10.0.3.3 (via apt-get install owncoud-files)

    What i tried:

    • Increase loglevel and enable debugging. the logs in data/owncloud.log are super unhelpful, no permissions error or anything else, just the following:
    {"reqId":"xu2e8nA4q5YXRPPcBKXH","level":0,"time":"2017-10-04T12:17:29+00:00","remoteAddr":"46.87.94.36","user":"--","app":"no app in context","method":"POST","url":"\/login","message":"CSRF check failed"}
    

    I am completely lost right now. Any hints on what i could try?

    Edit: solved! Thanks to #25927 (comment) it works now. Steps:

    • Create temp folder in your owncloud dir
    • set permissions
  18. PVince81 commented on Nov 6, 2017

    @PVince81
    Contributor

    Raised #29462 to make error more user friendly in case it happens on the login page.

  19. bobalo2 commented on Dec 4, 2017

    @bobalo2

    I am also having this problem on my new installed owncloud instance v. 10.0.03.
    Tried everything from the above mentioned fixes. I'm unsure about the session save path configurations ,as I changed it's permissions with root user, and unsure how to change it as application's user.
    Please advise.
    Running owncloud via cPanel / softacolous. CentOS

  20. issic commented on Jan 9, 2018

    @issic

    Solved:
    Couldnt find a solution, but then discovered that this was in my VirtualHost /etc/apache2/vhost/ip-based.config
    Header edit Set-Cookie ^(.*)$ ;HttpOnly;Secure

    comment it out with # or remove it and it's good to go.

  21. ownclouders commented on Feb 17, 2018

    @ownclouders
    Contributor

    Hey, this issue has been closed because the label status/STALE is set and there were no updates for 7 days. Feel free to reopen this issue if you deem it appropriate.

    (This is an automated comment from GitMate.io.)

  22. PVince81 commented on Feb 19, 2018

    @PVince81
    Contributor

    Please note that since 10.0.5 is more user friendly and will ask for login again.

    I'll leave this ticket closed unless someone finds a CSRF error case that is really a bug and not an environment issue.

  23. alexolinux commented on May 24, 2018

    @alexolinux

    Error: CSRF check failed

    This happens when we log out on owncloud.

    Scenario:
    owncloud (backend) - Apache http port 80
    my frontend - https port 443

    I've a virtualhost with Reverse Proxy.

    Solution:

    Edit $HTML/owncloud/config.php

    'overwrite.cli.url' => 'https://OWNCLOUD_IP/',
    'overwriteprotocol' => 'https',
    'forcessl' => true,

  24. lock commented on Jul 30, 2019

    @lock

    This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

  25. locked as resolved and limited conversation to collaborators on Jul 30, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions