nextcloud / server

☁️ Nextcloud server, a safe home for all your data
https://nextcloud.com
GNU Affero General Public License v3.0
27.54k stars 4.08k forks source link

Request body isn't consumed on (webdav) exception #15315

Closed Thaodan closed 3 years ago

Thaodan commented 5 years ago

Steps to reproduce

  1. Trigger an exception for example access private carddav data without permission.
  2. see that the request body is not consumed.

Expected behaviour

The request body should be consumed before the HTTP status code is send.

Actual behaviour

Nextcloud dosn't consume the body of the old request and the cgi/wsgi implementation doesn't know what to do. This stops for example uwsgi from sending the request to the webserver because uwsgi waits for the app and triggers a timeout to the webserver.

Server configuration

Operating system: Arch Linux Web server: Uwsgi 2.0.18 Nginx 1.14.2 Database: Postgresql PHP version: 7.3.4 Nextcloud version: (see Nextcloud admin page) 16.0 Updated from an older Nextcloud/ownCloud or fresh install: upgrade from 15.x Where did you install Nextcloud from: pacman Signing status:

Signing status ``` No errors have been found. ```

List of activated apps:

App list ``` Enabled: - accessibility: 1.2.0 - activity: 2.9.1 - calendar: 1.7.0 - cloud_federation_api: 0.2.0 - comments: 1.6.0 - contacts: 3.1.1 - dav: 1.9.2 - federatedfilesharing: 1.6.0 - federation: 1.6.0 - files: 1.11.0 - files_pdfviewer: 1.5.0 - files_rightclick: 0.13.0 - files_sharing: 1.8.0 - files_texteditor: 2.8.0 - files_trashbin: 1.6.0 - files_versions: 1.9.0 - files_videoplayer: 1.5.0 - firstrunwizard: 2.5.0 - gallery: 18.3.0 - logreader: 2.1.0 - lookup_server_connector: 1.4.0 - mail: 0.14.0 - news: 13.1.5 - nextcloud_announcements: 1.5.0 - notifications: 2.4.1 - oauth2: 1.4.2 - password_policy: 1.6.0 - privacy: 1.0.0 - provisioning_api: 1.6.0 - recommendations: 0.4.0 - serverinfo: 1.6.0 - sharebymail: 1.6.0 - support: 1.0.0 - survey_client: 1.4.0 - systemtags: 1.6.0 - theming: 1.7.0 - twofactor_backupcodes: 1.5.0 - updatenotification: 1.6.0 - user_ldap: 1.6.0 - viewer: 1.0.0 - workflowengine: 1.6.0 Disabled: - admin_audit - encryption - files_external - grauphel - occweb ```

Nextcloud configuration:

