docker-mailserver: bug report: Rspamd dkim_signing module should have try_fallback = false ?
📝 Preliminary Checks
- I tried searching for an existing issue and followed the debugging docs advice, but still need assistance.
👀 What Happened?
I’m not an rspamd expert by any means, but was noticing that rspamd seemed to be trying to sign (DKIM) every message – not just outbound email from local domains. For example if an inbound email from Gmail came, I’d something like this would be logged:
| 7/19/2023, 11:35:42 AM | rspamd_proxy | 1295 | proxy | b2bf53 | cannot load dkim key /var/lib/rspamd/dkim/gmail.com.dkim.key: cannot stat key file: ‘/var/lib/rspamd/dkim/gmail.com.dkim.key’ No such file or directory |
|---|
After some Googling, I came across this issue which basically says that’s the expected result if try_fallback = true which seems to be the default currently:
https://github.com/rspamd/rspamd/issues/2832
Perhaps that should be set to false ? I did so in my override.d/dikim_signing.conf and the issue seems to have dissapeared without any repercussions that I can tell.
👟 Reproduction Steps
- Enable rspamd
- Send inbound email from external domains
- Check history/error log for spamd
🐋 DMS Version
v12.1.0
💻 Operating System and Architecture
Debian 11
⚙️ Container configuration files
N/A but can provided if needed
📜 Relevant log output
7/19/2023, 11:35:42 AM rspamd_proxy 1295 proxy b2bf53 cannot load dkim key /var/lib/rspamd/dkim/gmail.com.dkim.key: cannot stat key file: '/var/lib/rspamd/dkim/gmail.com.dkim.key' No such file or directory
7/19/2023, 11:26:55 AM rspamd_proxy 1294 proxy d6988d cannot load dkim key /var/lib/rspamd/dkim/linkedin.com.dkim.key: cannot stat key file: '/var/lib/rspamd/dkim/linkedin.com.dkim.key' No such file or directory
... ETC ...
About this issue
- Original URL
- State: closed
- Created a year ago
- Comments: 15 (10 by maintainers)
Commits related to this issue
- see https://github.com/docker-mailserver/docker-mailserver/issues/3433#issuecomment-1646532264 — committed to docker-mailserver/docker-mailserver by georglauterbach a year ago
- see https://github.com/docker-mailserver/docker-mailserver/issues/3433#issuecomment-1646532264 — committed to docker-mailserver/docker-mailserver by georglauterbach a year ago
- see https://github.com/docker-mailserver/docker-mailserver/issues/3433#issuecomment-1646532264 — committed to docker-mailserver/docker-mailserver by georglauterbach a year ago
- see https://github.com/docker-mailserver/docker-mailserver/issues/3433#issuecomment-1646532264 (#3439) — committed to docker-mailserver/docker-mailserver by georglauterbach a year ago
After reading through all of this, and looking at the docs etc. I agree that
try_fallback = false;should be the default. I will provide a PR.Moreover, we can discuss using
sign_local = false;instead of our current default. Rspamd does not know about Postfix’s configuration at all, somynetworksfrom Postfix is not involved here - after all, you can use Rspamd without Postfix perfectly fine. It is Rspamd’slocal_networks(also see this part of the Rspamd docs). We do not set a default because we cannot confidently guess which networks our users are using. The only setting would be127.0.0.1/8; we should add this to our default configuration. So, arguably,sign_localshould indeed becomefalsebecause we cannot confidently set the defaults that this setting is relying upon. I will provide a PR.You’re probably going to have to wait on @georglauterbach when he has time to spare, as he’s helming the rspamd feature integration.
In the meantime, this can probably be reproduced offline with two DMS instances and a local DNS (eg: CoreDNS container) + certs (eg: Smallstep container/CLI) if it’s helpful to simulate a third-party like gmail.
The issue you linked seems to be convincing with the last comment though: https://github.com/rspamd/rspamd/issues/2832#issuecomment-479581185
As does this section of the Rspamd DKIM docs. So defaulting to
try_fallback=falsesounds good 👍 I’ll leave that decision to @georglauterbachWell, I think the fix you mention would be for people who are/were using OpenDKIM to create their local keys and just want rspamd to know where those keys are located for signing outbound mail from local domains – which would be a different issue.
What I’m saying is that rspamd currently seems to be trying to sign all mail – not just outbound mail from local domains you have keys for.
For example, if an email comes in to your server from someone@gmail.com, rspamd will currently try to sign it using a key for gmail.com, which obviously you won’t have 😃 , and will log that it can’t find the key.
Give this a shot on your Docker host some time and see what comes up:
docker exec mailserver cat /var/log/supervisor/rspamd.log |grep 'cannot load dkim key'I’m thinking you will see results from that and they will likely be from inbound email from remote domains which it shouldn’t be trying to sign – because
try_fallback=truecurrently.I think we may be talking about two different things. 😃
I’m coming into DMS fresh, so I never setup keys via OpenDKIM. Rather I just created them via
setup config dkim domain xxxxxx.comfor each domain and then added entried for them to myrspamd/override.d/dkim_signing.confI’ve verified things are signed for my domains when outbound mail is sent.What I was seeing is that inbound mail (from say gmail.com, linkedin.com, etc) that gets run through rspamd for filtering was also trying to be signed by rspamd (in addition to being verified). That’s where the log entries about not being able to find keys for gmail.com, linkedin.com, etc were coming from. Apparently that’s because the current conf has
try_fallback = trueset for the dkim signing module. Setting that to false did stop all of that inbound signing log activity, and my local outbound email are still signed before heading out.So I’m thinking that’s just not the default that’s wanted ? i’m still very new to DMS and rspamd though, so I could be confused. 😃
One other thing I’ve run into (which I can definitely start a new issue for if needed) which is also DKIM related, is RSPAMD’s
allow_username_mismatchoption for DKIM. Basically without that set to true, an authenticated user (user@somedomain.com) won’t have email DKIM signed when sending as another valid domain alias they may have (user@anotherdomain.com). I suppose some may want that strict though? Maybe just something worth including in the config with comment? Just thinking out loud. 😃@williamdes I think you hit on the right clue ! 😃
Basically I have DMS setup on the side to test before swapping out my current mail server. So I have my current mail server configured to also relay all incoming email to DMS for testing. However, apparently because that mail host is on the local network (mynetworks?), rspamd is trying to add DKIM signing on the mail even though it’s “from” remote domains. As a quick test I changed port forwarding to DMS directly and send a couple from Gmail which didn’t trigger the dkim key not found warning.
I hope that’s not too confusing! But basically once I move DMS into production I shouldn’t see those signing issues as remote mail will all be from remote host connections.
However that does seem to mean
try_fallback=truewill try to DKIM sign any email accepted from “local” network hosts, regardless if the from address is a local domain or not.So I’m still not sure if that’s what is wanted in the end? Obviously if there is a local relay feeding external email it will hit the situation I was seeing. And really a fall back doesn’t seem necessary if all the local domains have their DKIM key info in
dkim_signing.confexplicitly. I’m not sure. That’s probably for your rspam guru to contemplate.Sorry for the confusion though, the situation is different than I originally thought.
EDIT: FWIW
sign_local = true;seems to be involved here also, basically telling rspamd to DKIM sign all email accepted by local connections.sign_authenticated=true;is also set which I think(?) is what most people would want/expect – basically sign everything originating from local authenticated users.