desktop icon indicating copy to clipboard operation
desktop copied to clipboard

[Bug]: Permission denied syncing "read only" shared folders

Open masakkre opened this issue 9 months ago • 11 comments

⚠️ Before submitting, please verify the following: ⚠️

Bug description

Good morning,

I will try to organize the topic with the information:

Although at first I thought the permission denied sync error was caused by file names containing Ñ or accented characters, I have discovered that it has nothing to do with that. It happens regardless of whether the file or folder names are normal.

I believe the problem lies in how the sync client handles shared folders that have read-only permissions. For example:

2.1. User A shares a folder and its contents with User B or a group of users, assigning read-only permissions to that folder and disabling the options to create, modify, or delete. It does not matter whether this is done from the Nextcloud web interface or from their synced folder.

2.2. The clients of User B or the user group create the shared folder, but afterward they are unable to sync its contents, showing a permission denied error.

2.3. I have also discovered that if this folder was syncing correctly in previous versions that did not have this problem, and I update to the latest version (4.0.6), if a conflict appears in any file, trying to resolve it by asking the application to keep the server version does not work, and it behaves as if it cannot take any action.

  1. I can solve all these problems if I change the permissions of the shared folder using chmod -R 755 /path/folder.

  2. I have also discovered that the same thing happens on Windows clients, not only on Linux/Debian clients.

I know that at first I blamed the problem on file names, since the first issues I encountered involved names containing Ñ or accents. However, over time I noticed that the problems increased and were unrelated to file names. Finally, it seems that the issue is caused by the permissions of the local folder when it is created by the application if that folder is a shared folder with read-only permissions, as I explained above. On the web interface, I do not have any problems with these folders; it only happens during synchronization.

I hope I have explained myself more clearly. If you need more information, please do not hesitate to ask, and I will try to provide everything I can.

Thank you very much for your patience.

Steps to reproduce

  1. User A share a folder in nextcloud with read-only permissions. (no modification, creation or delete permissions)
  2. User B syncs this folder with the app. The app creates this folder, but can not create the files, giving permission denied error
  3. in linux, using chmod -R 755 /path/read-only-shared-folder fixes this error
  4. In windows, syncing in normal mode (no virtual folders), i am having same error, but i can not fix it.
  5. I have probe with fresh install and updated installs. In previous versions of sync app, i have not this problem (version 3.X) ...

Expected behavior

When clicking on the share dialog, share by e-mail should be an option. ...

Which files are affected by this bug

syncing shared folder with read only permissions

Operating system

Linux

Which version of the operating system you are running.

ubuntu 22.04, windows 11

Package

Official PPA

Nextcloud Server version

31.0.8

Nextcloud Desktop Client version

4.0.6

Is this bug present after an update or on a fresh install?

Fresh desktop client install

Are you using the Nextcloud Server Encryption module?

Encryption is Disabled

Are you using an external user-backend?

  • [ ] Default internal user-backend
  • [ ] LDAP/ Active Directory
  • [ ] SSO - SAML
  • [ ] Other

Nextcloud Server logs


Additional info

No response

masakkre avatar Feb 23 '26 12:02 masakkre

+1

I seem to have the same issue. But I am on macOS.

After updating the local permissions with chmod -R 755 /path/read-only-shared-folder. I got the message "Not allowed to upload this file because it is read-only on the server, restoring" by the client. Although the web interface shows, that I have all permissions for the file.

Desktop Client: 4.0.6 Server version: 32.0.6

kuihlein avatar Feb 27 '26 14:02 kuihlein

Same here, but on Windows.

When sharing a file/folder as "read-only" the Nextcloud Desktop Client Version 4.0.8 on Windows 11 will report "Windows Error: 5: Access is denied" and fails to sync.

It looks like this can be fixed by granting full access permissions to the sync folder and its content...

embeh avatar Mar 20 '26 14:03 embeh

+1 for me with Desktop-Client-Version 33.0.2

The client throws "Windows Error: 5: Access is denied". The client downloads the file as a hidden temp file, then when renaming it to actual file name, it gets the error. But the temp file stays. Prob. broken permission handling on the client side, as it is not allowed to "edit" files?!

As a workaround: Changing the permission of the shared folder from "read only" to "can edit" lets me sync the folder (again).

Cheers hamu

hamuchen avatar Apr 06 '26 20:04 hamuchen

as I cannot reproduce this from latest master (which as far as the sync engine goes is still close enough to 33.0.2) on Windows I would appreciate to receive some debug archives created after reproducing this issue for further investigation. You may provide it at https://cloud.nextcloud.com/s/66Jnk8WRX68tMta