Config report ``` { "system": { "datadirectory": "***REMOVED SENSITIVE VALUE***", "instanceid": "***REMOVED SENSITIVE VALUE***", "appstoreenabled": false, "cache_path": "\/var\/lib\/nextcloud\/cache", "passwordsalt": "***REMOVED SENSITIVE VALUE***", "secret": "***REMOVED SENSITIVE VALUE***", "trusted_domains": [ ], "dbtype": "pgsql", "version": "16.0.0.9", "dbname": "***REMOVED SENSITIVE VALUE***", "dbhost": "***REMOVED SENSITIVE VALUE***", "dbport": "", "dbtableprefix": "oc_", "dbuser": "***REMOVED SENSITIVE VALUE***", "dbpassword": "***REMOVED SENSITIVE VALUE***", "installed": true, "ldapIgnoreNamingRules": true, "ldapProviderFactory": "OCA\\User_LDAP\\LDAPProviderFactory", "log_type": "systemd", "loglevel": 2, "maintenance": false, "memcache.local": "OC\\Memcache\\Redis", "memcache.locking": "OC\\Memcache\\Redis", "redis": { "host": "***REMOVED SENSITIVE VALUE***", "port": 0 }, "updater.release.channel": "stable", "theme": "" }, "apps": { "accessibility": { "types": "", "enabled": "yes", "installed_version": "1.2.0" }, "activity": { "types": "filesystem", "enabled": "yes", "installed_version": "2.9.1" }, "backgroundjob": { "lastjob": "248" }, "calendar": { "types": "", "enabled": "yes", "installed_version": "1.7.0" }, "cloud_federation_api": { "types": "filesystem", "enabled": "yes", "installed_version": "0.2.0" }, "comments": { "types": "logging", "enabled": "yes", "installed_version": "1.6.0" }, "contacts": { "types": "", "enabled": "yes", "installed_version": "3.1.1" }, "core": { "installedat": "1555889443.3732", "vendor": "nextcloud", "public_files": "files_sharing\/public.php", "public_webdav": "dav\/appinfo\/v1\/publicwebdav.php", "lastcron": "1556645228", "lastupdatedat": "1556567848", "scss.variables": "058d502fe120c54fd25d153a1d6c0704", "lastupdateResult": "[]", "shareapi_default_expire_date": "yes", "oc.integritycheck.checker": "[]", "backgroundjobs_mode": "cron" }, "dav": { "types": "filesystem", "enabled": "yes", "installed_version": "1.9.2", "regeneratedBirthdayCalendarsForYearFix": "yes", "buildCalendarSearchIndex": "yes", "chunks_migrated": "1" }, "federatedfilesharing": { "types": "", "enabled": "yes", "installed_version": "1.6.0" }, "federation": { "types": "authentication", "enabled": "yes", "installed_version": "1.6.0" }, "files": { "types": "filesystem", "enabled": "yes", "installed_version": "1.11.0", "cronjob_scan_files": "500" }, "files_pdfviewer": { "types": "", "enabled": "yes", "installed_version": "1.5.0" }, "files_rightclick": { "installed_version": "0.13.0", "types": "", "enabled": "yes" }, "files_sharing": { "types": "filesystem", "enabled": "yes", "installed_version": "1.8.0" }, "files_texteditor": { "types": "", "enabled": "yes", "installed_version": "2.8.0" }, "files_trashbin": { "types": "filesystem,dav", "enabled": "yes", "installed_version": "1.6.0" }, "files_versions": { "types": "filesystem,dav", "enabled": "yes", "installed_version": "1.9.0" }, "files_videoplayer": { "types": "", "enabled": "yes", "installed_version": "1.5.0" }, "firstrunwizard": { "types": "logging", "enabled": "yes", "installed_version": "2.5.0" }, "gallery": { "types": "", "enabled": "yes", "installed_version": "18.3.0" }, "grauphel": { "installed_version": "0.7.1", "types": "", "enabled": "no" }, "logreader": { "types": "", "enabled": "yes", "installed_version": "2.1.0", "relativedates": "1" }, "lookup_server_connector": { "types": "authentication", "enabled": "yes", "installed_version": "1.4.0" }, "mail": { "installed_version": "0.14.0", "types": "", "enabled": "yes" }, "news": { "installed_version": "13.1.5", "types": "", "enabled": "yes" }, "nextcloud_announcements": { "types": "logging", "enabled": "yes", "installed_version": "1.5.0" }, "notifications": { "types": "logging", "enabled": "yes", "installed_version": "2.4.1" }, "oauth2": { "types": "authentication", "enabled": "yes", "installed_version": "1.4.2" }, "password_policy": { "types": "", "enabled": "yes", "installed_version": "1.6.0" }, "privacy": { "installed_version": "1.0.0", "types": "", "enabled": "yes", "readableLocation": "de" }, "provisioning_api": { "types": "prevent_group_restriction", "enabled": "yes", "installed_version": "1.6.0" }, "recommendations": { "installed_version": "0.4.0", "types": "", "enabled": "yes" }, "serverinfo": { "types": "", "enabled": "yes", "installed_version": "1.6.0" }, "sharebymail": { "types": "filesystem", "enabled": "yes", "installed_version": "1.6.0" }, "support": { "installed_version": "1.0.0", "types": "", "enabled": "yes" }, "survey_client": { "types": "", "enabled": "yes", "installed_version": "1.4.0", "last_sent": "1556398670", "last_report": "{\"id\":\"ocsk6q936cke\",\"items\":[[\"server\",\"version\",\"16.0.0.9\"],[\"server\",\"code\",\"other\"],[\"server\",\"enable_avatars\",\"yes\"],[\"server\",\"enable_previews\",\"yes\"],[\"server\",\"memcache.local\",\"OC\\\\Memcache\\\\Redis\"],[\"server\",\"memcache.distributed\",\"none\"],[\"server\",\"asset-pipeline.enabled\",\"no\"],[\"server\",\"filelocking.enabled\",\"yes\"],[\"server\",\"memcache.locking\",\"OC\\\\Memcache\\\\Redis\"],[\"server\",\"debug\",\"no\"],[\"server\",\"cron\",\"cron\"],[\"php\",\"version\",\"7.3.4\"],[\"php\",\"memory_limit\",536870912],[\"php\",\"max_execution_time\",0],[\"php\",\"upload_max_filesize\",2097152],[\"database\",\"type\",\"pgsql\"],[\"database\",\"version\",\"PostgreSQL 11.2 on x86_64-pc-linux-gnu, compiled by gcc (GCC) 8.2.1 20181127, 64-bit\"],[\"database\",\"size\",116927487],[\"apps\",\"support\",\"1.0.0\"],[\"apps\",\"news\",\"13.1.5\"],[\"apps\",\"accessibility\",\"1.2.0\"],[\"apps\",\"federatedfilesharing\",\"1.6.0\"],[\"apps\",\"files_pdfviewer\",\"1.5.0\"],[\"apps\",\"files_texteditor\",\"2.8.0\"],[\"apps\",\"files_videoplayer\",\"1.5.0\"],[\"apps\",\"gallery\",\"18.3.0\"],[\"apps\",\"logreader\",\"2.1.0\"],[\"apps\",\"password_policy\",\"1.6.0\"],[\"apps\",\"provisioning_api\",\"1.6.0\"],[\"apps\",\"serverinfo\",\"1.6.0\"],[\"apps\",\"survey_client\",\"1.4.0\"],[\"apps\",\"twofactor_backupcodes\",\"1.5.0\"],[\"apps\",\"updatenotification\",\"1.6.0\"],[\"apps\",\"federation\",\"1.6.0\"],[\"apps\",\"lookup_server_connector\",\"1.4.0\"],[\"apps\",\"oauth2\",\"1.4.2\"],[\"apps\",\"user_ldap\",\"1.6.0\"],[\"apps\",\"files\",\"1.11.0\"],[\"apps\",\"activity\",\"2.9.1\"],[\"apps\",\"cloud_federation_api\",\"0.2.0\"],[\"apps\",\"dav\",\"1.9.2\"],[\"apps\",\"files_sharing\",\"1.8.0\"],[\"apps\",\"files_trashbin\",\"1.6.0\"],[\"apps\",\"files_versions\",\"1.9.0\"],[\"apps\",\"sharebymail\",\"1.6.0\"],[\"apps\",\"workflowengine\",\"1.6.0\"],[\"apps\",\"comments\",\"1.6.0\"],[\"apps\",\"firstrunwizard\",\"2.5.0\"],[\"apps\",\"nextcloud_announcements\",\"1.5.0\"],[\"apps\",\"notifications\",\"2.4.1\"],[\"apps\",\"systemtags\",\"1.6.0\"],[\"apps\",\"theming\",\"1.7.0\"],[\"apps\",\"grauphel\",\"disabled\"],[\"apps\",\"calendar\",\"1.7.0\"],[\"apps\",\"contacts\",\"3.1.1\"],[\"apps\",\"privacy\",\"1.0.0\"],[\"apps\",\"viewer\",\"1.0.0\"],[\"apps\",\"files_rightclick\",\"0.13.0\"],[\"apps\",\"recommendations\",\"0.4.0\"],[\"apps\",\"mail\",\"0.14.0\"],[\"stats\",\"num_files\",50148],[\"stats\",\"num_users\",3],[\"stats\",\"num_storages\",10],[\"stats\",\"num_storages_local\",7],[\"stats\",\"num_storages_home\",3],[\"stats\",\"num_storages_other\",0],[\"stats\",\"num_comments\",0],[\"stats\",\"num_comment_markers\",0],[\"stats\",\"num_systemtags\",0],[\"stats\",\"num_systemtags_mappings\",0],[\"files_sharing\",\"num_shares\",1],[\"files_sharing\",\"num_shares_user\",1],[\"files_sharing\",\"num_shares_groups\",0],[\"files_sharing\",\"num_shares_link\",0],[\"files_sharing\",\"num_shares_link_no_password\",0],[\"files_sharing\",\"num_fed_shares_sent\",0],[\"files_sharing\",\"num_fed_shares_received\",0],[\"files_sharing\",\"permissions_0_31\",1],[\"encryption\",\"enabled\",\"no\"],[\"encryption\",\"default_module\",\"no\"]]}" }, "systemtags": { "types": "logging", "enabled": "yes", "installed_version": "1.6.0" }, "theming": { "types": "logging", "enabled": "yes", "installed_version": "1.7.0", "color": "#000000", "backgroundMime": "image\/jpeg", "cachebuster": "2" }, "twofactor_backupcodes": { "types": "", "enabled": "yes", "installed_version": "1.5.0" }, "updatenotification": { "types": "", "enabled": "yes", "installed_version": "1.6.0", "update_check_errors": "0" }, "user_ldap": { "s01ldap_port": "389", "s01ldap_backup_host": "", "types": "authentication", "enabled": "yes", "s01ldap_backup_port": "", "s01ldap_override_main_server": "", "s01ldap_base_users": "", "s01ldap_base_groups": "", "s01ldap_user_filter_mode": "0", "s01ldap_login_filter_mode": "0", "s01ldap_loginfilter_username": "1", "s01ldap_dn": "cn=Directory Manager", "s01ldap_base": "dc=thaodan,dc=de", "s01ldap_userfilter_objectclass": "posixAccount", "s01ldap_loginfilter_email": "1", "s01ldap_configuration_active": "1", "s01ldap_userfilter_groups": "users", "installed_version": "1.6.0", "s01ldap_group_filter_mode": "0", "s01ldap_gid_number": "gidNumber", "s01ldap_display_name": "displayName", "s01ldap_group_display_name": "cn", "s01ldap_tls": "0", "s01ldap_quota_def": "", "s01ldap_quota_attr": "", "s01ldap_cache_ttl": "600", "s01ldap_turn_off_cert_check": "0", "s01ldap_attributes_for_user_search": "", "s01ldap_attributes_for_group_search": "", "s01ldap_expert_username_attr": "", "s01use_memberof_to_detect_membership": "1", "s01last_jpegPhoto_lookup": "0", "s01ldap_nested_groups": "0", "s01ldap_paging_size": "500", "s01ldap_turn_on_pwd_change": "0", "s01ldap_experienced_admin": "0", "s01ldap_dynamic_group_member_url": "", "s01ldap_default_ppolicy_dn": "", "s01ldap_user_avatar_rule": "default", "s01ldap_host": "localhost", "s01ldap_agent_password": "Z3IzNHNhcmFoNw==", "s01has_memberof_filter_support": "1", "s01ldap_userlist_filter": "(&(|(objectclass=posixAccount))(|(memberof=cn=users,ou=groups,dc=thaodan,dc=de)))", "s01ldap_loginfilter_attributes": "", "s01ldap_groupfilter_objectclass": "posixGroup", "s01ldap_email_attr": "mail", "s01ldap_user_display_name_2": "mail", "s01ldap_group_member_assoc_attribute": "gidNumber", "cleanUpJobOffset": "0", "s01_lastChange": "1555891248", "background_sync_prefix": "s01", "background_sync_offset": "0", "background_sync_interval": "43200" }, "viewer": { "installed_version": "1.0.0", "types": "", "enabled": "yes" }, "workflowengine": { "types": "filesystem", "enabled": "yes", "installed_version": "1.6.0" } } } ```

