⚠ SECURITY: Run the manual migration 0037_fix_bad_permissions

:uk: An important security issue was discovered in YunoHost. A fixed version was released in version 12.1.41 and 13.0.7.1.

We recommend to upgrade and run the migration 0037_fix_bad_permissions as soon as possible. This migration could take a while and will search for paths left writable by other users and fix these too large permissions.

yunohost tools update
yunohost tools upgrade system
yunohost tools migrations run 0037_fix_bad_permissions

You might have some good reasons to grant write permissions to others on some paths, if so you should reapply your customization manually. After the migration, you can check the list of change in the log of the migration.

IMPORTANT: On some servers, this migration may take several hours (or days) if there are a large number of files.

Alternatively, if you don’t want to run the migration on all your writable mounted filesystems, you can fix your paths by hand with the command bellow (think to replace <PATH> by the part of the tree files you want to fix):

/usr/bin/find <PATH> -mount \( -path /proc -o -path /sys -o -path /dev -o -path /run -o -path /var/spool/postfix -o  \( -regextype posix-extended -regex '.*/.snapshots(/.*)?' \) \) -prune -o \( -type f -or -type d -or -type s \) -perm -o+w ! -perm /o+t -exec chmod o-w {} \; -print

Questions & answers

Should i run the migration 0036 about DKIM before or could i run it later ?

Those migrations are not related and can be made in the order you want.

In webadmin, you can skip the DKIM migration, and run it later with:

yunohost tools migrations run 0036_dkim_keys_upgrade

I use samba and use ACL and unix permissions, does the migration could break something ?

We guess no. The migration only remove the write permissions for others users.

So for example if you have a file with permissions like this

-rw-rw-rw-  myfile.txt

Permissions will be changed with

chmod o-w  myfile.txt

And permissions should be like that

-rw-rw-r--  myfile.txt

If something going wrong, you still could fix it by running the reverse operation (by getting the list of change from your migration log):

chmod o+w  myfile.txt

Will resetting the permissions on each file cause everything to resync on Nextcloud clients?

In theory, we suppose nextcloud file in /home/yunohost.app/nextcloud should not be impacted, however, /home/USER could be impacted.

For now we don’t know if changing permissions in /home/USER could resync nextcloud.

My Discourse return a 502 error, what can i do ?

You can restart the discourse service or run:

chown discourse:www-data /var/www/discourse/discourse/tmp/sockets/unicorn.sock

And let’s thank @lelabtv for their great security report! I’m glad the Yunohost team managed to fix this issue in the end.

Can anyone tell me why it failed?

ended_at: 2026-09-04 04:20:54.636462
error: ‘Migration 0037_fix_bad_permissions did not complete, aborting. Error: The
find command fails for an unknow reasons (return code: 1)’
interface: api
operation: tools_migrations_migrate_forward
parent: null
started_at: 2026-09-04 04:20:49.600901
started_by: ******
success: false
yunohost_version: 12.1.41.2

============