nilsding avatar Apr 07 '26 10:04 nilsding

I seem to have same problem as stated. We tried to update the server to 32.0.6 on the server with the clients running Nextcloud Desktop Client Version 33.0.2 , the latest stable as of now. But to no avail, it does not work.

fearcube69 avatar Apr 10 '26 06:04 fearcube69

as I cannot reproduce this from latest master (which as far as the sync engine goes is still close enough to 33.0.2) on Windows I would appreciate to receive some debug archives created after reproducing this issue for further investigation. You may provide it at https://cloud.nextcloud.com/s/66Jnk8WRX68tMta

Good morning, I'm very sorry for the delay in responding. I've tried looking in the client logs for where the failure occurs when creating read-only shared resources, and this is what I found:

2026-06-09 10:56:36:022 [ info nextcloud.sync.statustracker ./src/libsync/syncfilestatustracker.cpp:233 ]: Investigating "IDAZKARITZA JURIDIKOA/FORO ARANZADI/2025_2026_kurtsoa/GIPUZKOA/Ekaina/Criterios Interpretativos 2026/Criterio de Gestión 8 2026.pdf" OCC::SyncFileItem::NoStatus CSyncEnums::CSYNC_INSTRUCTION_NEW OCC::SyncFileItem::Down CSyncEnums::ItemTypeFile

I'm not sure if this is what you need; if not, please let me know and I'll keep trying.

Thank you very much.

P.S. I found some more information from the logs:

2026-06-09 11:48:38:024 [ info nextcloud.sync.discovery ./src/libsync/discovery.cpp:1892 ]: Processing "IDAZKARITZA JURIDIKOA/FORO ARANZADI/2025_2026_kurtsoa/GIPUZKOA/Apirila/María Belén Cardona.pdf" | (db/local/remote) | valid: false/false/true | mtime: 0/0/1776239523 | size: 0/0/810100 | etag: ""//"0455bf8308fc9b350b5ddfedb4001272" | checksum: ""//"" | perm: ""//"GS" | fileid: ""//"15522471oct0zlinw8yu" | inode: 0/0/ | type: CSyncEnums::ItemTypeSkip/CSyncEnums::ItemTypeSkip/CSyncEnums::ItemTypeFile | e2ee: false/false | e2eeMangledName: ""/"" | file lock: not locked //not locked | file lock type: ""//"0" | live photo: false//false | metadata missing: /false/ 2026-06-09 11:48:38:024 [ info nextcloud.sync.discovery ./src/libsync/discovery.cpp:1893 ]: discovered "IDAZKARITZA JURIDIKOA/FORO ARANZADI/2025_2026_kurtsoa/GIPUZKOA/Apirila/María Belén Cardona.pdf" CSyncEnums::CSYNC_INSTRUCTION_NEW OCC::SyncFileItem::Down CSyncEnums::ItemTypeFile

I've also attached a screenshot of the program error. As you can see, the logs correspond to the first of the error files. After doing chmod -R 755 to the parent folder, the Synchronization is performed without problems

Image

masakkre avatar Jun 09 '26 09:06 masakkre

i have same issue just on a Ubuntu 24.04.4 service with Nextcloud V34.0.1 and i have just upgrade to 34.0.2 still same problem and also see that i can't update app in web(dashboard) part of Nextcloud

also get this in log RedisExceptionPermission denied

nemprinter avatar Jul 23 '26 20:07 nemprinter

Same issue - Adding my setup and environment:

  • NextCloud Desktop Client: 33.0.7
  • OS: Windows 11
  • Scenario: Syncing a read-only shared folder (shared by another NextCloud user with read-only permissions, no create/modify/delete rights)

What works:

  • Folders with read AND write permissions sync flawlessly.

What fails:

  • Read-only shared folders trigger WindowsError 5: Access Denied as soon as the client attempts to download/write files locally, despite having proper NTFS Full Control permissions on the parent directory.

Observations:

  • Issue persists even after resetting NTFS permissions (icacls /reset /T) and explicitly granting Full Control to local users.
  • Controlled Folder Access (Windows Defender) is disabled.
  • Same issue occurs regardless of file names or types.
  • Web interface works perfectly – this is purely a Desktop Client bug.

Conclusion: This confirms the bug is still present in client version 33.0.7. The client appears to apply server-side read-only permissions as local NTFS ACLs, blocking itself from writing downloaded files.

Regards
Coffee

CoffeeHT avatar Jul 30 '26 18:07 CoffeeHT