Are you using external storage, if yes which one: local/smb/sftp/...

Are you using encryption: yes/no

Are you using an external user-backend, if yes which one: LDAP/ActiveDirectory/Webdav/...

LDAP configuration (delete this part if not used)

LDAP config ``` With access to your command line run e.g.: sudo -u www-data php occ ldap:show-config from within your Nextcloud installation folder Without access to your command line download the data/owncloud.db to your local computer or access your SQL server remotely and run the select query: SELECT * FROM `oc_appconfig` WHERE `appid` = 'user_ldap'; Eventually replace sensitive data as the name/IP-address of your LDAP server or groups. ```

Client configuration

Browser: Firefox 66.x Operating system: Arch Linux

Logs

Web server error log

Web server error log ``` 2019/04/29 08:56:44 [error] 31240#31240: *36 readv() failed (104: Connection reset by peer) while reading upstream, client: 84.175.160.117, server: cloud.thaodan.de, request: "REPORT /remote.php/dav/addressbooks/users/99999/kontakte-1/ HTTP/1.1", upstream: "uwsgi://unix:///run/nextcloud.sock:", host: "cloud.thaodan.de" ```

Nextcloud log (data/nextcloud.log)

Nextcloud log ``` Nextcloud[12055]: {webdav} {"Exception":"Sabre\\Xml\\ParseException","Message":"This should never happen (famous last words)","Code":0,"Trace":[{"file":"\/usr\/share\/webapps\/nextcloud\/3rdparty\/sabre\/xml\/lib\/Element\/Base.php","line":86,"function":"parseInnerTree","class":"Sabre\\Xml\\Reader","type":"->","args":[]},{"function":"xmlDeserialize","class":"Sabre\\Xml\\Element\\Base","type":"::","args":[{"elementMap":{"{DAV:}multistatus":"Sabre\\DAV\\Xml\\Response\\MultiStatus","{DAV:}response":"Sabre\\DAV\\Xml\\Element\\Response","{DAV:}propfind":"Sabre\\DAV\\Xml\\Request\\PropFind","{DAV:}propertyupdate":"Sabre\\DAV\\Xml\\Request\\PropPatch","{DAV:}mkcol":"Sabre\\DAV\\Xml\\Request\\MkCol","{DAV:}resourcetype":"Sabre\\DAV\\Xml\\Property\\ResourceType","{DAV:}sync-collection":"Sabre\\DAV\\Xml\\Request\\SyncCollectionReport","{DAV:}group-member-set":"Sabre\\DAV\\Xml\\Property\\Href","{DAV:}acl":"Sabre\\DAVACL\\Xml\\Property\\Acl","{DAV:}acl-principal-prop-set":"Sabre\\DAVACL\\Xml\\Request\\AclPrincipalPropSetReport","{DAV:}expand-property":"Sabre\\DAVACL\\Xml\\Request\\ExpandPropertyReport","{DAV:}principal-property-search":"Sabre\\DAVACL\\Xml\\Request\\PrincipalPropertySearchReport","{DAV:}principal-search-property-set":"Sabre\\DAVACL\\Xml\\Request\\PrincipalSearchPropertySetReport","{DAV:}principal-match":"Sabre\\DAVACL\\Xml\\Request\\PrincipalMatchReport","{http:\/\/owncloud.org\/ns}share":"OCA\\DAV\\DAV\\Sharing\\Xml\\ShareRequest","{http:\/\/owncloud.org\/ns}invite":"OCA\\DAV\\DAV\\Sharing\\Xml\\Invite","{urn:ietf:params:xml:ns:carddav}addressbook-query":"Sabre\\CardDAV\\Xml\\Request\\AddressBookQueryReport","{urn:ietf:params:xml:ns:carddav}addressbook-multiget":"Sabre\\CardDAV\\Xml\\Request\\AddressBookMultiGetReport","{http:\/\/calendarserver.org\/ns\/}me-card":"Sabre\\DAV\\Xml\\Property\\Href","{http:\/\/owncloud.org\/ns}tags":"OCA\\DAV\\Connector\\Sabre\\TagList","{http:\/\/owncloud.org\/ns}share-types":"OCA\\DAV\\Connector\\Sabre\\ShareTypeList","{http:\/\/nextcloud.com\/ns}calendar-search":"OCA\\DAV\\CalDAV\\Search\\Xml\\Request\\CalendarSearchReport"},"contextUri":"\/remote.php\/dav\/addressbooks\/users\/99999\/kontakte-1","namespaceMap":[],"classMap":[],"__class__":"Sabre\\Xml\\Reader"}]},{"file":"\/usr\/share\/webapps\/nextcloud\/3rdparty\/sabre\/xml\/lib\/Reader.php","line":246,"function":"call_user_func","args":[["Sabre\\Xml\\Element\\Base","xmlDeserialize"],{"elementMap":{"{DAV:}multistatus":"Sabre\\DAV\\Xml\\Response\\MultiStatus","{DAV:}response":"Sabre\\DAV\\Xml\\Element\\Response","{DAV:}propfind":"Sabre\\DAV\\Xml\\Request\\PropFind","{DAV:}propertyupdate":"Sabre\\DAV\\Xml\\Request\\PropPatch","{DAV:}mkcol":"Sabre\\DAV\\Xml\\Request\\MkCol","{DAV:}resourcetype":"Sabre\\DAV\\Xml\\Property\\ResourceType","{DAV:}sync-collection":"Sabre\\DAV\\Xml\\Request\\SyncCollectionReport","{DAV:}group-member-set":"Sabre\\DAV\\Xml\\Property\\Href","{DAV:}acl":"Sabre\\DAVACL\\Xml\\Property\\Acl","{DAV:}acl-principal-prop-set":"Sabre\\DAVACL\\Xml\\Request\\AclPrincipalPropSetReport","{DAV:}expand-property":"Sabre\\DAVACL\\Xml\\Request\\ExpandPropertyReport","{DAV:}principal-property-search":"Sabre\\DAVACL\\Xml\\Request\\PrincipalPropertySearchReport","{DAV:}principal-search-property-set":"Sabre\\DAVACL\\Xml\\Request\\PrincipalSearchPropertySetReport","{DAV:}principal-match":"Sabre\\DAVACL\\Xml\\Request\\PrincipalMatchReport","{http:\/\/owncloud.org\/ns}share":"OCA\\DAV\\DAV\\Sharing\\Xml\\ShareRequest","{http:\/\/owncloud.org\/ns}invite":"OCA\\DAV\\DAV\\Sharing\\Xml\\Invite","{urn:ietf:params:xml:ns:carddav}addressbook-query":"Sabre\\CardDAV\\Xml\\Request\\AddressBookQueryReport","{urn:ietf:params:xml:ns:carddav}addressbook-multiget":"Sabre\\CardDAV\\Xml\\Request\\AddressBookMultiGetReport","{http:\/\/calendarserver.org\/ns\/}me-card":"Sabre\\DAV\\Xml\\Property\\Href","{http:\/\/owncloud.org\/ns}tags":"OCA\\DAV\\Connector\\Sabre\\TagList","{http:\/\/owncloud.org\/ns}share-types":"OCA\\DAV\\Connector\\Sabre\\ShareTypeList","{http:\/\/nextcloud.com\/ns}calendar-search":"OCA\\DAV\\CalDAV\\Search\\Xml\\Request\\CalendarSearchReport"},"contextUri":"\/remote.php\/dav\/addressbooks\/users\/99999\/kontakte-1","namespaceMap":[],"classMap":[],"__class__":"Sabre\\Xml\\Reader"}]},{"file":"\/usr\/share\/webapps\/nextcloud\/3rdparty\/sabre\/xml\/lib\/Reader.php","line":71,"function":"parseCurrentElement","class":"Sabre\\Xml\\Reader","type":"->","args":[]},{"file":"\/usr\/share\/webapps\/nextcloud\/3rdparty\/sabre\/xml\/lib\/Service.php","line":118,"function":"parse","class":"Sabre\\Xml\\Reader","type":"->","args":[]},{"file":"\/usr\/share\/webapps\/nextcloud\/3rdparty\/sabre\/dav\/lib\/DAV\/CorePlugin.php","line":713,"function":"parse","class":"Sabre\\Xml\\Service","type":"->","args":["","\/remote.php\/dav\/addressbooks\/users\/99999\/kontakte-1",null]},{"function":"httpReport","class":"Sabre\\DAV\\CorePlugin","type":"->","args":[{"absoluteUrl":"https:\/\/cloud.thaodan.de\/remote.php\/dav\/addressbooks\/users\/99999\/kontakte-1","__class__":"Sabre\\HTTP\\Request"},{"__class__":"Sabre\\HTTP\\Response"}]},{"file":"\/usr\/share\/webapps\/nextcloud\/3rdparty\/sabre\/event\/lib\/EventEmitterTrait.php","line":105,"function":"call_user_func_array","args":[[{"__class__":"Sabre\\DAV\\CorePlugin"},"httpReport"],[{"absoluteUrl":"https:\/\/cloud.thaodan.de\/remote.php\/dav\/addressbooks\/users\/99999\/kontakte-1","__class__":"Sabre\\HTTP\\Request"},{"__class__":"Sabre\\HTTP\\Response"}]]},{"file":"\/usr\/share\/webapps\/nextcloud\/3rdparty\/sabre\/dav\/lib\/DAV\/Server.php","line":479,"function":"emit","class":"Sabre\\Event\\EventEmitter","type":"->","args":["method:REPORT",[{"absoluteUrl":"https:\/\/cloud.thaodan.de\/remote.php\/dav\/addressbooks\/users\/99999\/kontakte-1","__class__":"Sabre\\HTTP\\Request"},{"__class__":"Sabre\\HTTP\\Response"}]]},{"file":"\/usr\/share\/webapps\/nextcloud\/3rdparty\/sabre\/dav\/lib\/DAV\/Server.php","line":254,"function":"invokeMethod","class":"Sabre\\DAV\\Server","type":"->","args":[{"absoluteUrl":"https:\/\/cloud.thaodan.de\/remote.php\/dav\/addressbooks\/users\/99999\/kontakte-1","__class__":"Sabre\\HTTP\\Request"},{"__class__":"Sabre\\HTTP\\Response"}]},{"file":"\/usr\/share\/webapps\/nextcloud\/apps\/dav\/lib\/Server.php","line":316,"function":"exec","class":"Sabre\\DAV\\Server","type":"->","args":[]},{"file":"\/usr\/share\/webapps\/nextcloud\/apps\/dav\/appinfo\/v2\/remote.php","line":35,"function":"exec","class":"OCA\\DAV\\Server","type":"->","args":[]},{"file":"\/usr\/share\/webapps\/nextcloud\/remote.php","line":163,"args":["\/usr\/share\/webapps\/nextcloud\/apps\/dav\/appinfo\/v2\/remote.php"],"function":"require_once"}],"File":"\/usr\/share\/webapps\/nextcloud\/3rdparty\/sabre\/xml\/lib\/Reader.php","Line":157,"CustomMessage":"--"} ```