2026-09-04 04:20:50,656: INFO - Running migration 0037_fix_bad_permissions…
2026-09-04 04:20:50,657: DEBUG - Removing others writable permissions for the following paths:
2026-09-04 04:20:50,661: DEBUG - [‘/usr/bin/find’, ‘/’, ‘-mount’, ‘(’, ‘-path’, ‘/tmp’, ‘-o’, ‘-path’, ‘/var/spool/postfix’, ‘-o’, ‘-path’, ‘/ynh-dev’, ‘-o’, ‘(’, ‘-regextype’, ‘posix-extended’, ‘-regex’, ‘./.snapshots(/.)?’, ‘)’, ‘)’, ‘-prune’, ‘-o’, ‘(’, ‘-type’, ‘f’, ‘-or’, ‘-type’, ‘d’, ‘-or’, ‘-type’, ‘s’, ‘)’, ‘-perm’, ‘-o+w’, ‘!’, ‘-perm’, ‘/o+t’, ‘-exec’, ‘chmod’, ‘o-w’, ‘{}’, ‘;’, ‘-print’]
2026-09-04 04:20:50,690: WARNING - /usr/bin/find: ‘/lost+found’: Permission denied
2026-09-04 04:20:54,631: WARNING - 1 paths might still be unprotected but are probably in read only mode (check the logs for debugging why the chmod command did not work for them).
2026-09-04 04:20:54,633: ERROR - Migration 0037_fix_bad_permissions did not complete, aborting. Error: The find command fails for an unknow reasons (return code: 1)
Traceback (most recent call last):
File “/usr/lib/python3/dist-packages/yunohost/tools.py”, line 932, in tools_migrations_run
migration.run()
File “/usr/lib/python3/dist-packages/yunohost/migrations/0037_fix_bad_permissions.py”, line 111, in run
raise YunohostError(
yunohost.utils.error.YunohostError: The find command fails for an unknow reasons (return code: 1)

If I do the upgrade in the webadmin page. Do I have to run the command yunohost tools migrations run 0037_fix_bad_permissions nevertheless from ssh ?

I’ll answer this question myself: webadmin will nicely guide you through the migration process immediately after the update. Nicely done, bravo!

That directory is not always present, so the error probably did not appear in the VM/Container used to test the migration.

You can look into /lost+found and see if there is something to recover. If it contains nothing of value you can delete the whole directory and should be safe.

Thanks, that worked.

I just did it, worked like a charm,
thank you for the work !

The update went very well, a little long to do regarding the waiting time when updating the DKIM keys in the DNS areas (at my house).
In the end, a success over everything.
Bravo and Thank you for the work!

root@arnauld:/home/arnauld# yunohost tools migrations run 0037_fix_bad_permissions
ERROR There is no migration called ‘0037_fix_bad_permissions’

??

Did you upgrade first?

yunohost tools update && yunohost tools upgrade system

If you accept to run the migration, please re-run the command with the option '--accept-disclaimer'.

root@arnauld:/home/arnauld# yunohost tools migrations run 0037_fix_bad_permissions --accept-disclaimer
INFO Running migration 0037_fix_bad_permissions…
INFO Running migration 0037_fix_bad_permissions…
INFO 20396 vulnerable paths have been found and protected. If you had customized some paths to make them writable by others users, feel free to check logs for a list of changes.
SUCCESS Migration 0037_fix_bad_permissions completed

Thank you.

The diagnosis seems to cache DNS responses independent from the actual TTL it defines, and thus possibly longer.

Uh, some providers also seem to cache longer than the TTL… (still dkim=fail).

I’m weary of the note:

if you don’t want to run the migration on all your writable mounted filesystems

I have a media server and Immich running, with my NAS mounted to my Yunohost server for storage. Is this migration going to try to fix permissions on every single individual file in my ~40TB of data on the NAS? If so, can someone please explain in more detail how to run the migration manually? What path do I need to add for the<PATH>command?

Also, what exactly does this negatively affect if it is not done?

Same here. Since I’m running on Trixie unstable, I’m at version 13.0.3, so the migration didn’t appear at all. I had to run the command listed above, with some changes as there are some slashes not properly escaped:

/usr/bin/find <PATH> -mount \( -path /proc -o -path /sys -o -path /dev -o -path /run -o -path /var/spool/postfix -o  \( -regextype posix-extended -regex .*/.snapshots\(/.*\)? \) \) -prune -o \( -type f -or -type d -or -type s \) -perm -o+w ! -perm /o+t -exec chmod o-w {} \; -print

Basically all parts of your system that’s not mounted from your NAS. Maybe you can temporarily stop your media server’s and Immich’s services, unmount your NAS directories, and run the migration, then mount it again.

Any system user could read some sensitive logs and configuration files.

Good thing we released 13.0.7.1 last night. :slight_smile: I’ve edited the first post to mention that trixie is covered as well.

Thank you for this! I will try the stop and unmount method and see what happens.

Almost same problem here :

https://paste.yunohost.org/raw/avuriwexel

But when I try to see what’s inside the lost+found folder, I get an error :

root@yunohost:/# cd lost+found/
-bash: cd: lost+found/: Permission denied

Did I miss somthing ?

Thanks !