The check against links in the server's directory also refused a
secret_file with no secret_from, which the join only checks is there
and never reads or writes: only the server reads it. An operator may
keep such a secret elsewhere and link it in, so it is no longer
refused; a secret the join installs still is.
Test: TestJoinLeavesALinkedSecretItDoesNotWrite is new and passes;
TestJoinRefusesLinksInTheServersDirectory still passes.
The proxy in front of the console and the webmail, which holds their
TLS keys (and runs on the host network beside a host server), was
docker.io/library/caddy:2-alpine: a floating tag on Docker Hub, so
every install and converge ran whatever that tag named that day, and
whoever could push it chose what ran as the proxy. Everything else
the installer downloads is checked against a checksum in its source.
Caddy is now pinned in internal/release by the digest of its image
index (2.11.9-alpine), and compose.yaml names it by digest. pin-check
reads Docker Hub's caddy tags and reports a newer X.Y.Z-alpine in the
series, or the pinned version's tag now naming another image (Docker
Hub rebuilds them for a new Alpine), so the pin is moved by the same
reviewed change as the others. The comment that called the suite's
own tags immutable is corrected: they can be pushed again.
Test: TestCaddyIsPinnedByDigest failed before (DefaultCaddyImage was
"docker.io/library/caddy:2-alpine") and now passes; TestCheckCaddy and
TestSuiteImagesNameAnExactRelease are new.
A host first boot restarts the server and then sends the bootstrap
credential, then the administrator's password, then the setup's API
key to 127.0.0.1:8080 and later :8081; a move to the host does the same
with the operator's API key. Those are unprivileged ports, and nothing
checked who answered there. A local user who bound one while the
server restarted was sent the password or the key.
Before each such request, the installer now checks that every socket
listening on that port belongs to the server unit's main process
(systemctl show -p MainPID), reading /proc as the port survey already
does; otherwise nothing is sent, and the step waits or fails naming
what holds the port. The jmap client gained a Guard hook for this. A
server in a container is not checked: the runtime publishes its port.
Test: TestSetupCredentialsGoOnlyToTheServersOwnListener failed before
(a listener that wasn't the server's received "Basic ..." and "Bearer
the-api-key") and now passes; TestSetupCredentialsGoToTheServer and
TestSetupCredentialsCheckTheClientsCurrentAddress are new.
First boot wrote its two compose overrides to /tmp/inbuxa-bootstrap.yaml
and /tmp/inbuxa-basic-auth.yaml, and a host webmail install downloaded
Node to /tmp/inbuxa-node.tar.xz(.part), all opened by root with no
O_EXCL and following links. A local user could create those names
first: with fs.protected_regular off, root then wrote into the user's
own file, which the user could rewrite before docker compose read it
(an override that mounts / into the server) or before tar unpacked it
as root (after the checksum had passed), or a link made root overwrite
another file. With the sysctl on, it made the install fail. The Node
tarball was also never removed.
Each override now goes in a new directory from os.MkdirTemp (0700),
created with O_EXCL and removed with its directory when the step ends.
Node is downloaded the same way and removed once unpacked. A download's
.part file is always created new: anything already at the name is
removed first, and a link there is never written through.
Test: TestSetupOverrideIsNotAtAFixedNameInTmp,
TestNodeTarballIsNotAtAFixedNameInTmp and
TestFetchVerifiedDoesNotWriteThroughAPartLink failed before (a planted
link was written through) and now pass.
The relay binary and its directory belong to the relay's user, so an
upgrade sent from the console can replace it in place. relay install
(dry runs too) and relay status nevertheless ran that binary as root
to ask its version. Code running as the relay user, for example after
a compromise of the internet-facing relay, could replace the binary
and have it run as root, outside the relay's sandbox, the next time
an administrator checked on it.
The version is now asked as the relay user, through runuser, as join,
status and reset already were. Everything the installer runs of the
installed binary also runs in a session of its own, so it no longer
has root's terminal as its controlling one and can't push input into
it. The freshly downloaded, checked binary is still tried as root,
from root's own temporary directory, before it is put in place.
Test: TestInstalledVersionDoesNotRunTheBinaryItself failed before (the
stand-in binary ran as the test's own user) and now passes;
TestTheInstalledBinaryRunsAsTheRelayUser is new.
The server's home (<dir>/server) belongs to its user, and the server
runs as that user with write access there. Install, cluster join and
move then worked on paths inside it as root in ways that follow
symbolic links. Code running as the server's user (a compromised
server, for example) could put a link at data/, config.json,
config.json.prev or a secret file, and the next install, converge,
move or cluster join would chown the link's target to that user, write
over it, or copy a root-only file into an inbuxa-owned rollback copy:
the server's user became root.
Now install refuses a data/ that is not a plain directory and changes
ownership with chown -h and no trailing slash. Cluster join refuses a
link at config.json, its rollback copy or a secret in the server's
directory, reads config.json without following a link, and writes
each file beside its place, gives it to the server's user through the
open file and renames it into place. A move reads config.json without
following a link and replaces it by a rename, and refuses a data/ that
is a link before emptying it.
Test: TestServerDirsRefusesALinkedDataDir, TestJoinRefusesLinksInTheServersDirectory,
TestJoinDoesNotWriteThroughALinkPlantedAfterThePlan and
TestRewriteDataPathRefusesALink failed before (the link was chowned or
written through) and now pass.