Browser log

Browser log ``` no browser log ```

Comments:

I'm not 100% sure if that bug only affects uwsgi but I'm sure thats not good when using php-fpm either.

Thaodan commented 5 years ago

The author of uwsgi explains the issue here: https://stackoverflow.com/questions/13063454/nginx-uwsgi-connection-reset-by-peer?noredirect=1

kesselb commented 5 years ago

Executing php with uwsgi sounds like a bad plan. Is this happening with php-fpm too?

Thaodan commented 5 years ago

Can you explain why? Thats offtopic but uwsgi executes php like any other language. I don't see the issue here.

kesselb commented 5 years ago

Can you explain why?

Just guessing from what you posted here ;) The exception is thrown from sabre/xml https://github.com/sabre-io/xml/blob/e8e9bb3e46afe12262ffd0e994ffa7fd5e163893/lib/Reader.php#L147

cc @nextcloud/server-triage

kesselb commented 4 years ago

Do you still have the REPORT xml body? The stack trace looks like we are already parsing the xml body and also the error is triggered by sabre/xml. I don't think we are able to parse the xml without consuming the body first. But probably the body is consumed in chunks and the failure is somewhere in the middle.

I wonder to be honest why we are parsing the xml at all. Perhaps some technical requirements with sabre but if we already know that a contact does not exist we should throw away the xml.

