Skip to content

Security

Unlike in the golden era of BBSing, modern Internet-connected systems are prone to hacking attempts, eavesdropping, etc. While plain-text passwords, insecure data over Plain Old Telephone Service (POTS), and so on was good enough then, modern systems must employ protections against attacks. ENiGMA½ comes with many security features that help keep the system and your users secure — not limited to:

config.hjson may contain secrets — the SSH host key passphrase, email credentials, FTN/BinkP session passwords, and more. To limit exposure:

  • Restrict file permissions. The config file should be readable only by the OS user that runs ENiGMA½:
    Terminal window
    chmod 600 /path/to/enigma-bbs/config/config.hjson
  • Restrict the SSH private key itself in the same way:
    Terminal window
    chmod 600 /path/to/enigma-bbs/config/ssh_private_key.pem
  • Do not commit config.hjson to version control. Add it to .gitignore if you track your configuration in git.
  • Limit OS-level read access to backup archives that include the config directory.

For stronger separation — especially in container or GitOps environments — ENiGMA½ supports two directives that let you keep sensitive values out of config.hjson entirely:

  • @file:/path/to/secret — reads the value from a file at startup (trimming surrounding whitespace). Ideal for Docker/Podman secrets (/run/secrets/…) or any chmod-600 file on disk.
  • @environment:VAR_NAME — reads the value from an environment variable.

These work for any string-valued config key. Examples:

loginServers: {
ssh: {
privateKeyPass: "@file:/run/secrets/ssh_key_pass"
}
}
email: {
transport: {
auth: {
user: noreply@yourbbs.net
pass: "@environment:SMTP_PASS"
}
}
}
scannerTossers: {
ftn_bso: {
binkp: {
nodes: {
"1:218/700": {
sessionPassword: "@file:/run/secrets/binkp_pass"
}
}
}
}
}

See Configuration Files — Secret Files for the full reference and a complete list of supported @environment: type coercions.

A new user name, whether chosen at sign-up or set with oputil user rename, must match users.usernamePattern. The default allows letters, digits, spaces and the symbols ~!@#$%^&*()-_+., but rejects a name that starts with a dash (-). Existing accounts are not checked again. If you set your own users.usernamePattern, it replaces the default, so add (?!-) after the ^ if you want the same rule.

Three limits under users.failedLogin slow down password guessing. All are on by default:

users: {
failedLogin: {
disconnect: 3
lockAccount: 9
autoUnlockMinutes: 360
perAddress: 10
perAddressWindowMinutes: 10
}
}
  • disconnect: after this many failed logins on one connection, the caller is disconnected. 0 never disconnects.
  • lockAccount: after this many failed logins in a row for one account, from anywhere, the account is locked. autoUnlockMinutes unlocks it again after that long (0 leaves it to the sysop: ./oputil.js user activate USERNAME). 0 never locks.
  • perAddress: the failed logins one address may make per perAddressWindowMinutes, across telnet, SSH, the web terminal, NNTP and the REST API together. Past that, each further password check from the address waits before it runs: 1, 2, 4, then 5 seconds. They run one at a time: while one of the address’s checks is under way, the next waits its turn, for at most 30 seconds before it goes ahead anyway. Nothing is refused because of the address (though under a flood the board-wide limit below can turn a check away). The budget refills evenly over the window, so the waits are gone a few minutes after the failures stop. A login that succeeds gives back only its own attempt; it does not refill the budget. 0 turns the per-address limit off. Reconnecting does not reset it, as it does disconnect.

On every server, the REST API included, the wait comes before the user name is looked up, and a name that does not exist uses up the address’s budget just as a wrong password does. Neither the wait nor the budget tells whether an account exists.

An address that may stand for many callers is never slowed: loopback (127.0.0.0/8, ::1), any address in trustedProxies (by default loopback and the private ranges, where a proxy on the same host, a tunnel, a container gateway or a LAN proxy shows up), and a connection with no usable address. Only the board-wide limit below applies to those. An IPv6 address counts per /64, since one subscriber normally holds a whole /64.

Behind a TCP proxy or tunnel (HAProxy in TCP mode, nginx stream, Cloudflare Spectrum, and so on), telnet, SSH and NNTP callers all arrive from the proxy’s address. If that address is public and not in trustedProxies, all callers through it share one budget. While someone is guessing through the proxy, everyone’s logins through it are slowed: the address’s checks run one at a time, each after a wait of up to 5 seconds, and a caller whose check has waited its turn for 30 seconds goes ahead alongside the others. So a login through the proxy is answered within about 35 seconds however many guesses are queued, and is not refused because of the address. ENiGMA½ logs a warning the first time an address goes over its budget; if that address is your proxy, add it to trustedProxies. Note that the same list decides whose X-Forwarded-For header is believed when a server has proxied set (see Trusted Proxies), so only list proxies you run. The web terminal and the REST API see the real caller’s address behind an HTTP proxy that sets X-Forwarded-For, when proxied is set.

