Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
4df3b25
Key custody S3 slice B3c, installer part: host-provider account refus…
wshallwshall Nov 22, 2026
74d9b48
Key custody B3c repair round 1: keep only the account refusal; read T…
wshallwshall Nov 22, 2026
2516efd
Key custody B3c repair round 2: the settings reader skips multi-line …
wshallwshall Nov 22, 2026
2ed4bbb
Key custody B3c: text only, the reader's docstring states its triple-…
wshallwshall Nov 22, 2026
6edc3b9
Key custody B3c: the settings reader skips lines inside a multi-line …
wshallwshall Nov 22, 2026
b9299af
Key custody B3c: text only, the settings reader's docstring drops its…
wshallwshall Nov 22, 2026
1291264
Key custody B3c: the custody installer test imports messagefoundry.se…
wshallwshall Nov 22, 2026
1814843
Key custody: the host provider reads a custody directory of its own
wshallwshall Nov 22, 2026
9ec2beb
Key custody: the installer makes the custody directory under the host…
wshallwshall Nov 22, 2026
033d49e
Key custody: repair round 1, custody directory review round-058d7b7c0e
wshallwshall Nov 22, 2026
055009a
Key custody: repair round 2, custody directory review round-e6602f0088
wshallwshall Nov 22, 2026
104122b
Key custody: round-232ff851bf's four items, the uninstaller and the n…
wshallwshall Nov 22, 2026
88e7fe3
Key custody: the other-provider check reads beside the store again, w…
wshallwshall Nov 22, 2026
d04015b
Key custody: way-on texts leave every key file in place; installer re…
wshallwshall Nov 23, 2026
cfe8a3d
Key custody: review round-abff55c7b2 repairs (unsafe advice, a regres…
wshallwshall Nov 23, 2026
04395c5
Key custody: review round-e035104760 repairs (a regression, unsafe ad…
wshallwshall Nov 23, 2026
0cd9fa9
Key custody: one SERVICE.md procedure for key-file refusals (review r…
wshallwshall Nov 23, 2026
09b6d4c
Key custody: review round-0c8608ba47 repairs (unsafe advice, a false …
wshallwshall Nov 23, 2026
3bb69a0
Key custody: review round-ba0f0fa1e7 repairs (unsafe advice, false co…
wshallwshall Nov 23, 2026
f9017f4
Key custody: text only, the five lead items of review round-0255766107
wshallwshall Nov 23, 2026
654156c
Merge origin/main into w7-custody
wshallwshall Nov 23, 2026
5551445
Key custody: PR 3168 hold items 1-10, a way on that reaches a mint
wshallwshall Nov 23, 2026
711cb88
Key custody: review round-ddf319bc80 repairs to the PR 3168 hold fixes
wshallwshall Nov 23, 2026
eab1e46
Key custody: review round-1d986c2c9d repairs to the PR 3168 hold fixes
wshallwshall Nov 23, 2026
cba6119
Key custody: text only, review round-0da6ce5df9 findings U2, U3, U4, U9
wshallwshall Nov 23, 2026
d11efef
Key custody: text only, the Lander's hold at comment 7111305444
wshallwshall Nov 23, 2026
b49710b
Key custody: text only, review round-0d8df5163a findings
wshallwshall Nov 23, 2026
01fd9b7
Merge remote-tracking branch 'origin/main' into fix-3168
wshallwshall Nov 23, 2026
d811625
Key custody: text only, review round-693a596586 findings
wshallwshall Nov 23, 2026
530e998
Secrets-directory lockdown: name the conditional Allow entry that sur…
wshallwshall Nov 24, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
216 changes: 200 additions & 16 deletions docs/SERVICE.md

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,29 @@ names ADR 0019 declared and nobody built. Also not moved: the store key's own re

## Amendments

- **2026-11-22, the host key provider's files get a custody directory of their own (vault
BACKLOG #3411).** Under `[store].key_provider = 'host'` the service's first start writes its own
key file, `master.key`, beside the `handoff.key` an administrator's `provision-admin
--service-account` left. Neither the installer nor the engine guarantees the service read only
on this directory ([SERVICE.md, The custody directory under the host key
provider](../SERVICE.md#the-custody-directory-under-the-host-key-provider) says which grants
survive a rerun); decision 4's check passes a directory one named account may write. A service right to add a
file here would let it supply a secret-class setting. So those two files move to a directory of their own when
`MEFOR_CUSTODY_DIRECTORY` names one, an absolute path, which wins over `MEFOR_SECRETS_DIRECTORY`
for them; unset, they stay where they were, in this directory or beside a SQLite store. Before
a read or a mint, the engine applies decision 4's check to the directory that variable names,
`broad_access_problem` with `directory`, at every enforcement setting; like decision 4's check,
it reads known broad groups only, so it refuses no entry for one account, the service's add-file
right included. While the variable is set and neither file is in that directory, a host file or
handoff in this directory or beside a SQLite store refuses a read and a mint, so one made
without the variable is not taken for no key; and the check that refuses another key provider
beside a host file or handoff looks in at least the custody directory, this directory and the
place beside a SQLite store, whatever is set. Its refusal deletes no file it finds and moves
none, and points at the one procedure in docs/SERVICE.md that says when a key file may move.
`install-service.ps1` makes the custody directory only when it reads that provider, and names
it to the service as `MEFOR_CUSTODY_DIRECTORY`. docs/SERVICE.md, *The custody directory under
the host key provider*, states its location, its access list and the rest, and is the record
of them.
- **2026-11-17, the Windows holder is read where the path resolves to (vault BACKLOG #5657).**
This replaces parts of the 2026-11-13 amendment below. `_windows_surroundings_problem` still
walks `full.parent`, except for a drive root such as `S:\`, whose own path it walks, so a
Expand Down
32 changes: 23 additions & 9 deletions messagefoundry/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10592,13 +10592,17 @@ async def server_store_found() -> Literal["none", "empty", "held"]:
# On a server the probe refused only a store with a genesis record or with data.
held = "exists" if settings.store.backend is StoreBackend.SQLITE else "holds data"
step = keep_the_key_step(
settings.store, new_store=True, service_account=args.service_account
settings.store,
new_store=True,
service_account=args.service_account,
key_file_left=False,
)
raise HostCustodyRefused(
f"the store already {held}, and {missing}. A new key cannot open a store "
"another key made: run with the custody directory that holds the store's host "
"blob, MEFOR_SECRETS_DIRECTORY set as the store's service has it, or unset for "
"a SQLite store whose blob sits beside its file. If that blob is lost, the "
"blob, MEFOR_CUSTODY_DIRECTORY and MEFOR_SECRETS_DIRECTORY set as the store's "
"service has them, or both unset for a SQLite store whose blob sits beside "
"its file. If that blob is lost, the "
f"store stays in place. {step}"
) from missing
absent, exists = True, None
Expand Down Expand Up @@ -10926,13 +10930,23 @@ def refused_write(exc: Exception) -> int:
# named as a literal: this text reaches stderr (keep_the_key_step says why).
import os

from messagefoundry.engine_secrets import SECRETS_DIRECTORY_VARIABLE

where = (
f"MEFOR_SECRETS_DIRECTORY set to {minted.path.parent}"
if os.environ.get(SECRETS_DIRECTORY_VARIABLE, "").strip()
else "MEFOR_SECRETS_DIRECTORY unset, so that it looks beside the SQLite store file"
from messagefoundry.engine_secrets import (
CUSTODY_DIRECTORY_VARIABLE,
SECRETS_DIRECTORY_VARIABLE,
)

if os.environ.get(CUSTODY_DIRECTORY_VARIABLE, "").strip():
where = f"MEFOR_CUSTODY_DIRECTORY set to {minted.path.parent}"
elif os.environ.get(SECRETS_DIRECTORY_VARIABLE, "").strip():
where = (
f"MEFOR_SECRETS_DIRECTORY set to {minted.path.parent}, with "
"MEFOR_CUSTODY_DIRECTORY unset"
)
else:
where = (
"MEFOR_CUSTODY_DIRECTORY and MEFOR_SECRETS_DIRECTORY unset, so that it looks "
"beside the SQLite store file"
)
print(
f"The store key was written to {minted.path}. The service looks for it in the custody "
f"directory its own environment names; here that came from {where}. A service whose "
Expand Down
14 changes: 12 additions & 2 deletions messagefoundry/engine_secrets.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,12 @@
UTF-8, or one over :data:`MAX_FILE_BYTES`.
* **The store key is not read from here as a setting.** A file named for the store key, or for its
retired keys, is refused. The key custody host blob and its handoff (:data:`CUSTODY_FILE_NAMES`)
may sit here, and the listing passes over them: the ``host`` key provider reads them itself
(:mod:`messagefoundry.store.custody_host`, vault BACKLOG #3411), checking each as a key file.
may sit here, and the listing passes over them: with :data:`CUSTODY_DIRECTORY_VARIABLE` unset,
the ``host`` key provider reads them itself (:mod:`messagefoundry.store.custody_host`, vault
BACKLOG #3411), checking each as a key file. With it set, the provider reads them in the
directory that variable names instead, and a key file left here is not checked as one: its
name alone refuses another key provider, and a read or a mint while that directory holds
neither file.

**What this slice does not do**, at least: refuse a secret found in the environment (slice B
later made the NSSM reading in :mod:`messagefoundry.serviceenv` refuse one in the service's own
Expand All @@ -50,6 +54,7 @@
from typing import Final

__all__ = [
"CUSTODY_DIRECTORY_VARIABLE",
"CUSTODY_FILE_NAMES",
"DIRECTORY_SETTING_NAMES",
"KEY_CLASS_NAMES",
Expand Down Expand Up @@ -103,6 +108,11 @@
#: in this directory when it is set, so the listing passes over them.
CUSTODY_FILE_NAMES: Final[tuple[str, str]] = ("master.key", "handoff.key")

#: The variable that names a custody directory of its own for those two files (vault BACKLOG
#: #3411, ADR 0214's 2026-11-22 amendment). Set, it wins over this directory for them. A path, not
#: a secret.
CUSTODY_DIRECTORY_VARIABLE: Final = "MEFOR_CUSTODY_DIRECTORY"

#: The prefix of an ``env()`` value's variable, ``MEFOR_VALUE_<KEY>``. A file in the directory with
#: this prefix supplies that value. ``config.environments.VALUE_ENV_PREFIX`` is this constant.
VALUE_PREFIX: Final = "MEFOR_VALUE_"
Expand Down
Loading
Loading