Thaodan commented 4 years ago

No I don't have the REPORT, at least I didn't look at it. If you tell me a way to get more debug info that fits I'll get that. If I read everything correctly thats the issue that the body is not consumed when caldav login was wrong and 403 is thrown after without consuming the body before.

kesselb commented 4 years ago

OK. How do you trigger this faulty request then?

Thaodan commented 4 years ago

Try to access a webdav ressource that requires login without logging for example.

kesselb commented 4 years ago

Could you give me an example with curl?

curl -I https://xxx/remote.php/dav/addressbooks/users/99999/kontakte-1
curl -I -X REPORT https://xxx/remote.php/dav/addressbooks/users/99999/kontakte-1

Does any of the above requests should trigger This should never happen (famous last words) with uwsgi? :confused:

ghost commented 3 years ago

This issue has been automatically marked as stale because it has not had recent activity and seems to be missing some essential information. It will be closed if no further activity occurs. Thank you for your contributions.

Thaodan commented 3 years ago

Could you give me an example with curl?

curl -I https://xxx/remote.php/dav/addressbooks/users/99999/kontakte-1
curl -I -X REPORT https://xxx/remote.php/dav/addressbooks/users/99999/kontakte-1

Does any of the above requests should trigger This should never happen (famous last words) with uwsgi? confused

