Featured image of post emfor 0.7.0: Tighter Defaults, a Small Environment for Check Programs, and Fixes from a Security Review

emfor 0.7.0: Tighter Defaults, a Small Environment for Check Programs, and Fixes from a Security Review

emfor 0.7.0 is a hardening release: exec checks and plugins no longer inherit the daemon's environment (env_pass adds what they need), the store files, the main config file and the peer secret are held to stricter rules, a daemon that encrypts refuses plaintext peer messages by default, and a review's fixes include late peer messages overwriting newer ones and http checks failing without CA certificates.

emfor is an open-source health-check daemon that runs on every application host. It checks the backends of the services your applications use and writes which ones are healthy into a local file; applications ask a client library which backend to connect to and get an answer in about a microsecond, without a network round trip.

0.7.0 was released on 2026-11-22. 0.6.0 was about running emfor next to the tools you already have; this release is about what the daemon and its files trust. It follows a self-assessment against a security checklist and a review of the whole system: the check programs a daemon starts get a small environment, the files it reads and writes are held to stricter rules, and a few places where one slow or wrong input could stall or confuse it are fixed. Several of these are compatibility changes: each tightens a default, and an install that relied on the old behaviour needs one line of config. Read section 1 before you upgrade.

1. Before you upgrade

The store format (version 2) and the plugin protocol (1) are unchanged: clients and plugins of 0.6.0 keep working with this daemon. libemfor is now libemfor.so.0.7, so rebuild or reinstall what links against it. Six things can stop an install that relied on the old behaviour; run emfor check-config with the new binary, as the daemon’s user, on every host first, because it reports most of them.

  1. exec checks and plugins get a small environment. A check program that reads HOME, a proxy variable or the like now needs env_pass (section 2). check-config does not warn about this one.
  2. The store files are 0640 and 0660 by default (they were 0644 and 0666). An application user that is not in the daemon’s group gets UNAVAILABLE from the client. Add the user to the group (usermod -aG emfor <user>), or write file_mode = "0644" and lock_file_mode = "0666" under [store] to keep the old behaviour.
  3. A daemon that encrypts peer messages drops plaintext ones by default. If a group still has members with encrypt = false or on 0.3.0, give the hosts that encrypt an explicit accept_plaintext = true until every member encrypts. A host on 0.3.0 or 0.4.0 does not know that key, so it goes in the same config change as the upgrade there; on 0.5.0 or 0.6.0 it goes in before the upgrade.
  4. A peer secret file must be owned by root or by the user that runs emfor. Whoever owns a file can rewrite it, whatever its mode says. chown root:emfor it on every host before you upgrade.
  5. The main config file is checked like the files of include_dir: not writable by group or others, owned by root or the user that runs emfor. The deb, rpm and FreeBSD port install it that way. A file with mode 0664 stops the daemon at start until chmod g-w,o-w /etc/emfor/emfor.toml.
  6. previous_secret_file is used only for the secret the daemon replaced. It is no longer used just because the current file was touched within 120 seconds (section 4). The first start of 0.7.0 has no record yet, so it ignores the option once.

2. exec checks and plugins no longer get the daemon’s whole environment

A program that an exec check or a plugin starts used to inherit every variable of the daemon’s environment, so a secret set there (by a unit file, for example) reached every check program. It now gets only PATH, LANG, TZ and the LC_* variables, with the daemon’s values, and exec also gets EMFOR_IP, EMFOR_PORT and EMFOR_SERVICE.

The new env_pass is a list of variable names, never values, in the check_options of an exec check and in [plugins."<name>"]. It adds variables the daemon has; a name the daemon does not have is skipped. Changing a plugin’s env_pass restarts the plugin on reload, like changing its command, and the names are part of the check definition that peers compare, so the hosts of a group must list the same names for a service. emfor-check also reads SSL_CERT_FILE and SSL_CERT_DIR, to find the system CAs of a TLS check that has no ca_file.

3. Stricter files, and warnings for passwords sent in clear text

  • The store files. The lock file holds LMDB’s reader table and the lock the daemon takes for every commit, and it was writable by every local user. The daemon sets the new modes on the existing files at every start. emfor check-config and the daemon warn, one line per option, about a file_mode or lock_file_mode that other users can write.
  • The main config file can declare a plugin command, which runs with the daemon’s rights, as a fragment can; only the fragments were checked. At start a refusal exits with status 2 before the store is opened; at a reload the old config keeps running.
  • Peer secrets are opened first and the opened file is checked (mode, regular file, owner) and read, so the file cannot be swapped in between and a FIFO named as the secret no longer makes the once-a-second re-read wait. A secret larger than 65536 bytes is a config error (a secret needs 32). The daemon wipes the secret and the keys derived from it from memory when it drops them.
  • Warnings, never errors. A password_file, secret_file or tls_key_file in a check’s options that every user can read or that anyone but its owner can write gets one line naming the services that use it. A password_file without tls on a redis, ldap, mysql, pgsql or amqp check gets a line too. A config that works keeps working.
  • Invisible characters in a check’s reason (the bidirectional controls such as U+202E, the zero-width characters, the soft hyphen) are escaped as \u{202e}, and so are the lines a plugin writes to stderr and the name and version in its handshake, so a backend or a plugin cannot forge a log line or make emfor status show a service as something else. A redis server that echoes the AUTH password in an error no longer puts it in the reason, and the reason of a failed http check no longer holds the request URL, token in its query string included.
  • The systemd unit sets UMask=0027, ProtectProc=invisible and ProcSubset=pid, and stops retrying after five failed starts in a minute (an invalid config used to be retried every two seconds without end). systemd-analyze security rates it 1.5, it was 1.7. A copy of the example unit has to be updated by hand; the packages bring the new one.

