Security fixes for 27.1-rc.37 #511

Merged
jcoffey-dev merged 5 commits from sec/batch-11 into main 2026-11-20 20:48:02 +00:00
Owner

Security fixes for 27.1-rc.37: 5 commits, from a private security review. Every fix has a test. Advisories are drafts and stay private for now.

  • WebDAV: every file answer carries Content-Security-Policy: default-src 'none'; frame-ancestors 'none'; sandbox and nosniff; only raster images, audio, video and plain text are shown inline, everything else downloads. (advisory, high)
  • ACME: a tenant's provider reaches only public HTTPS addresses (IP literals checked before sending, names when they resolve, no redirects). ACME errors carry only the problem type and detail, bounded, for every provider. (advisory, medium, with DNS)
  • DNS: a tenant's DNS provider reaches only public addresses: endpoints must be public HTTPS, RFC 2136 servers public, and fields built into URLs plain names. Checked on save and on every use. (advisory, medium, with ACME)
  • OIDC directories: a tenant's reaches only public HTTPS addresses, discovered endpoints included. is_global_ip and the public-only resolver move to utils::public_ip so the directory crate can use them. (hardening)
  • Passkeys: a sign-in challenge or registration ceremony is used once even when sent several times at once: each reader takes an atomic claim, and only the first gets it. (hardening)

Server-owned ACME providers, DNS providers and directories keep any destination.

Tests: fmt, fork checks, build, unit tests, and the webdav, directory, system and passkey suites pass locally. The new webdav, ACME and DNS tests fail without their fixes. The system suite needs #510 (a separate bug from #500) to get past the account purge step.

Security fixes for 27.1-rc.37: 5 commits, from a private security review. Every fix has a test. Advisories are drafts and stay private for now. - WebDAV: every file answer carries `Content-Security-Policy: default-src 'none'; frame-ancestors 'none'; sandbox` and `nosniff`; only raster images, audio, video and plain text are shown inline, everything else downloads. (advisory, high) - ACME: a tenant's provider reaches only public HTTPS addresses (IP literals checked before sending, names when they resolve, no redirects). ACME errors carry only the problem type and detail, bounded, for every provider. (advisory, medium, with DNS) - DNS: a tenant's DNS provider reaches only public addresses: endpoints must be public HTTPS, RFC 2136 servers public, and fields built into URLs plain names. Checked on save and on every use. (advisory, medium, with ACME) - OIDC directories: a tenant's reaches only public HTTPS addresses, discovered endpoints included. `is_global_ip` and the public-only resolver move to `utils::public_ip` so the directory crate can use them. (hardening) - Passkeys: a sign-in challenge or registration ceremony is used once even when sent several times at once: each reader takes an atomic claim, and only the first gets it. (hardening) Server-owned ACME providers, DNS providers and directories keep any destination. Tests: fmt, fork checks, build, unit tests, and the webdav, directory, system and passkey suites pass locally. The new webdav, ACME and DNS tests fail without their fixes. The system suite needs #510 (a separate bug from #500) to get past the account purge step.
jcoffey-dev added 5 commits 2026-11-20 20:38:35 +00:00
A file stored over WebDAV was served with whatever content type its
uploader gave it, and with no Content-Disposition or sandbox policy. An
HTML or SVG file opened in a browser ran as a page of the mail server's
own origin, the one that serves the sign-in page and JMAP. Any account
that can store a file could leave one for someone else to open.

Every file answer (GET, HEAD, ranges, 416) now carries
"Content-Security-Policy: default-src 'none'; frame-ancestors 'none';
sandbox" and nosniff, so a document has an opaque origin and no
scripts. Only raster images, audio, video and plain text are offered for
display; HTML, XHTML, SVG, XML, PDF and anything unknown download as
attachments. WebDAV clients ignore both headers.

Test: in the WebDAV suite, user_content stores HTML, XHTML, SVG, PDF,
untyped, text and PNG files and checks both headers on GET, HEAD and a
range request. On main the HTML file came back as text/html with
neither header.