Good morning, I've tried the latest version, 34.0.0, and I can say that the problem persists in Windows, just as it did in Mint Mate version 22.3, or at least it seems that way, since the "MORE ACTIVITY" window doesn't open and I can't see the results in Mint.

Regards

masakkre avatar Jul 31 '26 07:07 masakkre

Still present in 4.x — with a permanent, silent failure mode on Windows

Adding a data point from a long-running Windows installation, since this issue is still open. In our case the read-only-share permission handling did not just fail once — it produced a permanent retry loop that went unnoticed for almost four years, because the client kept reporting "Everything synced!" the whole time.

Environment

Client 34.0.1 (build 20260804)
Server 32.0.12.1
OS Windows 11 Home 26200, German locale
Sync root C:\Sync\nextcloud, 18,209 objects
VFS off (virtualFilesMode=off)
Account standard user, not elevated, owner of all files

Symptom

Files inside read-only shares download completely (HTTP 200, byte size matches the server exactly) but the final rename never happens. The log shows, per file, on every single sync run:

||CourseMaterials3/example.docx|8|2|1748619651|edbcd27...|32553|03548468oc...|3|WindowsError: 5: Zugriff verweigert|200|0|0||
                               ^ NEW  ^ down                                    ^ SoftError    ^ ERROR_ACCESS_DENIED

Scale of the accumulation before we noticed:

  • 80 distinct files permanently stuck
  • 7,482 error events across 239 sync runs
  • oldest stuck temp file dated 2022-09-14
  • 2.66 GB of fully-downloaded data sitting in unusable .<name>.~<hex> temp files

Root cause as observed on disk

Every stuck temp file carries an explicit DENY ACE. 68 of 69 had it:

> icacls ".CourseMaterials3\.example.docx.~2ce7"

BUILTIN\Users:(DENY)(DE,WD,AD,WEA,DC)
BUILTIN\Administrators:(F)
NT AUTHORITY\SYSTEM:(F)
NT AUTHORITY\Authenticated Users:(M)
BUILTIN\Users:(RX)

Denied: DELETE, FILE_WRITE_DATA, FILE_APPEND_DATA, FILE_WRITE_EA, FILE_DELETE_CHILD.

On Windows a DENY ACE always wins over any ALLOW, so the Authenticated Users:(M) entry below it has no effect. The client cannot rename or delete its own temp file, and because the transfer id is persisted in the journal database it reuses the same temp file on the next run — so the failure is self-perpetuating and can never resolve on its own.

Notably, no regular file anywhere in the 18,209-object tree carried a DENY ACE or the ReadOnly attribute — only the client's own temp files.

Re-downloading does not help (verified)

We first cleared all 69 temp files and let the client fetch everything fresh. Within minutes it had produced 67 new blocked temp files, downloads complete (HTTP 200), same WindowsError: 5. So this is not a rare race — it reproduces on essentially every fresh download into a read-only share.

The DENY is also applied at directory level

Worth flagging separately, because it broke our first repair attempt: some parent directories carry the same DENY ACE plus the ReadOnly attribute:

SharedProject\Material\CourseMaterials1   ReadOnly, Directory
   BUILTIN\Users : Deny  CreateFiles, AppendData, WriteExtendedAttributes,
                         DeleteSubdirectoriesAndFiles, Delete

A rename needs FILE_ADD_FILE on the parent to create the new name and FILE_DELETE_CHILD (or DELETE on the file) to remove the old one. With the directory denied, unlocking the file alone is not enough — 30 of our 67 files still failed until the parent directory was unlocked too.

The more damaging bug: the status is wrong

These are classified as SoftError (status 3), which does not affect the headline status. The result:

  • Three shared folders contained 0 files locally while the server had 30
  • The tray/activity window read "Everything synced!" throughout
  • Nobody had any reason to check, for years

A permanent, self-inflicted, non-recoverable condition should not be a soft error. Even without fixing the ACL behaviour, surfacing "N files have failed on every run since " would have turned four years of silent data absence into a five-minute fix.

Workaround that works (no admin rights needed)

The downloaded data is intact — only the final rename is missing. So rather than re-downloading, finish the step the client could not:

# 1. unlock the parent directory
icacls "<dir>" /remove:d "BUILTIN\Users"

# 2. unlock the temp file
icacls "<dir>\.<name>.~<hex>" /remove:d "BUILTIN\Users"

# 3. clear ReadOnly / Hidden, then rename to the final name

Works as the file owner without elevation. Set-Acl does not work — it fails with a missing SeSecurityPrivilege because it also tries to write the SACL; icacls /remove:d avoids that.

