Skip to content

NTNT v0.6.3 — Security fixes and verified TLS for PostgreSQL and Redis

Choose a tag to compare

@github-actions github-actions released this 21 Nov 01:01
· 116 commits to main since this release
ed4ee16

NTNT v0.6.3 — Security fixes and verified TLS for PostgreSQL and Redis

NTNT 0.6.3 is a security release. It fixes the findings of a security scan of the
runtime, standard library and installers, adds verified TLS for runtime PostgreSQL
and Redis connections, and updates the SMTP client behind std/email for six
advisories. Several fixes change behaviour, so read the upgrade checklist before
deploying.

This announcement describes the changes since the last published release,
v0.6.2.

Authentication rules cover every handler they name

  • Handlers under the auth prefix. require_auth() and protected-path rules now
    apply to application handlers registered under the auth route prefix (/auth by
    default). Before, everything under the prefix was public, so a custom
    /auth/profile route ran without a session. Only std/auth's own handlers there
    stay public: the login page, provider start and callback, logout, health and
    auth_me.
  • The path the router serves. Auth now matches requests the way the router
    does, so //admin, /admin//settings and /admin/ hit the rules for /admin
    instead of bypassing them. Protection patterns and route_prefix are stored in
    the same canonical form, and redirects built from the request path use it too: a
    request for //evil.example/x can no longer produce a protocol-relative
    Location.
  • Workers starting or reloading. Protection rules no longer disappear while
    other workers start, restart or reload. Each worker re-runs the application's
    setup, and its enable_auth() used to clear the shared rules while worker 0 was
    already serving, so a path protected only by a rule was briefly public. While a
    server is serving, enable_auth() now adds rules instead of replacing them.

Application code cannot change the runtime's security policy

The process-execution policy (NTNT_PROCESS_ENABLE, NTNT_PROCESS_ALLOW) and the
fetch() network policy (NTNT_SSRF_PROTECTION, NTNT_ALLOW_LOCALHOST,
NTNT_ALLOW_PRIVATE_IPS, NTNT_BLOCKED_HOSTS) are read once, from the environment
that starts ntnt, before any application code runs. load_env skips those keys,
NTNT_NET_ALLOW_PRIVATE, NTNT_NETMON_ENABLE and every NTNT_SECRETS_* key,
printing one warning per key and loading the rest of the file. Loading
NTNT_ENV=development can no longer lift a production host's localhost block;
loading NTNT_ENV=production still adds it. Other production protections follow
the NTNT_ENV that load_env sets; see Deploying with .env files below.

Cloud metadata endpoints stay blocked

fetch(), download(), cache_fetch() and probe_fetch() compare hosts in
canonical form (case, trailing dots, and IP literals in any notation), so spellings
such as metadata.google.internal. or [::ffff:169.254.169.254] are blocked.
Metadata addresses returned by DNS are denied on every request and redirect hop,
even with NTNT_ALLOW_PRIVATE_IPS or NTNT_ALLOW_LOCALHOST set; only
NTNT_SSRF_PROTECTION=false in the host environment turns the check off.
NTNT_BLOCKED_HOSTS entries are canonicalized the same way, and an IP entry also
blocks names that resolve to it.

Safe Markdown drops unsafe links

to_html_safe() renders a link whose scheme is not http, https or mailto as
its plain text, omits an image with such a source (keeping its alt text), and no
longer renders heading attributes such as # Title {#id .class}. Scheme detection
follows browsers: it ignores case, leading control characters and embedded tabs or
newlines. Relative links, fragments and to_html() are unchanged.

Verified TLS for PostgreSQL and Redis

  • PostgreSQL (std/db/postgres and the std/auth store) honours sslmode:
    verify-full checks the certificate chain and host name, verify-ca the chain
    only (it needs sslrootcert), require encrypts without verifying, and disable
    stays plaintext. prefer and allow are rejected because they can fall back to
    plaintext. Without sslmode, a connection uses verified TLS (verify-full
    against the host CA store) unless every host is local: a loopback address,
    localhost, a Unix socket, or a single-label name such as a Docker service
    (db), which stay plaintext as before. sslrootcert=/path/ca.pem adds a private
    CA and always means verified TLS: without sslmode it selects verify-full for
    local hosts too, it cannot be combined with require or disable, and over a
    Unix socket, which PostgreSQL serves in plaintext only, it is an error. A TLS
    connection never falls back to plaintext, and errors never include the
    connection string. Each TLS policy has its own connection pool, and trust roots
    are read once per pool: restart after rotating a CA. A server that accepts TLS
    must finish the handshake within the connection string's connect_timeout, or
    10 seconds when it sets none; otherwise the connection is closed with an error.
    A target given only as hostaddr= is named by that address, so verify-full
    needs a certificate for the IP address (libpq instead refuses verify-full
    without a host name), and such targets now also work in plaintext through the
    connection pool, where they used to fail on Unix.
  • Redis and Valkey (std/kv, std/jobs stores and the std/auth session store):
    rediss:// and valkeys:// connect over TLS and verify the certificate chain and
    host name against the host CA store. redis:// and valkey:// stay plaintext.
    Before, std/kv treated a rediss:// URL as a SQLite file path, and jobs and auth
    rejected it. Connecting now has a deadline on each wait: std/kv open(), job
    stores and the auth session store wait at most 10 seconds for each answer during
    the TCP connect, the TLS handshake and the setup commands, so a server that stops
    answering is an error instead of a hang. The bound is per wait, not for the whole
    connection, so a reply that arrives very slowly can take longer (see the known
    issues). One auth-store operation's slow connect no longer holds up the others.