Not that message but another exception:

Dec 16 20:08:22 example Nextcloud[659482]: 
{"reqId":"X827YcpbAQl01TQUrWtW","level":4,"time":"2020-12-16T18:08:22+00:00","remoteAddr":"83.245.176.167","user":"99999","app":"webdav","method":"REPORT","url":"/remote.php/dav/addressbooks/users/99999/kontakte-1","message":"{\"Exception\":\"Sabre\\\\Xml\\\\ParseException\",\"Message\":\"The input element to parse is empty. Do not attempt to parse\",\"Code\":0,\"Trace\":[{\"file\":\"/usr/share/webapps/nextcloud/3rdparty/sabre/dav/lib/DAV/CorePlugin.php\",\"line\":715,\"function\":\"parse\",\"class\":\"Sabre\\\\Xml\\\\Service\",\"type\":\"->\",\"args\":[\"\",\"/remote.php/dav/addressbooks/users/99999/kontakte-1\",null]},{\"file\":\"/usr/share/webapps/nextcloud/3rdparty/sabre/event/lib/WildcardEmitterTrait.php\",\"line\":89,\"function\":\"httpReport\",\"class\":\"Sabre\\\\DAV\\\\CorePlugin\",\"type\":\"->\",\"args\":[{\"__class__\":\"Sabre\\\\HTTP\\\\Request\"},{\"__class__\":\"Sabre\\\\HTTP\\\\Response\"}]},{\"file\":\"/usr/share/webapps/nextcloud/3rdparty/sabre/dav/lib/DAV/Server.php\",\"line\":474,\"function\":\"emit\",\"class\":\"Sabre\\\\DAV\\\\Server\",\"type\":\"->\",\"args\":[\"method:REPORT\",[{\"__class__\":\"Sabre\\\\HTTP\\\\Request\"},{\"__class__\":\"Sabre\\\\HTTP\\\\Response\"}]]},{\"file\":\"/usr/share/webapps/nextcloud/3rdparty/sabre/dav/lib/DAV/Server.php\",\"line\":251,\"function\":\"invokeMethod\",\"class\":\"Sabre\\\\DAV\\\\Server\",\"type\":\"->\",\"args\":[{\"__class__\":\"Sabre\\\\HTTP\\\\Request\"},{\"__class__\":\"Sabre\\\\HTTP\\\\Response\"}]},{\"file\":\"/usr/share/webapps/nextcloud/3rdparty/sabre/dav/lib/DAV/Server.php\",\"line\":319,\"function\":\"start\",\"class\":\"Sabre\\\\DAV\\\\Server\",\"type\":\"->\",\"args\":[]},{\"file\":\"/usr/share/webapps/nextcloud/apps/dav/lib/Server.php\",\"line\":325,\"function\":\"exec\",\"class\":\"Sabre\\\\DAV\\\\Server\",\"type\":\"->\",\"args\":[]},{\"file\":\"/usr/share/webapps/nextcloud/apps/dav/appinfo/v2/remote.php\",\"line\":35,\"function\":\"exec\",\"class\":\"OCA\\\\DAV\\\\Server\",\"type\":\"->\",\"args\":[]},{\"file\":\"/usr/share/webapps/nextcloud/remote.php\",\"line\":167,\"args\":[\"/usr/share/webapps/nextcloud/apps/dav/appinfo/v2/remote.php\"],\"function\":\"require_once\"}],\"File\":\"/usr/share/webapps/nextcloud/3rdparty/sabre/xml/lib/Service.php\",\"Line\":121,\"CustomMessage\":\"--\"}","userAgent":"curl/7.73.0","version":"20.0.1.1"}
kesselb commented 3 years ago

