OCP\Files\ForbiddenException: Invalid path

Nextcloud version 17.0.2:
Operating system and version Debian 10
nginx version: nginx/1.17.8
PHP version 7.3

The issue you are facing:

I have a user that is having problems manipulating her folders. Underlying permissions on the storage is all correct (www-data:www-data 775). The user has some data that was imported from the old system and added into nextcloud with occ. She is unable to delete or move folders in her username/files/folders although she has full permission over the files contained within.

Is this the first time you’ve seen this error? (Y/N): Y

Steps to replicate it:

  1. Login or impersonate affected user
  2. delete, move or rename a folder

Admin > Logging: Rename

{"reqId":"ZMDQOA3HGoZpm1nutBi5","level":4,"time":"2020-01-31T14:11:50+00:00","remoteAddr":"86.31.185.11","user":"usr@fullyqualified.domain.name","app":"webdav","method":"MOVE","url":"/remote.php/dav/files/usr@fullyqualified.domain.name/User/Desktop/FDD","message":{"Exception":"OCP\\Files\\ForbiddenException","Message":"Invalid path","Code":0,"Trace":[{"file":"/var/www/nextcloud/lib/private/Files/Storage/Wrapper/Wrapper.php","line":277,"function":"rename","class":"OC\\Files\\Storage\\Local","type":"->","args":["files/User/Desktop/FDD","files/User/Desktop/FDD2"]},{"file":"/var/www/nextcloud/lib/private/Files/Storage/Wrapper/Wrapper.php","line":277,"function":"rename","class":"OC\\Files\\Storage\\Wrapper\\Wrapper","type":"->","args":["files/User/Desktop/FDD","files/User/Desktop/FDD2"]},{"file":"/var/www/nextcloud/lib/private/Files/Storage/Wrapper/Wrapper.php","line":277,"function":"rename","class":"OC\\Files\\Storage\\Wrapper\\Wrapper","type":"->","args":["files/User/Desktop/FDD","files/User/Desktop/FDD2"]},{"file":"/var/www/nextcloud/lib/private/Files/View.php","line":813,"function":"rename","class":"OC\\Files\\Storage\\Wrapper\\Wrapper","type":"->","args":["files/User/Desktop/FDD","files/User/Desktop/FDD2"]},{"file":"/var/www/nextcloud/apps/dav/lib/Connector/Sabre/Node.php","line":141,"function":"rename","class":"OC\\Files\\View","type":"->","args":["/User/Desktop/FDD","/User/Desktop/FDD2"]},{"file":"/var/www/nextcloud/3rdparty/sabre/dav/lib/DAV/Tree.php","line":151,"function":"setName","class":"OCA\\DAV\\Connector\\Sabre\\Node","type":"->","args":["FDD2"]},{"file":"/var/www/nextcloud/3rdparty/sabre/dav/lib/DAV/CorePlugin.php","line":642,"function":"move","class":"Sabre\\DAV\\Tree","type":"->","args":["files/usr@fullyqualified.domain.name/User/Desktop/FDD","files/usr@fullyqualified.domain.name/User/Desktop/FDD2"]},{"function":"httpMove","class":"Sabre\\DAV\\CorePlugin","type":"->","args":[{"absoluteUrl":"https://supported.redirectme.net/remote.php/dav/files/usr@fullyqualified.domain.name/User/Desktop/FDD","__class__":"Sabre\\HTTP\\Request"},{"__class__":"Sabre\\HTTP\\Response"}]},{"file":"/var/www/nextcloud/3rdparty/sabre/event/lib/EventEmitterTrait.php","line":105,"function":"call_user_func_array","args":[[{"__class__":"Sabre\\DAV\\CorePlugin"},"httpMove"],[{"absoluteUrl":"https://supported.redirectme.net/remote.php/dav/files/usr@fullyqualified.domain.name/User/Desktop/FDD","__class__":"Sabre\\HTTP\\Request"},{"__class__":"Sabre\\HTTP\\Response"}]]},{"file":"/var/www/nextcloud/3rdparty/sabre/dav/lib/DAV/Server.php","line":479,"function":"emit","class":"Sabre\\Event\\EventEmitter","type":"->","args":["method:MOVE",[{"absoluteUrl":"https://supported.redirectme.net/remote.php/dav/files/usr@fullyqualified.domain.name/User/Desktop/FDD","__class__":"Sabre\\HTTP\\Request"},{"__class__":"Sabre\\HTTP\\Response"}]]},{"file":"/var/www/nextcloud/3rdparty/sabre/dav/lib/DAV/Server.php","line":254,"function":"invokeMethod","class":"Sabre\\DAV\\Server","type":"->","args":[{"absoluteUrl":"https://supported.redirectme.net/remote.php/dav/files/usr@fullyqualified.domain.name/User/Desktop/FDD","__class__":"Sabre\\HTTP\\Request"},{"__class__":"Sabre\\HTTP\\Response"}]},{"file":"/var/www/nextcloud/apps/dav/lib/Server.php","line":317,"function":"exec","class":"Sabre\\DAV\\Server","type":"->","args":[]},{"file":"/var/www/nextcloud/apps/dav/appinfo/v2/remote.php","line":35,"function":"exec","class":"OCA\\DAV\\Server","type":"->","args":[]},{"file":"/var/www/nextcloud/remote.php","line":163,"args":["/var/www/nextcloud/apps/dav/appinfo/v2/remote.php"],"function":"require_once"}],"File":"/var/www/nextcloud/lib/private/Files/Storage/Local.php","Line":285,"CustomMessage":"--"},"userAgent":"Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:72.0) Gecko/20100101 Firefox/72.0","version":"17.0.2.1","id":"5e3435a6e94f3"}