SMTP fixes in std/email

std/email now uses lettre 0.11.24, which fixes six advisories in its SMTP
client:

  • RUSTSEC-2026-0560: STARTTLS response injection let a
    man-in-the-middle forge SMTP replies. Only STARTTLS connections are affected.
  • RUSTSEC-2026-0561: message content with a bare LF or CR
    was not dot-stuffed, allowing SMTP command injection.
  • RUSTSEC-2026-0563: mail for an address with a quoted local
    part could be sent to a different address.
  • RUSTSEC-2026-0565: a malicious server could exhaust memory
    with an unbounded reply.
  • RUSTSEC-2026-0562 and
    RUSTSEC-2026-0564: panics on an EHLO reply line of only
    white space and on a display name containing CR or LF.

Other fixes

  • The warning for JavaScript-style ${...} interpolation in string literals scans
    each literal once and reports at most 64 candidates, shortening long snippets. A
    crafted literal previously took quadratic time and memory.
  • Windows installer: install.ps1 verifies the archive against the release's
    .sha256 file before extracting it, and replaces an existing ntnt.exe only after
    the new binary runs and reports the release's version; on any failure the previous
    install stays. It no longer builds from source when the download fails, never
    reuses or overwrites an existing .\ntnt directory, and fetches the starter kit
    from the release tag instead of main.
  • ntnt test sends its requests once the app's server is listening, instead of
    after a fixed short wait, so an app that is slow to start no longer fails its
    first requests; --port 0 now picks a free port.
  • Release checksums: the Windows archive's .sha256 file now ends its line with
    LF like the others, so shasum -a 256 -c on macOS accepts it.
  • Process tests keep their fixtures in private temporary directories.

Compatibility and upgrade checklist

  1. Policy keys belong in the host environment. load_env now skips
    NTNT_PROCESS_ENABLE, NTNT_PROCESS_ALLOW, the fetch() policy keys,
    NTNT_NET_ALLOW_PRIVATE, NTNT_NETMON_ENABLE and every NTNT_SECRETS_* key,
    printing a warning for each. If your app sets any of them in a .env file, set
    them in the environment that starts ntnt instead; otherwise process execution,
    fetch(), std/net, std/netmon and std/secrets use their defaults.
  2. Handlers under the auth prefix. A custom handler under the auth prefix that
    require_auth() or a protected-path rule covers now requires a session. With a
    global require_auth(), a custom page mounted at the prefix itself redirects to
    the prefix; exclude it in your own middleware.
  3. PostgreSQL TLS. A connection string whose host is not local (a name containing
    a dot, or a non-loopback address) and that has no sslmode now requires verified
    TLS. Enable TLS on the server, add sslrootcert= for a private or managed CA, or
    add sslmode=disable to keep plaintext on a trusted network. sslrootcert
    always means verified TLS, local hosts included: remove it to use disable or
    require. sslmode=prefer and sslmode=allow are rejected, and so are TLS
    modes over a Unix socket.
  4. Safe Markdown. to_html_safe() renders tel:, ftp:, data: and other
    links outside http, https and mailto as plain text. Use to_html() for trusted
    content that needs them.
  5. Development reload. A require_auth(path) rule or protected_paths entry you
    delete stays enforced until the server restarts; rules you add still apply at the
    reload.

Deploying with .env files. Apart from the reserved policy keys, load_env
applies every value in the file, NTNT_ENV included, so a development .env
deployed with a production app turns off its production protections. Ship the
.env meant for that host, or none, and keep production secrets in
std/secrets. #409 tracks a warning when a .env changes NTNT_ENV from the
host's value.

Builds and dependencies. Release archives cover the same platforms as before:
Linux x64, Linux ARMv7 hard-float, macOS Apple Silicon and Windows x64. redis
moves to 0.28.2 and lettre to 0.11.24. The redis crate's rustls support adds
rustls-pemfile and webpki-roots (data only; NTNT verifies against the host CA
store), plus older versions of rustls-native-certs, openssl-probe
(certificate-path lookup, with no OpenSSL linkage) and security-framework (macOS
only) alongside the ones NTNT already uses. Contributors and builders use the
pinned Rust 1.99.1 toolchain.

Known issues not fixed in this release:

  • A development reload that fails before enable_auth() serves routes without
    authentication (#394).
  • ntnt stops with a panic when load_env reads a .env line with an empty key
    (#406).
  • A rediss:// or valkeys:// host name that resolves to several addresses
    fails to connect when its first address does not answer, even if a later one
    would (#410).
  • Some connection waits still have no deadline of their own: PostgreSQL's wait for
    the server's first answer and its login exchange, Redis/Valkey host name lookups
    and replies that arrive very slowly, and Redis commands after the connection is
    set up (#410).

The version-pinned references below become available with the v0.6.3 tag:

Full changelog: v0.6.2...v0.6.3

What's Changed

  • fix: security hardening for 0.6.3 (auth, runtime policy, SSRF, Markdown, installers) by @larimonious in #395
  • fix: land runtime TLS (#396) on main; lettre 0.11.24 for six SMTP advisories by @larimonious in #405
  • release: prepare 0.6.3; Windows checksum file ends with LF by @larimonious in #408

Full Changelog: v0.6.2...v0.6.3