4. Fixes

  • A late peer message no longer overwrites a newer one. The replay check lets a message that the network delivered late through, if its seq is within 64 of the highest, and the daemon then kept it as the sender’s latest result, replacing a later one and making the result look fresh again. Each kept result and each member’s tags now remember the boot and seq they came from, and an older one leaves them alone. The wire format is unchanged.
  • A retired secret could come back. After a change of secret from K1 to K2 with previous_secret_file still holding K0, a restart within 120 seconds signed with K0, and the members that had dropped K0 stopped hearing the host. The daemon now keeps a record of the secrets it has used (a fingerprint, never the secret) in <store path>-peers, mode 0600, and uses previous_secret_file only for the secret it replaced less than 120 seconds ago.
  • A hung peer secret file no longer stops the peer loop. On a network file system that does not answer, the once-a-second read never returned and the other members saw the host as not live after three seconds while its checks and DNS went on. The read now runs on a blocking thread, and where the system allows it (inotify, kqueue) the file is watched and read when it changes. A hung config file no longer blocks SIGTERM on a reload either.
  • http checks work on a host without CA certificates. Every http check was an error with cannot build http client: builder error, even with scheme = "http", because building the client read the system roots for a verifier that a plain request never uses. https with verification on still needs the certificates, and its reason now says so.
  • A client that opens the store while the daemon pads it no longer fails. The daemon commits a write and only then extends the data file to the recorded length, and a client that opened the store in that gap refused it as truncated for one second. It now measures again up to five times, 20 ms apart.
  • Smaller ones: a restarted plugin leaves no tasks behind; libemfor on FreeBSD no longer aborts a process that forks while a thread is exiting; the rpm keeps a changed /etc/emfor/emfor.toml on upgrade (noreplace) instead of replacing it with the packaged one; durations in the config are parsed by emfor itself, because the humantime crate is now flagged unmaintained; and examples/pf/emfor-pf-table.sh and examples/nagios/check_emfor.sh check what they hand on to pfctl and to Nagios.

The deploy scripts have a change of their own: emfor-drain.sh and emfor-peers-sync.sh ran emfor check-config as root, and check-config starts the plugins the config declares, so a plugin ran as root outside the service’s sandbox. They now run it as EMFOR_USER (default emfor). There is also a new recipe for a peer group whose hosts come and go: emfor-peers-sync.sh writes [peers] members into a conf.d file from a list of addresses (AWS and Google Cloud examples are in the peer groups chapter of the manual).

5. Known limits

  • The pf recipe and the Nagios examples were run on FreeBSD 15.1-RELEASE (arm64, in a VM) after these changes. Not tested: Nagios itself (only its plugins), FreeBSD 13.x and 14.x, poudriere, and the kqueue watch of the peer secret on FreeBSD by hand. Most checks of this release ran in a Debian container; macOS was run only for part of the tests.
  • The container check that an http check works without CA certificates was run once, on Debian 13, and is not part of the test gate.
  • Environment: the PATH that systemd gives the daemon was not checked, and neither were installs whose check programs need variables that nobody here knows about; if one fails after the upgrade, add its variable to env_pass.
  • Unchanged from earlier releases: the HAProxy 503 after a server-template slot with port 0 on FreeBSD; the deb and rpm tested in containers, the deb also under systemd but not the rpm, not signed and not in any repository; peer messages have no forward secrecy; the ldap plugin has been checked against Active Directory only without a certificate; lookup throughput across threads levels off at about two million a second on Linux; with [store] sync = false (the default) a host crash can damage the store; a host announces at most 80 services left out of the peer group.

6. How to upgrade

  1. Run emfor check-config as the daemon’s user with the 0.7.0 binary on the config of every host before you upgrade it (section 1).
  2. Before the upgrade: chown root:emfor the peer secret files, put application users into the daemon’s group (or set the old store modes), and add accept_plaintext = true where a group still has plaintext members. Look at every exec check and plugin that needs a variable of the daemon’s environment and give it an env_pass.
  3. Install libemfor and the daemon from 0.7.0, host by host. Once every member has encrypt = true and the plaintext count in emfor_peer_messages_rejected_total stops increasing, remove accept_plaintext = true again and reload.

The user manual on this site is rewritten for 0.7.0. The full list of changes is in the CHANGELOG, and the source is in the v0.7.0 release on GitHub.


💡 Technical collaboration and architecture consulting

Are your services struggling with inconsistent health checks, slow failure detection, or check traffic that weighs on your backends? We can help you assess your architecture and adopt the health-check and service-discovery approach that fits.

📧 Book a technical consultation

Built with Hugo
Theme Stack designed by Jimmy