Reported privately in a security review.
Tenant administrators can create ACME providers (sysAcmeProvider* is in
the default tenant role), and creating one fetches its directory URL
from the server, then follows the URLs the directory names. Nothing
limited where those requests went, plain HTTP was allowed, and a
non-2xx answer's body was returned in the JMAP error. A tenant
administrator could make the server request an internal address and
read part of the reply.

For a provider with a memberTenantId, every ACME request must be HTTPS
to a public address: IP literals are checked before sending, host names
when they resolve (the resolver Web Push uses), and redirects aren't
followed. The server's own providers are unchanged, so an internal ACME
server still works there. For every provider, an error now carries only
an RFC 7807 problem document's type and detail (bounded), never the raw
body, and a parse error quotes at most 120 characters.

Test: unit tests in acme::http refuse plain HTTP, private, link-local,
loopback and mapped addresses, and a name resolving to loopback, before
anything is sent; the tenant suite checks the same through
x:AcmeProvider/set (with the DNS changes).

Reported privately in a security review.
Tenant administrators can create DNS providers (sysDnsServer* is in the
default tenant role). Several take an endpoint (cPanel, Plesk, PowerDNS,
BlueCat, Infoblox, EdgeDNS, UltraDNS, Volcengine) and RFC 2136 takes a
server address, so DNS updates could be aimed at loopback or a private
service. Others build their URL from a region, zone id or domain, where
a value such as "[email protected]/" moves the host.

For a provider with a memberTenantId, checked each time it's saved and
each time an updater is built from it: endpoints must be HTTPS to names
that resolve only to public addresses, an RFC 2136 server must have a
public address, and names that go into URLs may only hold letters,
digits, '-', '_' and '.'. The server's own providers keep any
destination; private DNS servers are a normal setup there.

Test: unit tests in dns::tenant_endpoints; the tenant suite refuses
tenant ACME and DNS providers aimed at private addresses or with a
host-moving region, and still creates the server's own RFC 2136 provider
on a private address.

Reported privately in a security review.
An OpenID Connect directory fetches discovery, JWKS, user info and
introspection from the server. A directory a tenant manages (only when a
server administrator delegates sysDirectory*, which tenants don't have
by default) could point those at internal addresses.

For a directory with a memberTenantId, the issuer, introspection,
jwks_uri and userinfo URLs must be HTTPS and not a private IP literal,
host names are checked when they resolve, and redirects aren't followed.
Server-owned directories are unchanged. Test builds let a tenant's
directory use loopback, as push and reports do, because the harness
runs Keycloak on localhost.

is_global_ip and the public-only resolver move from common to utils,
unchanged, so the directory crate (below common) can use them; common
re-exports both.

Test: oidc::config::tenant_url_tests.

Reported privately in a security review.
Passkeys: a challenge signs in once, even when sent twice at once
ci / fork-checks (pull_request) Skipped
ci / build (pull_request) Skipped
github/ci (branch) GitHub Actions
ci / github (pull_request) Successful in 9m5s
bd5bfb3892
A sign-in challenge and a registration ceremony were read, then
deleted, in two steps. Two requests sent together with the same
challenge could both read it before either deleted it. Each still
needed a valid signed assertion, so this didn't let anyone in without
the passkey, but PK-10 says a challenge is good once.

Each reader now also takes a claim counter named after the key and
what it read. Every in-memory store increments it atomically (Redis,
SQL, the key-value stores, sharded or not), and only the first reader
gets the challenge. A registration ticket that starts a new ceremony
after a failed try gets a new claim. The counter expires with the
challenge.

Tests, in the passkey suite: 64 readers claiming one challenge at once
get exactly one win, and a ticket's next ceremony is a new claim. The
read-then-delete window is two back-to-back store calls, too short to
hit reliably over HTTP, so the claim is tested directly; the same
challenge sent six times at once over HTTP also signs in exactly once.

Reported privately in a security review.
jcoffey-dev merged commit ce0aa919d1 into main 2026-11-20 20:48:02 +00:00
jcoffey-dev deleted branch sec/batch-11 2026-11-20 20:48:03 +00:00
Sign in to join this conversation.