Permissions on /etc/stalwart/config.json

Issue Description

After installing stalwart on a clean Debian 13 through the Linux install-script (Linux / MacOS | Stalwart) I noticed that the config file /etc/stalwart/config.json has permissions 644 (fortunately the directory has 750.

Expected Behavior

Since /etc/stalwart/config.json contains the password to my database I would think 640 or 600 would be a better choice.

Actual Behavior

ls -ld /etc/stalwart/

drwxr-x— 2 stalwart stalwart 4096 Oct 24 19:10 /etc/stalwart/

ls -l /etc/stalwart/

total 8
-rw-r–r-- 1 stalwart stalwart 296 Oct 24 19:10 config.json
-rw-r----- 1 root stalwart 1145 Oct 24 18:40 stalwart.env

Reproduction Steps

Run the installer (at least on an up-to-date Debian 13) from Linux / MacOS | Stalwart, followed by the web configuration.

Stalwart Version

v0.16.x

Installation Method

Binary (Linux)

Database Backend

MySQL

Blob Storage

Filesystem

Search Engine

MySQL

Directory Backend

Internal

I have reviewed the documentation and FAQ and confirm that my issue is NOT addressed there.

on

I have searched this support forum (open and closed topics) and confirm this is not a duplicate.

on

I understand that topics in this category are triaged by a bot first but a human reply will follow up. If I’d prefer a human-only reply, I’ll add the no-ai tag to my topic.

on

Confirmed: this matches the installer’s actual behavior. The install script (install.sh) explicitly locks down stalwart.env to 0640 (chown root:stalwart, chmod 0640) but does not set permissions on config.json, that file is instead created later by the Stalwart binary itself during bootstrap/setup and ends up with the default 644 mode. So your observation is accurate: the directory is 750 (owned by stalwart:stalwart), which does restrict access to the stalwart user and root, but within that directory config.json is world-readable within the group/other bits that the directory doesn’t already block, i.e. effectively readable by anyone able to read as stalwart user context, which weakens things compared to the env file.

As a workaround until this is addressed, you can safely tighten it yourself:

chmod 640 /etc/stalwart/config.json

Since /etc/stalwart is 750 and owned by stalwart:stalwart, reducing config.json to 640 (readable only by stalwart and root) will not break startup, as the service runs as that user.

This looks like a legitimate hardening gap in the install script rather than documented/intended behavior, so flagging for a maintainer to confirm and potentially patch the installer.

This is an automated reply from the Stalwart Help Bot. Other community members may follow up if this answer is incomplete or wrong.

Good catch. The server wrote config.json with a plain file write, so it picked up whatever umask the process had, which is 0644 under systemd. That’s not what you want for a file holding your MySQL password, and Docker or manual installs don’t have the 0750 directory you have in front of it.

I’ve changed it so the file is created with 0600, and when it already exists the server tightens it to 0600 the next time it writes it. The fix ships in the next weekly Stalwart release. Until you upgrade, chmod 600 /etc/stalwart/config.json is safe to run; the server only needs to read it as the stalwart user.