@Thaodan could you give me an curl example request?

Thaodan commented 3 years ago

@Thaodan could you give me an curl example request?

Ah sorry the curl output was missing in the message above see here:

~/:curl --user example:example -I -X REPORT https://XX.X/remote.php/dav/
addressbooks/users/99999/kontakte-1
HTTP/2 500 
server: nginx/1.18.0
date: Wed, 16 Dec 2020 22:17:15 GMT
content-type: application/xml; charset=utf-8
expires: Thu, 19 Nov 1981 08:52:00 GMT
cache-control: no-store, no-cache, must-revalidate
pragma: no-cache
set-cookie: oc_sessionPassphrase=XXXXXXXXX secure; HttpOnly; SameSite=Lax
set-cookie: __Host-nc_sameSiteCookielax=true; path=/; httponly;secure; 
expires=Fri, 31-Dec-2100 23:59:59 GMT; SameSite=lax
set-cookie: __Host-nc_sameSiteCookiestrict=true; path=/; httponly;secure; 
expires=Fri, 31-Dec-2100 23:59:59 GMT; SameSite=strict
content-security-policy: default-src 'none';
set-cookie: XXXXXX; path=/; secure; HttpOnly; SameSite=Lax
set-cookie: cookie_test=test; expires=Wed, 16-Dec-2020 23:17:15 GMT; Max-
Age=3600
kesselb commented 3 years ago

