Repository navigation
Description
Why
RouterOS /app (7.23+) delivers secrets as files: an app-level secrets: entry, listed under a service, appears at /run/secrets/<name>. Docker and Podman secrets work the same way. That is safer than an env value. On RouterOS, an expanded [secret:…] env value is copied into the derived /container entry's env, where a read,!sensitive user can see it and a plain /export prints it (the #542 territory). A file stays out of RouterOS config and export.
Today centrs accepts the CDB key only from --cdb-password or CENTRS_CDB_PASSWORD, and a target password only from the flag, the env or the CDB. devices add/set adds --password-stdin (#582). Inside a container, that leaves two bad choices: plumb the secret into env, or have every agent run CENTRS_CDB_PASSWORD=$(cat /run/secrets/…) centrs ….
Measured for tikoci/app-t3code#47 (research, PR tikoci/app-t3code#73, CHR 7.25.2 x86, centrs 0.2.0-next):
centrs devices init --encryptkeyed from/run/secrets/routeros_pwcreates/data/.config/tikoci/winbox.cdb(0600, no plaintext).__default__isadminwith an empty password, plus a gateway record.retrievethen works with every sourcecdb, and fails closed without the key (cdb/password-required).- A router-side
/user/add name=t3code group=<ro> password=[/file/get …/secret-routeros_pw contents]turns the same generated value into a dedicated account. centrs read through the CDB as that user, and RouterOS refused a write. So one file served as both the CDB key and the account password.
The only missing piece is getting the key to each centrs process without env. This scheme isn't app-t3code-specific: any centrs in a RouterOS /app or Docker container has /run/secrets.
Proposal
CENTRS_CDB_PASSWORD_FILE/--cdb-password-file <path>: read the CDB key from a file, stripping one trailing newline (as--password-stdindoes). Also forcentrs mcp.CENTRS_PASSWORD_FILE/--password-file <path>for the target password, for parity. app-t3code may not use it, but the pair should match.devices add|set --password-file <path>: the record password from a file. Optionally remove the file after a successful write, for T3 Code's secret cards: T3 delivers a value the user typed to an owner-only file that lasts about 24 h. An agent could thendevices add <router> --user u --password-file <path>, and the plaintext wouldn't outlive the import. T3's multi-field cards write one file per field, so a whole-record-from-file form is a possible follow-up, not part of this.
Rules to settle (constitution)
- Setting both
XandX_FILE(or the flag and its file form) is a usage error, not a silent precedence. meta.settingsreports the source as a file (the env key or the flag), never the contents. Errors name the path, not the value.centrs.envstill never carries credentials. Whether it may carry a*_FILEpath (a pointer, not a secret) is a decision to make here.- The constitution's credential rules (the CDB is the credential store;
CENTRS_CDB_PASSWORDnever comes fromcentrs.envor a file) give way for an explicit path the caller names. The reason for the old rule, a decrypt password persisted beside the CDB, doesn't apply to/run/secrets.
Filed from app-t3code#47 at the owner's request.
Activity
mobileskyfi commentedon Nov 25, 2026
Correction to item 3, from the review of tikoci/app-t3code#73 (checked against T3 v0.1.12
apps/server/src/secrets/SecretRequests.ts). T3 writes a card's typed value to its plaintext secret store first, then moves it to an owner-only file under<T3 state>/secrets/files. It sweeps those files by mtime at startup and then hourly. So--password-filewith remove-after shortens how long the plaintext stays on the container's persistent volume; it doesn't avoid it. Items 1 and 2 (/run/secrets) are unaffected.mobileskyfi commentedon Nov 25, 2026
Triage. Reviewer: claude-code/claude-opus-5-5 · head 3cf57ae (main) · session t3code thread c4f35b6a-f56e-4cad-b640-9060ce54d101
Fit. This is option (a) of #603, which the Auth and secrets theme already plans. The theme's long-term shape is three sources per secret: a value, a file, and later a password command or keychain helper. Built as below, #672 needs no rework when the command form lands. It goes on the current track so app-t3code can try it in a
nextrelease.Scope, as settled with the maintainer:
--cdb-password-file/CENTRS_CDB_PASSWORD_FILE, includingcentrs mcp.--password-file/CENTRS_PASSWORD_FILEfor the target password.devices add|set --password-stdin < <path>already reads a record password from a file (devices set/add record password needs a non-argv channel (env/stdin) #582). Removing the file after import only shortens how long the plaintext stays on disk, since T3 has already stored the value; that cleanup is T3 Code's job. centrs never deletes a file the caller gave it, which would also fail on a read-only/run/secretsmount.Implementation rules:
CENTRS_CDB_PASSWORDis read separately today insrc/devices.ts,src/mcp/config.ts,src/resolver/selection.ts,src/resolver/cdb.tsandsrc/resolver/settings.ts. Resolve value-or-file once and return{ value, source }, shared by CLI, MCP and the library. The later_COMMANDform then becomes one more case in it.usage/conflicting-flags.mcp/config.tscurrently keeps the password for the life of the process. Reading per load lets rotating or deleting the file take effect at the next call, which is MCP/CDB: unlock-password channel for hosts that don't pass env (password command or file, fetched per load) #603's lock behaviour.cdb/password-unavailable(MCP/CDB: unlock-password channel for hosts that don't pass env (password command or file, fetched per load) #603's code); no source configured stayscdb/password-required. Errors name the path, never the contents. On MCP the fix text tells the operator to configure the server's password source and never invites the agent to ask the user for the password.--password-stdinuses (readPasswordStdin), so the two can't drift apart.meta.settingsreports{ kind: "file", key }(the env key or the flag). It may show the path and never shows the value.*_FILEincentrs.envor any workspace file. Only a flag or the process environment may name the path. Otherwise a cloned workspace could pointCENTRS_PASSWORD_FILEat~/.ssh/id_ed25519and, through its own CDB record, send that file to a host it chose. In a container,/appYAMLenvironment:carries the path, which is enough. Add the*_FILEkeys to the listsettingsrefuses to write and to the keys thecentrs.envreader ignores, next toCENTRS_CDB_PASSWORD. This rule is also why Read passwords from files: CENTRS_CDB_PASSWORD_FILE, CENTRS_PASSWORD_FILE and --*-file (container /run/secrets) #672 can go ahead of the theme's workspace gate./run/secretsvary, and on RouterOS they don't mean anything, so a group- or world-readable file is accepted without a warning.Docs. Using one generated value as both the CDB key and the RouterOS account password suits app-t3code, but centrs docs shouldn't present it as the recommended pattern.
Acceptance.
examples.mdentries for both forms. A unit test proves file contents never appear in an envelope. CHR integration runsretrievekeyed from a file. #603's stdio MCP checks run on an encrypted throwaway fixture: no password in argv or env; deleting the file makes the next call returncdb/password-unavailablewithout crashing.Matrix change: tikoci/centrs PR on branch
docs/matrix-672-password-files.mobileskyfi commentedon Nov 25, 2026
Alignment review from the app-t3code side, against the triage above. Reviewer: claude-code/claude-opus-5-5, cross-checked with tikoci/app-t3code#73 at
a41224e, which now matches this scope.Agreed as triaged: items 1 and 2, dropping item 3 (
--password-stdin < <file>covers the import; app-t3code's recipe or T3's sweep deletes the file), one resolver, the conflict rule, re-reading on each CDB load,cdb/password-unavailable, no permission check, and not documenting one value for both the CDB key and a router password as the recommended pattern. In a RouterOS container, the/appYAMLenvironment:and the imageENVare process environment, so the "flag or process env only" rule works for app-t3code.Three things to settle before building:
centrsis#!/usr/bin/env bun(still true at3cf57ae), and Bun loads the working directory's.envintoprocess.env. So a cloned workspace's.envwithCENTRS_PASSWORD_FILE=~/.ssh/id_ed25519looks like process environment to centrs. That is the exact~/.sshcase the triage uses to keep*_FILEout ofcentrs.envand workspace files. Suggest making Installed centrs reads CENTRS_* from the working directory's .env (Bun auto-load) #666 a prerequisite of Read passwords from files: CENTRS_CDB_PASSWORD_FILE, CENTRS_PASSWORD_FILE and --*-file (container /run/secrets) #672, or fixing them together; how the auto-load gets turned off is Installed centrs reads CENTRS_* from the working directory's .env (Bun auto-load) #666's call. In app-t3code, agents work inside cloned repos all the time, so this is the usual case, not an edge case.environment:key is also an imageENVdefault. SoCENTRS_CDB_PASSWORD_FILE=/run/secrets/<name>would be set on every run, including Docker without that secret and a first start before any CDB exists. If centrs returnscdb/password-unavailablewhenever the variable is set and the file is missing, plain use breaks there. Suggestion: it's an error only when the key is actually needed (loading an encrypted CDB, orinit --encrypt); otherwise a warning, like today's unused---cdb-passwordwarning. Either way, app-t3code needs to know which behavior to design for.CENTRS_PASSWORD_FILEin a container env replaces every record's password. The env tier outranks CDB records (args → env → record →__default__), asCENTRS_PASSWORDdoes today. That's correct behavior, but a container that sets it globally makes the CDB's per-router passwords useless. Worth one sentence in theexamples.mdentry: set it per invocation, or keep router passwords in the CDB. app-t3code won't set it in the container env (recorded in test(ci): green the windows-latest unit tier — SO_REUSEPORT skip + null-sink/basename portability (#69) #73).app-t3code's open choice of one app secret or two (CDB key and account password) is on our side and doesn't affect this issue.
docs(matrix): make #666 a prerequisite of password files (#672)
mobileskyfi commentedon Nov 26, 2026
Settling the three points from the app-t3code review. Reviewer: claude-code/claude-opus-5-5 · head ccee2ff (PR #673) · session t3code thread c4f35b6a-f56e-4cad-b640-9060ce54d101
Installed centrs reads CENTRS_* from the working directory's .env (Bun auto-load) #666 is a prerequisite. The "flag or process environment only" rule doesn't hold while Bun loads a cloned repo's
.envintoprocess.env. Installed centrs reads CENTRS_* from the working directory's .env (Bun auto-load) #666 lands first, or in the same PR as this. The matrix track item (PR docs(matrix): put password files (#672) on the current track #673) now says so. I've added a note on Installed centrs reads CENTRS_* from the working directory's .env (Bun auto-load) #666 aboutenv -Sin a container base image.A key file that is missing when no key is needed is a warning, not an error. The file is read only when a key is actually needed:
devices init --encrypt;devices add-encryption.cdb/password-unavailablecdb/password-not-neededwarning, as for an unused--cdb-passwordFor the missing-file warning, either reuse
cdb/password-not-neededwith the path in its context or add a sibling code; that's the implementer's choice, recorded in the errors catalog either way. A file alone never converts an open CDB, the same rule as for a password value today. This makes an image-wideCENTRS_CDB_PASSWORD_FILEdefault safe on plain Docker and on a first start.CENTRS_PASSWORD_FILEoutranks CDB records. This follows the normal order (args → env → record →__default__), asCENTRS_PASSWORDdoes today. If it is set but the file is missing, resolving a target password is an error (usage/cdb/password-unavailable, whichever the shared resolver settles on). It never quietly falls back to the record. Theexamples.mdentry says to set it per invocation, or to keep router passwords in the CDB, and not to set it in a container-wide env.Acceptance gains two checks: a set-but-missing
CENTRS_CDB_PASSWORD_FILEwith an open or absent CDB gives a warning andok:true; and a working-directory.envthat setsCENTRS_PASSWORD_FILEhas no effect (covered by #666's test).mobileskyfi commentedon Nov 26, 2026
Maintainer confirmed points 1–3 above. One addition for app-t3code, on point 3: the maintainer leans toward app-t3code using its own environment names for router credentials (not
CENTRS_*), with itst3app initwriting them into the CDB's__default__record. Router credentials then live in the CDB like any other, and nothing in the container environment outranks the records. This is app-t3code's design and doesn't change this issue's scope.On #666 (the prerequisite): the proposed
env -Sshebang fails on BusyBox (v1.36 to v1.38, Alpine andoven/bun:alpine), so #666 now suggests filtering the.envkeys inside centrs instead. Details on #666.Reviewer: claude-code/claude-opus-5-5 · session t3code thread c4f35b6a-f56e-4cad-b640-9060ce54d101
docs(matrix): put password files (#672) on the current track (#673)
fix: Codex follow-up review on PR #674
Password files (#672), with the working-directory .env guard (#666) (#…
docs: align README, SECURITY and CHANGELOG for the first 0.2.0-next (#…