Checking a password is deliberately slow (PBKDF2), and it runs on Node.js’s libuv thread pool, which file access, compression (zlib) and DNS lookups share. TLS does not use the pool. So that logins cannot fill the pool, only a few password checks run at once board-wide: half the pool, but no more than one fewer than the number of CPUs, and always at least one. With the default pool of 4 threads that is 2 on a machine with 3 or more CPUs, and 1 on a machine with 2. Further checks wait their turn, those from addresses within their budget first, and addresses take turns, with signups, password changes and logins through a shared address getting every other turn. That is fair until more than 256 addresses each have a check waiting; past that, each new arrival pushes out the latest one before it, so the checks that got in first keep their turn and the rest are turned away. When 256 checks are already waiting, the newest check of the address with the most waiting fails at once (Busy), except that while signups and shared-address logins fill more than half the queue, a new one of those is what fails, and an address with nothing waiting takes the newest one’s place. A caller turned away sees an ordinary failed login, which does not count toward disconnect or the account lock. So under a flood a login can be turned away, though not because of its address.

The one-at-a-time rule has a limit, by design: a check that has waited its turn for 30 seconds goes ahead anyway, so that nobody sharing an address with an attacker waits much longer than that. An address with many connections open (N of them) can therefore still get roughly N/35 password checks a second, spread over accounts. Each account still locks after lockAccount failures, and the board-wide limit above caps the hashing whatever the number of connections.

On a busy board you can give the pool more threads by setting the environment variable UV_THREADPOOL_SIZE before starting ENiGMA½, e.g. UV_THREADPOOL_SIZE=8 ./main.js. The number of password checks run at once grows with it.

Two-Factor Authentication via One-Time Password

Section titled “Two-Factor Authentication via One-Time Password”

Enabling Two-Factor Authentication via One-Time-Password (2FA/OTP) on an account adds an extra layer of security (“something a user has”) in addition to their password (“something a user knows”). Providing 2FA/OTP to your users has some prerequisites:

  • A configured email gateway such that the system can send out emails.
  • One or more secure servers enabled such as SSH or secure WebSockets (that is, WebSockets over a secure connection such as TLS).
  • The web server enabled and exposed over TLS (HTTPS).

Due to the nature of 2FA/OTP, even if enabled on your system, users must opt-in and enable this feature on their account. Users must also have a valid email address such that a registration link can be sent to them. To opt-in, users must enable the option, which will cause the system to email them a registration link. Following the link provides the following:

  1. A secret for manual entry into a OTP device.
  2. If applicable, a scannable QR code for easy device entry (e.g. Google Authenticator)
  3. A confirmation prompt in which the user must enter a OTP code. If entered correctly, this validates everything is set up properly and 2FA/OTP will be enabled for the account. Backup codes will also be provided at this time. Future logins will now prompt the user for their OTP after they enter their standard password.

A wrong one-time password or backup code counts toward users.failedLogin just as a wrong password does: after disconnect failures the caller is disconnected, and after lockAccount failed logins in a row (passwords and codes together) the account is locked. While it is locked, the code prompt answers “locked” whatever is entered, without checking it. For an account with 2FA/OTP, the failed login count, and a lock that has run out (autoUnlockMinutes), are cleared only once the code checks out, not by the password alone. An email password reset leaves the count and any lock of such an account as they are, since it proves nothing about the second factor; the lock runs out as usual, or the sysop can clear it with ./oputil.js user activate USERNAME.

In the situation that a user loses their 2FA/OTP device (such as a lost phone with Google Auth), there are some options:

  • Utilize one of their backup codes.
  • Contact the SysOp.

Various places throughout the system that implement ACS can make 2FA specific checks:

  • AR#: Current users required authentication factor. AR2 for example means 2FA/OTP is required for this user.
  • AF#: Current users active authentication factor. AF2 means the user is authenticated with some sort of 2FA (such as One-Time-Password).

See ACS for more information.

The following example illustrates using an AR ACS check to require applicable users to go through an additional 2FA/OTP process during login:

login: {
art: USERLOG
next: [
{
// users with AR2+ must first pass 2FA/OTP
acs: AR2
next: loginTwoFactorAuthOTP
}
{
// everyone else skips ahead
next: fullLoginSequenceLoginArt
}
]
// ...
}