One caveat for anyone scripting this: skip temp files that were written in the last ~90 seconds. Renaming one mid-download leaves a truncated file under the final name and the client then creates a conflict copy of it.

Recovered 69/69 files this way, verified byte-exact against the server sizes.

Where this appears to originate

FileSystem::setAclPermission() in src/common/filesystembase.cpp — reached from setFileReadOnly() on Windows — adds a DENY ACE via AddAccessDeniedAceEx() for SID S-1-5-32-545 (BUILTIN\Users), denying:

FILE_DELETE_CHILD | DELETE | FILE_WRITE_DATA | FILE_WRITE_EA | FILE_APPEND_DATA

That mask matches the ACL observed on disk exactly — (DE,WD,AD,WEA,DC) in icacls notation — and S-1-5-32-545 is a group the syncing user's own account belongs to. So the client denies itself DELETE on the very object it is about to rename.

Finalising a download needs DELETE on the temp file (or FILE_DELETE_CHILD on the parent) plus FILE_ADD_FILE on the parent to create the final name. The ACE removes all three.

Possible directions, for maintainers to judge:

  • apply the ACL only after the temp file has been renamed into place
  • skip setAclPermission() for transfer temp files (.<name>.~<hex>) entirely
  • lift the ACE for the duration of propagation and re-apply it afterwards
  • use the plain ReadOnly attribute instead — it prevents accidental edits without blocking rename/delete, which is what the DENY ACE is really costing here

Offer to help

We have an environment that reproduces this reliably — read-only shares on a production server, Windows 11, fails on essentially every fresh download — and are glad to contribute rather than just report:

  • test any candidate fix and report back with logs and ACL dumps, or
  • prepare a pull request ourselves, if a maintainer indicates which of the directions above is preferred

Happy to take whichever is more useful. Just say which.

suebi76 avatar Aug 19 '26 10:08 suebi76

Same bug on Windows, in production. The root cause is the one described in #9885, and PR #10213 fixes it — linking them here, since the Windows reports in this issue look like the same thing.

Environment

  • Server: Nextcloud 34.0.5 (All-in-One, Docker), files on external storage (files_external, S3 backend).
  • About 80 Windows users who need read-only access to some folders. Read-only access comes from two places:
    • an external storage mount with the option readonly = true, applicable to two groups;
    • user shares with permissions = 1, created via the OCS API.
  • Clients: Windows desktop 35.0.0 and 35.0.1, Russian locale.

What the client shows (user A, 35.0.0, classic sync) <folder>/grupp 30k 1t.psd: WindowsError: 5: Отказано в доступе. ("Access is denied") for every file in one read-only subfolder.

What the server sees — admin_audit log, anonymized: desktop-client GETs of files in the read-only mount, 2026-10-29, times in UTC.

user A, desktop 35.0.0, classic sync
  grupp 10k 1t.psd   17:32:15  17:32:34  17:33:31  17:33:51  17:34:24  17:34:41
  grupp 14k 1t.psd   17:32:15  17:32:34  17:33:31  17:33:51  17:34:24  17:34:41
  grupp 30k 1t.psd   17:32:16  17:32:34  17:33:31  17:33:51  17:34:24  17:34:41
  grupp 7k 1t.psd    17:32:23  17:32:43  17:33:37  17:33:59  17:34:48
  grupp 9k 1t.psd    17:32:23  17:32:47  17:33:39  17:33:59  17:34:48
  grupp 9k.psd       17:32:24  17:32:48  17:33:41  17:34:09  17:34:50

user B, desktop 35.0.1
  one .psd file      14:23:07  14:23:11  14:23:15  14:23:19  14:23:31

That is 33 GET requests for six 45–70 MB files in 2.5 minutes, where 6 were needed. The server serves every request without errors (nothing in nextcloud.log); the client requests the same files again roughly every 20–60 seconds. User A then downloaded the same six files through the web UI: one GET each.

Still present in 35.0.1: at tag v35.0.1, src/libsync/propagatedownload.cpp calls setFileReadOnlyWeak() on _tmpFile (line 1251) before uncheckedRenameReplace() (line 1302). On Windows this adds the BUILTIN\Users deny ACE with DELETE (filesystembase.cpp, AddAccessDeniedAceEx), so the rename fails.

Impact: all our Windows users download read-only folders through the web UI for now. Giving them write access is not an option: they must not delete or overwrite these files.

We don't install unofficial builds on work PCs, but we will test the first official build that contains #10213 and report back here.

yb99h5ydz9-web avatar Nov 04 '26 08:11 yb99h5ydz9-web