Secret files: harden the open-recording tests and read_secret_file #42
Labels
No labels
boundary:crosses
bug
enhancement
epic
needs-info
needs-triage
ready-for-agent
ready-for-human
svd:go
svd:hold
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
dev/messages-mind-mcp#42
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Two reviews of PR #41 (issue #33, head
269ae77) found no blocker. They found the items below. None of them is a regression from #41.The open-recording tests (
tests/test_config_cli.py)/varagainst/private/var), the recorded string differs fromstr(secret)and the test passes without proving anything. Fix: in the same recording, assert that a file the verb does read (the key file) is recorded.dir_fd, a relative path, a symlink or a..form escapes it. Fix: compareos.path.realpathon both sides, or compare(st_dev, st_ino).openevent. Say "opens made in Python" in the invariant, or add a check that covers those opens.sync.py:252-254(aNonesalt). Only mypy covers it. Add a test:sync_oncewithsalt=Noneprintssecret=error code=secret-missing at=store.tombstone_salt_fileand returns 2.read_secret_file(src/messages_mind_mcp/kit/secrets.py:21), from before #41os.openhas noO_NOFOLLOW, so a secret path that is a symlink is followed.st_uid == os.geteuid()). A process that runs as root accepts a0600file that another user owns.os.openhas noO_NONBLOCK. A FIFO at a secret path blocks the open before the regular-file check runs.Fix sketch: open with
O_RDONLY | O_NOFOLLOW | O_NONBLOCK | O_CLOEXEC, then checkS_ISREG, the mode and the owner on the descriptor.Documents
apiverb line say "never". Add one sentence under the table that points to the caveat inSECURITY.md: this is what the code does, not a permission boundary.apistill stops withsecret-dir-unlistable. This fails closed, but the README does not say it.tombstone_salt_fileis required in every config, so a host that runs onlyapimust still hold the salt file forcheckto pass. Least privilege holds per process, not per host. Decide whether the salt becomes optional on a host with nosync, or whetherchecktakes a verb.Decisions
checktakes an optional verb (apiorsync) and opens only the secret files of that verb, fromstartup.SECRET_FILE_VERBS. Without a verb,checkopens every secret file that the config names, as today. The config schema does not change.Acceptance criteria
read_secret_filerefuses a symlink, a FIFO and a file that another user owns. A test proves each refusal.syncguard for aNonesalt.SECURITY.mdstate items 3, 8 and 9.checkwith a verb opens only the secret files of that verb. A test proves it for each verb.Human act
ruling: the operator sets
svd:goto approve dispatch of this credential-path change (CONV-40)Blocked by
Filed under: operator word "Grant" sha256:78b7d0379d5e
Triage
main:read_secret_fileopens withoutO_NOFOLLOWorO_NONBLOCK, and it does not check the file owner.Blocked by #33edge is removed: #33 closed when #41 merged.checktakes a verb. The body records it under## Decisions. Option (b), an optional salt, would change the config schema; (a) is additive.ready-for-human. The human act is the operator's dispatch approval (svd:go).Brief
Category: bug
Summary:
read_secret_filerefuses a symlink, a FIFO and a file that another user owns; the open-recording tests prove what they claim;checktakes a verb.Why a human gates it: the change is on the path that reads every secret file. The design is settled; the operator approves the dispatch.
Current behavior:
read_secret_filefollows a symlink, blocks on a FIFO before its regular-file check, and accepts an owner-only file that another user owns./varagainst/private/var) makes them pass without proof.checkopens every secret file that the config names, so a host that runs onlyapimust hold the salt file.Desired behavior:
read_secret_fileopens withO_RDONLY | O_NOFOLLOW | O_NONBLOCK | O_CLOEXEC. On the descriptor it checksS_ISREG, the owner-only mode, andst_uid == os.geteuid(). Each refusal has a coded error.syncguard for aNonesalt: the output issecret=error code=secret-missing at=store.tombstone_salt_fileand the status is2.check apiandcheck syncopen only the secret files of that verb.checkwithout a verb keeps today's behavior.SECURITY.mdstate items 3, 8 and 9 of the body.Key interfaces:
read_secret_filein the Kit secrets module, and its error codes.startup.SECRET_FILE_VERBS, the map from a verb to its secret files.checkverb of the CLI.Acceptance criteria: the list in the body.
Out of scope:
check apiin the api container without the salt.