That's the response. Mind to share a request you sent to the server that triggers the behaviour?

Thaodan commented 3 years ago

The request is on top of the response output.

Thaodan commented 3 years ago

As the old message no longer appeared I tried to run without the mentioned workaround. Now the message is gone but the issue still exits (Nextcloud 20.1).

ghost commented 3 years ago

This issue has been automatically marked as stale because it has not had recent activity and seems to be missing some essential information. It will be closed if no further activity occurs. Thank you for your contributions.

Thaodan commented 3 years ago

The issue isn't fixed marking it as stale and closing it later only hides the issue.

kesselb commented 3 years ago

I've spent some more time today on this issue but don't know how to reproduce it.

Nextcloud dosn't consume the body of the old request and the cgi/wsgi implementation doesn't know what to do https://stackoverflow.com/questions/13063454/nginx-uwsgi-connection-reset-by-peer?noredirect=1

OK. https://uwsgi-docs.readthedocs.io/en/latest/ThingsToKnow.html is also an interesting read.

If an HTTP request has a body (like a POST request generated by a form), you have to read (consume) it in your application. If you do not do this, the communication socket with your webserver may be clobbered. If you are lazy you can use the post-buffering option that will automatically read data for you. For Rack applications this is automatically enabled.

Make sense.

curl -I https://xxx/remote.php/dav/addressbooks/users/99999/kontakte-1 curl -I -X REPORT https://xxx/remote.php/dav/addressbooks/users/99999/kontakte-1

GET and REPORT does not have a body. I don't know which body we should consume if there is none. You're welcome to dig around some more. Might be easier to use php-fpm ;)

szaimen commented 3 years ago

Is this Issue still valid in NC21.0.2? If not, please close this issue. Thanks! :)

ghost commented 3 years ago

This issue has been automatically marked as stale because it has not had recent activity and seems to be missing some essential information. It will be closed if no further activity occurs. Thank you for your contributions.