Skip to content

bug report: docker-data/dms/config/postfix-accounts.cf is world-readable聽#4436

Description

@gnoutchd

馃摑 Preliminary Checks

  • I tried searching for an existing issue and followed the debugging docs advice, but still need assistance.

馃憖 What Happened?

I recently installed DMS and created one account for myself using setup add email. (v15.0.1 at time of deployment, since upgraded to v15.0.2). I took a peek at my docker-data/dms/config/ and noticed that the password hash file (postfix-accounts.cf) was world-readable:

$ stat config/postfix-accounts.cf 
[...]
Access: (0644/-rw-r--r--)  Uid: (    0/    root)   Gid: (    0/    root)
[...]

Since this is the (hashed) password file, I would have expected it to have restrictive permissions. I have other (unprivileged but not containerized) services running on this machine that shouldn't be allowed to read password hashes.

I manually chmoded it 0640 and restarted DMS with docker compose up --force-recreate and it seems to work still, so I assume it doesn't actually need to be world-readable. If that's true, please consider tweaking the setup tool to create this file root-only (e.g. umask 0027) because that would be a safer default. Thanks!

馃憻 Reproduction Steps

  1. Install DMS as per https://docker-mailserver.github.io/docker-mailserver/latest/usage/
  2. docker exec -it mailserver setup add email user@example.com
  3. stat ./docker-data/dms/config/postfix-accounts.cf

馃悑 DMS Version

v15.0.1

馃捇 Operating System and Architecture

Debian 12 (bookworm) arm64

鈿欙笍 Container configuration files

馃摐 Relevant log output


Activity

  1. added this to the v15.1.0 milestone on Mar 31, 2025
  2. georglauterbach commented on Apr 1, 2025

    @georglauterbach
    Member

    @casperklein could you take a look please?

  3. casperklein commented on Apr 4, 2025

    @casperklein
    Member

    I can confirm what OP says. If we want to change that behaviour, we could add umask 027 to the setup script. That would effect any setup command. Or we could add the new umask just to addmailuser.

    BTW: Other files like postfix-virtual.cf are also world readable. Someone might consider available aliases also as confidential.

  4. georglauterbach commented on Apr 5, 2025

    @georglauterbach
    Member

    I'd probably start with adding umask to individual scripts 馃憤馃徏 And including the aliases is a good idea.

  5. polarathene commented on Apr 5, 2025

    @polarathene
    Member

    I'd probably start with adding umask to individual scripts

    How's that differ vs chmod? umask makes more sense when you're certain the default 022 isn't desirable. It could otherwise potentially break things? (/var/mail with LDAP comes to mind maybe?)

    I suppose it's rare that we need non-owner/group users to have access to files, so are we changing this more globally with chmod corrections after if needed?

    Might as well just set umask for the entire setup CLI then, and once in start-mailserver.sh and check-for-changes.sh? (might need to consider any relevant cron jobs/services too?) Or just chmod on a case-by-case basis as we have been 馃

  6. casperklein commented on Apr 6, 2025

    @casperklein
    Member

    If we add umask only to addmailuser, there should be no side-effects. The only file that is touched is /tmp/postfix-accounts?

  7. polarathene commented on Apr 6, 2025

    @polarathene
    Member

    The only file that is touched is /tmp/postfix-accounts?

    Yeah presently. If I ever get around to reviving the encrypted mailbox feature PR I have buried somewhere that'd come into play too I think.

    Only concern with umask is our usage of many bash scripts and how there isn't a proper import system for that, so if we add one for this, and then do it again somewhere else in future, we might be more prone to a caveat where we're troubleshooting something and eventually backtrack to discover it was because umask was adjusted (or having to think about that).

    I'm generally iffy about global state lingering like that, but I can see why you might prefer that approach since it can be slipped into the addmailuser script directly, whereas postfix-accounts.cf creation is abstracted away into the database management scripts I wrote (which covers postfix-virtual.cf for aliases and other configs with secrets like one for relay hosts).


    I've not checked if it'd work, but umask 027 could be set here I guess?

    function _main() {

    The reason I also suggested for start-mailserver.sh / check-for-changes.sh is you'll find those will call stuff like this:

    function _handle_postfix_virtual_config() {
    : >/etc/postfix/virtual
    local DATABASE_VIRTUAL=/tmp/docker-mailserver/postfix-virtual.cf

    Which while not the user config volume location, is the equivalent real config we map that content to, which should equally be locked down?

    But like I said, at a broader scope using umask instead of chmod on individual files will be less obvious on impact and may lead to some subtle bugs. I don't think our test suite presently has wide enough coverage to be confident in it passing as not introducing breaking changes 馃

  8. casperklein commented on Apr 7, 2025

    @casperklein
    Member

    I'm generally iffy about global state lingering like that

    Same here. To address the security concerns, one could remove the group rwx permission from the parent config folder (not tested if that breaks anything else). That way, all config files would be "protected".

  9. added
    stale-bot/ignoreIndicates that this issue / PR shall not be closed by our stale-checking CI
    on Apr 7, 2025
  10. modified the milestones: v16.0.0, on Aug 19, 2026
  11. removed this from the milestone on Aug 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions