Anti-spam and anti-virus settings stored by the server

Some settings can be changed while the server runs, without a restart and without editing the configuration file. They are kept in the cluster’s own storage, replicated to every node and applied on each node as soon as it hears of the change (a node also re-reads them once a minute, which covers a node that was restored from a snapshot). The admin pages that edit them are described under Using the admin pages; the rules they follow are below.

Precedence

For every key the first of these wins:

  1. the value the configuration file sets explicitly;
  2. the value stored in the cluster, if it passes validation;
  3. the built-in default.

A key the file sets is read-only in the web admin (“set in the configuration file”) and any stored value for it is ignored. To hand a key to the web admin, remove it from the file and restart. A SIGHUP that changes a key in the file behaves as described in config-reload.md: the three hot keys (antispam.builtin.threshold, antispam.builtin.high_threshold and antivirus.clamav.on_failure) apply at once, and a later change to the stored settings does not undo them.

A repeated block counts as one key: if the file names any zone, the file owns the whole zone list.

Areas and keys

Area Keys
Built-in scorer enabled, threshold, high_threshold
rspamd enabled, url, timeout, password
SpamAssassin enabled, host, port, timeout, threshold
ClamAV enabled, socket, on_failure
DNSBL enabled, timeout, cache_ttl, zones with weights
Greylisting enabled, delay, retry_window, pass_lifetime

Validation, on save and again by every node when it reads a value:

  • thresholds are above 0 and at most 1, and high_threshold is not below threshold;
  • the rspamd URL is http or https, has a host and carries no user name or password; timeouts are between 100 ms and 5 min (DNSBL: 30 s);
  • the SpamAssassin host contains no /, and the port is 1 to 65535;
  • the ClamAV socket is an absolute path; on_failure is quarantine or accept;
  • DNSBL zones are valid DNS names (two or more labels), at most 20, no duplicates, each weight above 0 and at most 1;
  • greylisting follows the limits in greylisting.md.

A stored value that fails validation on a node (a record written by a newer version, or damaged) is logged as settings: invalid stored value with the area and key, never the value, and that one field uses the file or default value instead. A bad value never switches a scanner off: an invalid ClamAV socket falls back to the configured socket while ClamAV stays on.

What each switch does

  • Built-in scorer, enabled. On by default whenever neither the file nor the web admin says otherwise. Off stops the heuristic content score counting. DMARC, DNSBL, Bayes and the handling of trusted mail still run.
  • rspamd and SpamAssassin. A scanner runs when its enabled is true and either the antispam stage’s backend in the file names it, or enabled was switched on in the web admin. A file that sets enabled = true for rspamd but names backend = "builtin" still runs the built-in scorer alone, as before. Both can be on; the first one that answers is used, and an unreachable scanner falls back to the built-in verdict.
  • ClamAV. Needs the antivirus pipeline stage. With the pipeline block’s stage list left at its defaults the stage is always present and lets mail through while scanning is off, so ClamAV can be switched on without a restart. If the file lists its own stages and leaves antivirus out or disabled, the web admin refuses to switch ClamAV on (stage_disabled_in_file): add the stage to the file and restart once. Mail that passes while scanning is off is marked as checked and is not scanned later unless it is rescanned from quarantine.
  • DNSBL. A change builds a new checker; its lookup cache starts empty.
  • Greylisting. The table exists on every server and development node with SMTP on; while it is off every message passes and nothing is recorded.

Credentials

The rspamd password is write-only. The admin page shows only whether one is set. Submitting an empty value keeps the stored password; clearing it is a separate, explicit action. It is sent to rspamd as the Password header, and it is never written to a log, not even at debug level, and never shown again.

The stored password is plaintext in the cluster’s storage, so it is replicated to every node and included in backups, like the DKIM private keys. Protect backups accordingly. If you would rather keep it out of storage, set antispam.rspamd.password in the configuration file, which then takes precedence (and is a restart-class key).

SpamAssassin’s spamd has no password mechanism, so there is no credential to store for it.

Changing the rspamd URL never sends the password in effect to the new address unasked. While a password is set, a save that changes the effective URL (including clearing a stored URL back to the file or default value) is refused with credential_required on the password field unless the same save enters the password again or clears it. When the configuration file sets the password, the web admin cannot change the URL at all (credential_in_file): only the operator who set the credential may point it elsewhere. The rspamd client does not follow redirects, so a scanner that answers with a redirect is treated as unavailable and the password never goes to the host the redirect names.

Trust

The rspamd URL, the SpamAssassin host and port and the ClamAV socket carry the same trust whether they come from the configuration file or from the web admin: the server connects to them and hands them every message it scans, and the rspamd password goes with each request. The admin pages that write them are open to global administrators only; domain administrators cannot reach them.

These addresses are deliberately not limited to public networks (unlike calendar subscriptions and remote-account fetching, which go through the server’s public-address dialer): scanners normally run on the same host or a private network. A global administrator can therefore point a scanner at any address the node can reach, as an operator editing the file can.

A DNSBL zone list that is stored but empty, with DNSBL enabled, is a real value: DNSBL is on and looks nothing up. Clear the stored list to fall back to the file or default zones.

Audit log

Each saved change logs one line with the component prefix settings: and the admin’s user ID, the area, the key and the old and new values. A credential is logged as changed or cleared only. Select the component with telemetry.log.components.

Several nodes

Settings are one record per area, written as a single replicated update. Two admins saving the same area on different nodes at the same moment are last writer wins; the later save replaces the whole area. A save on one node is applied there at once and on the others when they apply the replicated update, normally within a moment.

Upgrade every node before anyone edits settings in the web admin. A node on an older version ignores the stored settings and uses the file values, so mail it handles would be judged differently from mail on the other nodes. The cluster does not diverge (the update is an ordinary write), but behaviour differs per node until all are upgraded. See the mixed-version notes in the v0.17 administration PRD, section 6.3.

Nodes with the edge or agent role keep no replicated storage and always use the file values; the server logs this once at start. That includes antispam.builtin.enabled: an agent node’s antispam processor follows the file’s value, and a file without the key leaves the heuristic on.

Using the admin pages

Global administrators find the pages under Admin, Anti-spam settings (/admin/settings). There is one page per area: the built-in scorer, rspamd, SpamAssassin, ClamAV, DNSBL and greylisting. A domain administrator gets the same refusal as on the service overview.

  • Each field shows its effective value. A key the configuration file sets is shown disabled with “set in the configuration file”; a crafted request that names it is refused by the store as well.
  • Only the fields you change are stored, so an untouched default is never pinned. A field with a stored value has a “Use the default” box that removes the stored value.
  • The rspamd password is write-only. The page says whether one is set and never shows it. Leave the field empty to keep the stored password, or tick “Remove the stored password”. Changing the rspamd address while a password is set needs the password entered again, or removed, in the same save.
  • A refused save answers 422 and shows the form again with what you typed and a message beside the field; the password is not carried back. A failure to store the change answers 500 with a generic message and is logged as admin settings: save failed.
  • A saved change applies on the node you used at once and on the others as they hear of it. The page confirms that it was saved, not that every node has applied it. Upgrade every node before anyone edits settings.

View this page's source on GitHub