Admin > Logging: Delete

{"reqId":"vZl4GfgvCZT1cL9d3Rrp","level":4,"time":"2020-01-31T13:33:17+00:00","remoteAddr":"86.31.185.11","user":"usr@fullyqualified.domain.name","app":"webdav","method":"DELETE","url":"/remote.php/dav/files/usr@fullyqualified.domain.name/User/Desktop/circus%20skills","message":{"Exception":"OCA\\DAV\\Connector\\Sabre\\Exception\\Forbidden","Message":"Invalid path","Code":0,"Trace":[{"file":"/var/www/nextcloud/3rdparty/sabre/dav/lib/DAV/Tree.php","line":179,"function":"delete","class":"OCA\\DAV\\Connector\\Sabre\\Directory","type":"->","args":[]},{"file":"/var/www/nextcloud/3rdparty/sabre/dav/lib/DAV/CorePlugin.php","line":287,"function":"delete","class":"Sabre\\DAV\\Tree","type":"->","args":["files/usr@fullyqualified.domain.name/User/Desktop/circus skills"]},{"function":"httpDelete","class":"Sabre\\DAV\\CorePlugin","type":"->","args":[{"absoluteUrl":"https://supported.redirectme.net/remote.php/dav/files/usr@fullyqualified.domain.name/User/Desktop/circus%20skills","__class__":"Sabre\\HTTP\\Request"},{"__class__":"Sabre\\HTTP\\Response"}]},{"file":"/var/www/nextcloud/3rdparty/sabre/event/lib/EventEmitterTrait.php","line":105,"function":"call_user_func_array","args":[[{"__class__":"Sabre\\DAV\\CorePlugin"},"httpDelete"],[{"absoluteUrl":"https://supported.redirectme.net/remote.php/dav/files/usr@fullyqualified.domain.name/User/Desktop/circus%20skills","__class__":"Sabre\\HTTP\\Request"},{"__class__":"Sabre\\HTTP\\Response"}]]},{"file":"/var/www/nextcloud/3rdparty/sabre/dav/lib/DAV/Server.php","line":479,"function":"emit","class":"Sabre\\Event\\EventEmitter","type":"->","args":["method:DELETE",[{"absoluteUrl":"https://supported.redirectme.net/remote.php/dav/files/usr@fullyqualified.domain.name/User/Desktop/circus%20skills","__class__":"Sabre\\HTTP\\Request"},{"__class__":"Sabre\\HTTP\\Response"}]]},{"file":"/var/www/nextcloud/3rdparty/sabre/dav/lib/DAV/Server.php","line":254,"function":"invokeMethod","class":"Sabre\\DAV\\Server","type":"->","args":[{"absoluteUrl":"https://supported.redirectme.net/remote.php/dav/files/usr@fullyqualified.domain.name/User/Desktop/circus%20skills","__class__":"Sabre\\HTTP\\Request"},{"__class__":"Sabre\\HTTP\\Response"}]},{"file":"/var/www/nextcloud/apps/dav/lib/Server.php","line":317,"function":"exec","class":"Sabre\\DAV\\Server","type":"->","args":[]},{"file":"/var/www/nextcloud/apps/dav/appinfo/v2/remote.php","line":35,"function":"exec","class":"OCA\\DAV\\Server","type":"->","args":[]},{"file":"/var/www/nextcloud/remote.php","line":163,"args":["/var/www/nextcloud/apps/dav/appinfo/v2/remote.php"],"function":"require_once"}],"File":"/var/www/nextcloud/apps/dav/lib/Connector/Sabre/Directory.php","Line":317,"CustomMessage":"--"},"userAgent":"Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:72.0) Gecko/20100101 Firefox/72.0","version":"17.0.2.1","id":"5e342c9e1abc2"}

