-
-
Notifications
You must be signed in to change notification settings - Fork 4.6k
Description
⚠️ This issue respects the following points: ⚠️
- This is a bug, not a question or a configuration/webserver/proxy issue.
- This issue is not already reported on Github OR Nextcloud Community Forum (I've searched it).
- Nextcloud Server is up to date. See Maintenance and Release Schedule for supported versions.
- I agree to follow Nextcloud's Code of Conduct.
Bug description
I am getting frequent HTTP 412 errors, it says {"message": "CSRF check failed"}
I think everything I've configured is reasonable, since the upgrade to V26 it started to appear, recently upgraded to V27 the problem has become more frequent!
According to my experiments and observations I found that this problem may have something to do with the layout's head tag, I use the data-requesttoken returned to me by the page's head to make a request will generate a 412 error, But when I use "/csrftoken" to get the token, making the request works!
I have observed that this problem has been around for a long time and has not been resolved on the internet, so I hope to receive your further attention
I'd like to make a suggestion if it's possible to catch a 412 error on the front-end and then Call /csrftoke to refresh the CSRF Token and immediately re-request it?
https://github.com/nextcloud/server/blob/master/core/templates/layout.base.php#L3
https://github.com/nextcloud/server/blob/master/core/Controller/CSRFTokenController.php#L57
Steps to reproduce
1.Clocking a page
2.Accessing an interface without the @NoCSRFRequired annotation
Expected behavior
The request was successful
Installation method
Community Manual installation with Archive
Nextcloud Server version
27
Operating system
Debian/Ubuntu
PHP engine version
PHP 8.0
Web server
Nginx
Database engine version
MySQL
Is this bug present after an update or on a fresh install?
Upgraded to a MAJOR version (ex. 22 to 23)
Are you using the Nextcloud Server Encryption module?
Encryption is Disabled
What user-backends are you using?
- Default user-backend (database)
- LDAP/ Active Directory
- SSO - SAML
- Other
Configuration report
{
"system": {
"instanceid": "***REMOVED SENSITIVE VALUE***",
"passwordsalt": "***REMOVED SENSITIVE VALUE***",
"secret": "***REMOVED SENSITIVE VALUE***",
"memcache.local": "\\OC\\Memcache\\APCu",
"memcache.distributed": "\\OC\\Memcache\\Redis",
"memcache.locking": "\\OC\\Memcache\\Redis",
"redis": {
"host": "***REMOVED SENSITIVE VALUE***",
"port": 6379
},
"trusted_domains": [
"xxxxxxx:xxxxx",
],
"datadirectory": "***REMOVED SENSITIVE VALUE***",
"dbtype": "mysql",
"version": "27.1.0.7",
"overwrite.cli.url": "https:\/\/xxxxxx:xxxx\/xxxxxx\/",
"overwriteprotocol": "https",
"allow_local_remote_servers": "true",
"dbname": "***REMOVED SENSITIVE VALUE***",
"dbhost": "***REMOVED SENSITIVE VALUE***",
"dbport": "",
"dbtableprefix": "oc_",
"mysql.utf8mb4": true,
"dbuser": "***REMOVED SENSITIVE VALUE***",
"dbpassword": "***REMOVED SENSITIVE VALUE***",
"installed": true,
"twofactor_enforced": "true",
"tempdirectory": "\/data\/nextcloud_tmp\/",
"default_language": "ja",
"default_locale": "jp-JA",
"twofactor_enforced_groups": [
"admin",
],
"twofactor_enforced_excluded_groups": [],
"mail_from_address": "***REMOVED SENSITIVE VALUE***",
"mail_smtpmode": "smtp",
"mail_sendmailmode": "smtp",
"mail_domain": "***REMOVED SENSITIVE VALUE***",
"mail_smtpauthtype": "LOGIN",
"mail_smtpauth": 1,
"mail_smtpsecure": "tls",
"mail_smtphost": "***REMOVED SENSITIVE VALUE***",
"mail_smtpport": "587",
"mail_smtpname": "***REMOVED SENSITIVE VALUE***",
"mail_smtppassword": "***REMOVED SENSITIVE VALUE***",
"maintenance": false,
"updater.release.channel": "stable",
"theme": "",
"loglevel": 0,
"default_phone_region": "JP",
"app_install_overwrite": [
"epubreader",
"scanner"
],
}
}List of activated Apps
Enabled:
- activity: 2.19.0
- admin_audit: 1.17.0
- bruteforcesettings: 2.7.0
- circles: 27.0.1
- cloud_federation_api: 1.10.0
- comments: 1.17.0
- contacts: 5.4.2
- contactsinteraction: 1.8.0
- dashboard: 7.7.0
- dav: 1.27.0
- deck: 1.11.0
- duplicatefinder: 1.0.5
- external: 5.2.1
- extract: 1.3.6
- federatedfilesharing: 1.17.0
- federation: 1.17.0
- files: 1.22.0
- files_3dmodelviewer: 0.0.12
- files_accesscontrol: 1.17.1
- files_external: 1.19.0
- files_fulltextsearch: 27.0.1
- files_mindmap: 0.0.29
- files_pdfviewer: 2.8.0
- files_reminders: 1.0.0
- files_rightclick: 1.6.0
- files_sharing: 1.19.0
- files_trashbin: 1.17.0
- files_versions: 1.20.0
- fulltextsearch: 27.0.1
- fulltextsearch_elasticsearch: 27.0.2
- health: 1.6.2
- impersonate: 1.14.0
- logreader: 2.12.0
- lookup_server_connector: 1.15.0
- metadata: 0.19.0
- ncdownloader: 1.0.20
- nextcloud_announcements: 1.16.0
- notes: 4.8.1
- notifications: 2.15.0
- oauth2: 1.15.1
- password_policy: 1.17.0
- photos: 2.3.0
- previewgenerator: 5.3.0
- privacy: 1.11.0
- provisioning_api: 1.17.0
- quota_warning: 1.17.0
- recognize: 4.3.2
- recommendations: 1.6.0
- related_resources: 1.2.0
- richdocuments: 8.2.0
- scanner: 0.2.3
- serverinfo: 1.17.0
- settings: 1.9.0
- sharebymail: 1.17.0
- side_menu: 3.10.3
- support: 1.10.0
- survey_client: 1.15.0
- suspicious_login: 5.0.0
- systemtags: 1.17.0
- text: 3.8.0
- theming: 2.2.0
- theming_customcss: 1.14.0
- twofactor_backupcodes: 1.16.0
- twofactor_totp: 9.0.0
- twofactor_webauthn: 1.2.0
- updatenotification: 1.17.0
- user_saml: 5.2.2
- user_status: 1.7.0
- video_converter: 1.0.6
- viewer: 2.1.0
- weather_status: 1.7.0
- workflowengine: 2.9.0
Disabled:
- encryption: 2.15.0
- firstrunwizard: 2.16.0 (installed 2.10.0)
- user_ldap: 1.17.0Nextcloud Signing status
No response
Nextcloud Logs
{"reqId":"7pguVp7wVcp1j7oblyn6","level":0,"time":"2023-09-26T02:54:55+00:00","remoteAddr":"xxxx","user":"xxxx","app":"no app in context","method":"GET","url":"/nextcloud/apps/xxxxxxxxxxxx","message":"CSRF check failed","userAgent":"xxxxxxxxxxxx","version":"27.1.0.7","exception":{"Exception":"OC\\AppFramework\\Middleware\\Security\\Exceptions\\CrossSiteRequestForgeryException","Message":"CSRF check failed","Code":412,"Trace":[{"file":"/xxxxx/wwwroot/nextcloud/nextcloud/lib/private/AppFramework/Middleware/MiddlewareDispatcher.php","line":96,"function":"beforeController","class":"OC\\AppFramework\\Middleware\\Security\\SecurityMiddleware","type":"->"},{"file":"/xxxxx/wwwroot/nextcloud/nextcloud/lib/private/AppFramework/Http/Dispatcher.php","line":129,"function":"beforeController","class":"OC\\AppFramework\\Middleware\\MiddlewareDispatcher","type":"->"},{"file":"/xxxxx/wwwroot/nextcloud/nextcloud/lib/private/AppFramework/App.php","line":183,"function":"dispatch","class":"OC\\AppFramework\\Http\\Dispatcher","type":"->"},{"file":"/xxxxx/wwwroot/nextcloud/nextcloud/lib/private/Route/Router.php","line":315,"function":"main","class":"OC\\AppFramework\\App","type":"::"},{"file":"/xxxxx/wwwroot/nextcloud/nextcloud/lib/base.php","line":1068,"function":"match","class":"OC\\Route\\Router","type":"->"},{"file":"/xxxxx/wwwroot/nextcloud/nextcloud/index.php","line":36,"function":"handleRequest","class":"OC","type":"::"}],"File":"/xxxxx/wwwroot/nextcloud/nextcloud/lib/private/AppFramework/Middleware/Security/SecurityMiddleware.php","Line":224,"message":"CSRF check failed","exception":{},"CustomMessage":"CSRF check failed"}}Additional info
Nextcloud 27.1.0