trusteddomainproject / OpenDKIM

Other
97 stars 52 forks source link

opendkim.service: harden systemd service #154

Open Tachi107 opened 2 years ago

Tachi107 commented 2 years ago

The current opendkim.service file is not hardened, and systemd-analyze security opendkim.service reports an "UNSAFE" exposure level of 9.6.

With the help of that tool I've applied some more security hardenings to the unit file, and the exposure level dropped to an amazing 1.1!

Some of the most notable changes include:

Ported from https://salsa.debian.org/debian/opendkim/-/merge_requests/3

Related to #146

Tachi107 commented 2 years ago

@mdomsch how does this look to you?

mdomsch commented 2 years ago

I missed this while I was in process of moving this summer. The ExecPaths may need to also include /usr/sbin/sendmail and /bin/sh as OpenDKIM can popen() sendmail to send success/failure reports to the standardized reporting addresses. I've been working with the Fedora SELinux team to add a SELinux policy which allows opendkim to invoke sendmail. Any Systemd restrictive wrappers needs to allow this as well.

mdomsch commented 2 years ago

I should note, which mail submission tool to use is configurable in opendkim.conf. By default it's sendmail. The SELinux policy will allow sendmail, exim, postfix, and courier.