The output of your nginx log in /var/log/nginx/access.log: Delete

86.171.150.166 - - [31/Jan/2020:10:40:31 +0000] "DELETE /remote.php/dav/files/usr@fullyqualified.domain.name/User/Desktop/FDD HTTP/2.0" 403 223 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.0.5 Safari/605.1.15"
86.171.150.166 - - [31/Jan/2020:10:41:16 +0000] "DELETE /remote.php/dav/files/usr@fullyqualified.domain.name/User/Desktop/FDD HTTP/2.0" 403 223 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.0.5 Safari/605.1.15"

The output of your nginx log in /var/log/nginx/access.log: Move

86.31.185.11 - - [31/Jan/2020:14:11:50 +0000] "MOVE /remote.php/dav/files/usr@fullyqualified.domain.name/User/Desktop/FDD HTTP/2.0" 500 204 "-" "Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:72.0) Gecko/20100101 Firefox/72.0"

I have rsync’d the folder that the user that has the problem with to another users /files/* and then used occ to scan the imported files and I have the same problem with that user too… so it doesn’t appear user related… This is the folder of the otherwise working user, ls -last

4 drwxr-xr-x 2 www-data www-data 4096 Oct 19 17:00 .Contacts-Backup
4 drwxr-xr-x 2 www-data www-data 4096 Nov  7 01:42 Stuff
4 drwxrwxr-x 7 www-data www-data 4096 Nov 27 17:13 ..
4 drwxr-xr-x 2 www-data www-data 4096 Dec 13 16:46 Shares
4 drwxr-xr-x 2 www-data www-data 4096 Dec 22 20:58 Notes
4 drwxr-xr-x 2 www-data www-data 4096 Dec 22 21:01 Documents
4 drwxr-xr-x 3 www-data www-data 4096 Jan 10 15:11 Recovery
4 drwxrwxr-x 9 www-data www-data 4096 Jan 31 14:22 OtherUser
4 drwxr-xr-x 9 www-data www-data 4096 Jan 31 17:31 .

but the user cannot move or delete folders without getting a brief error in the browser and invalid path or a permission error in logging.

Database permissions for these folders are 31, permissions for files is 27. Both are in-line with other files that don’t cause the same issues.

I resolved this by copying the data via the nextcloud client, moving it out of the nextcloud user folder and then deleting it via ssh and resyncing with occ. Then copying the folder back into the nextcloud client folder and waiting till it copied the data back to the server. This is not generating errors anymore.

1 Like