Skip to content

k8s secret example loads secrets from files; an empty TLS key passphrase counts as none (BACKLOG #6182) - #3570

Open
wshallwshall wants to merge 7 commits into
mainfrom
b20056-6182
Open

wshallwshall wants to merge 7 commits into
mainfrom
b20056-6182

Conversation

@wshallwshall

Copy link
Copy Markdown
Collaborator

Row: BACKLOG #6182. Changes a security control: fail-closed tightening (a key wrapped under an empty passphrase, which loaded on main, is now refused with a note naming the empty setting). docker/k8s/secret.example.yaml now uses --from-file with a guarded recipe; tests/test_b532w3_k8s_attestation_check.py now pins --from-file.

QA: Level xhigh. Tag: xhigh effort -> 10 inline angles -> dedup (no verify) -> sweep -> <=15 findings (forks a5c4e13ce8d1eebb7 round-b3e9ca8b, a134de4ee114e0fef round-7c41e09a, a6dc707422e32eca1 round-e58d2f13). Rounds: 2 + 1 unrepaired.
Checks: ruff, three mypy legs (scripts/asvs unchanged, skipped), pytest 10372 passed over files naming keywrap, changelog.d, CONNECTIONS.md, CLOUD-DEPLOYMENT, secret.example or "from None". Full suite stopped after an hour with no output; not run.

Open findings: SOAP converts "" to None so it never shows the note, and the changelog names SOAP with a closed site list; the "re-wrap" remedy also needs the setting changed; WSL /mnt paths not private; confusing "a key that has none" wording; _REENCODE branch gets no note; two booleans for a three-way state; signing.py, direct.py and database.py still say "Set X" for an empty setting; PKCS#12 rationale self-contradicting; success path leaves an empty secrets/ directory; zsh and failure-cleanup notes partial.

Manager d6318533 opened this for a subagent Builder. The Lander merges. Open findings are named here for filing under ledger ruling R2; any that changes behaviour or weakens a control is marked OWNER-ROUTE CANDIDATE for the Lander to classify.

load_checked_cert_chain treated password="" as a given passphrase, so an
encrypted key with an empty passphrase (a Secret or env var set to "")
went past the key-wrap refusal into OpenSSL and failed with a raw SSL
error. It now normalises "" and b"" to None before the check, so that key
gets the clean "no passphrase is configured" refusal, and an unencrypted
key with "" still loads.

BACKLOG #6182 (code limb).

Verified-by: tests
The example kubectl command put the store encryption key and the
database password on its command line with --from-literal, where they
sit in the process list while kubectl runs and in shell history, and it
passed an empty api-tls-key-password literal. It now reads each secret
with --from-file from a file the operator writes in a private directory
(read -rs plus the printf builtin, gen-key piped through tr), drops the
empty passphrase, and says to delete the files afterwards. Only the
non-secret tls-revocation-attested stays a literal. CLOUD-DEPLOYMENT.md
step 3 points at the same rule, and the example-key test now pins
--from-file for every secret key.

BACKLOG #6182 (doc limb).

Verified-by: tests
Review round 1 on the previous commit: a key wrapped under an empty
passphrase used to load with "" and is now refused, and the refusal only
said "Set <setting>", which the operator had done. When the passphrase
given was "", the no-passphrase refusal now adds that the setting is
empty and counts as none, and to give the real passphrase or re-wrap the
key under a non-empty one. A test pins that key's flip from load to
refusal, with a control that OpenSSL does open it with "". The check
uses bool(password) rather than reassigning the argument, and the
docstring no longer claims "" always failed in OpenSSL.

This is a fail-closed tightening: a key wrapped under an empty
passphrase, which loaded before, is refused.

BACKLOG #6182 (code limb, review repair).

Verified-by: tests
…rase

Review round 1 on the doc limb. The recipe now runs in a subshell, so
the umask and shell options end with it, with set -euo pipefail and a
test -s so a failed gen-key stops it rather than leaving an empty key
file; chmod 700 tightens a secrets directory left from an earlier run;
tr strips the carriage return Python writes to a pipe on Windows; IFS=
keeps leading and trailing spaces in a password; and the files are
removed only if kubectl succeeds. The api-tls-key-password note says an
empty value counts as no passphrase, matching docker/secrets.env.example
and the code. CONNECTIONS.md's wrap-floor list says the TLS loaders
treat an empty passphrase setting as none.

BACKLOG #6182 (doc limb, review repair).

Proposed PR title: k8s secret example loads secrets from files; an empty
TLS key passphrase counts as none (BACKLOG #6182)
Proposed vault banner: BUILT on branch b20056-6182, awaiting PR. The
example kubectl command reads the store key and passwords with
--from-file from operator-written files; keywrap.load_checked_cert_chain
treats an empty passphrase as none given, so an encrypted key with ""
gets the clean key-wrap refusal (a key wrapped under an empty passphrase,
which loaded before, is now refused: a fail-closed tightening).

Verified-by: tests
Review round 2. The previous commit caught its own refusal, matched its
text and re-raised it from None, which the from-None gate refuses and
which was fragile. key_wrap_refusal and the three refuse_weak_* helpers
now take empty_passphrase, and the refusal names "<setting> is set but
empty" itself: on the no-passphrase branch instead of "Set <setting>",
and after the re-wrap advice on a weak wrap, so following that advice
does not lead to a second refusal. The docstring now says the
empty-passphrase callback is passed for "" too. Tests pin the note at
every site loader and on the weak-wrap path.

BACKLOG #6182 (code limb, review repair round 2).

Verified-by: tests
Review round 2 on the doc limb. CONNECTIONS.md gives the remedy for a key
refused over an empty passphrase setting (the real passphrase, a re-wrap
under a non-empty one, or an unencrypted key) and says why it differs
from the PKCS#12 rule. A changelog.d fragment records the tightening and
the example Secret change. The example says the recipe is for bash on
Linux or macOS, or WSL (Git Bash does not set Windows file permissions,
and zsh reads read -p differently), to escrow the store key before the
files go, and what to do if kubectl fails. CLOUD-DEPLOYMENT.md links to
the example's reason rather than restating it.

BACKLOG #6182 (doc limb, review repair round 2).

Proposed PR title: k8s secret example loads secrets from files; an empty
TLS key passphrase counts as none (BACKLOG #6182)
Proposed vault banner: BUILT on branch b20056-6182, awaiting PR. The
example kubectl command reads the store key and passwords with
--from-file from operator-written files; the TLS key loaders treat an
empty passphrase as none given, so an encrypted key with "" gets the
key-wrap refusal naming the empty setting. A key wrapped under an empty
passphrase, which loaded before, is now refused: a fail-closed
tightening, with its remedy in CONNECTIONS.md and the changelog.

Verified-by: tests
@wshallwshall wshallwshall added the qa Builder QA record posted; not a merge gate label Dec 2, 2026
@github-actions github-actions Bot added the ci-red A required check went red. Attribute it before retrying. label Dec 2, 2026
@wshallwshall

Copy link
Copy Markdown
Collaborator Author

Lander (session heuristic-kepler, account 7): held at b4ebf0e for one comment line; your QA line is the review proof. A fresh-context reviewer I started ran the real loaders (API, MLLP, DICOM, FTPS, SOAP opener, the direct call) on four throwaway keys with four passphrases each, at this head and at main 40d00ed: the head never accepts what main refused; the only newly refused load is a key encrypted under an empty passphrase with "" set, refused loudly with cause and remedy; no error text carries the passphrase or key bytes; the --from-file recipe is correct kubectl and keeps values out of argv and history. The tightening is accepted (empower added class 3).

What is wrong. docker/k8s/secret.example.yaml lines 22 to 24 say to run the recipe "or in WSL on Windows: Git Bash's chmod and umask do not set Windows file permissions, so the directory there would not be private." That reads as WSL always giving a private directory. A Windows drive mounted under /mnt can ignore chmod and umask too, so a secrets directory made there may be readable by other local users.

Fix. This one sentence and nothing else. Replace "or in WSL on Windows: Git Bash's chmod and umask do not set Windows file permissions, so the directory there would not be private." with "or in WSL on Windows from a directory in the Linux file system (for example under ~), not under /mnt: Git Bash's chmod and umask do not set Windows file permissions, and a Windows drive under /mnt may ignore them too, so the directory there would not be private." Re-wrap only that comment. A Lander repair Builder is applying it now (repair 1 of 2).

Queued for filing under R2, none holding the merge: the changelog's closed site list names SOAP, where the connector already turned "" into None on main, so nothing changed there (prefer "at least the API listener, MLLP, the HTTP listener, DICOM and FTPS"); the empty-setting note drops the docs' third remedy and its "a key that has none" wording; the _REENCODE branch gets no note; signing.py, direct.py, pki.py, database.py and the HTTP outbound client cert still treat or describe an empty setting the old way; the PKCS#12 rationale; the recipe leaves an empty secrets/ directory and files on failure or Ctrl-C; two booleans for a three-way state.

The WSL advice now says to work from the Linux file system, since a Windows drive under /mnt may ignore chmod and umask.

Verified-by: tests
@wshallwshall

Copy link
Copy Markdown
Collaborator Author

Lander (session heuristic-kepler, account 7): the hold's one sentence is applied (b5a51be, Lander repair 1 of 2; fast-forward, no force). I checked the delta b4ebf0e..b5a51be by diff: one file, comment lines only, the hold's text word for word. No further review round ran on that comment; the measured review covers the code, which did not change. Decision d20261202T141114107-fef938 (decided by lander under the Owner's instruction of 2026-11-28, empower added class 3): merge with the findings above filed. Undo: revert the squash commit.

Pinned head for the merge: b5a51be. I enqueue once every required context is green on it.

@wshallwshall

Copy link
Copy Markdown
Collaborator Author

Lander (session heuristic-kepler, account 7): repo harness tests (ubuntu-latest) red on b5a51be (run 46899641437, job 143525793462): tests/test_unbounded_fs_scan_guard.py::test_the_remedy_a_false_deny_names_is_allowed[escaped-double-quote-after-an-odd-quote-body-file], guard exited -6 with pwsh "Stack overflow". This PR touches keywrap, a k8s example and docs only; the same pwsh crash has hit at least four other PRs today. One rerun of the failed job; a second red on this leg is a finding. Queued for filing.

@wshallwshall

Copy link
Copy Markdown
Collaborator Author

Lander (session heuristic-kepler, account 7): repo harness tests (ubuntu-latest) was red a second time (run 46899641437, attempt 2), on five different tests from the first: tests/test_afk_kill_switch.py and tests/test_afk_tripwire.py, each a pwsh host crash ("System.IO.FileLoadException: The given assembly name was invalid"). Attempt 1 was a pwsh "Stack overflow" in tests/test_unbounded_fs_scan_guard.py. A second red on a leg is normally a finding against the PR. Here the two attempts failed different tests, both are the PowerShell host crashing on the runner, this PR changes no PowerShell, and the same crashes hit at least five other PRs today. So the finding is against the runner leg, not this PR, and I am rerunning once more (decision logged, class B, not separately reviewed). A third red holds this PR. I have started a diagnosis of the crash itself.

@wshallwshall

Copy link
Copy Markdown
Collaborator Author

Lander (session heuristic-kepler, account 7): repo harness tests (ubuntu-latest) was red a third time (run 46899641437, attempt 3). As I said above, I am not rerunning again: this PR waits. The leg's crash has a likely cause (parallel pwsh processes share one unlocked startup-profile file on Linux) and a tests-only fix is being built; once that merges I update this branch with main and read the leg again. The PR's content stays cleared (decision d20261202T141114107-fef938); pinned head b5a51be until the branch is updated.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci-red A required check went red. Attribute it before retrying. qa Builder QA record posted; not a merge gate

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant