Repository navigation
feat(store): fetch secrets with bws and bw - #50
Merged
Merged
Conversation
Run Bitwarden's own programs by absolute path, with a minimal environment, a timeout and capped output; read only the needed field; never log a value. Closes #8
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
internal/storefetches a secret after an approval, by running Bitwarden's own command-line programs. nodkey does not link the Bitwarden SDK.bws(Bitwarden Secrets Manager):bws secret get <id> --output json --color no. The access token is only inBWS_ACCESS_TOKEN, never in the arguments. Onlyvalueis read, and the answer'sidmust be the asked one.bw(Bitwarden Password Manager, with a separate account): unlock at start with--passwordfile(the password never passes through nodkey), keep the session key in memory and pass it only asBW_SESSION,bw sync --forcebefore each fetch,bw get item. Onlylogin.passwordis read; an item in the trash or archived is refused. Ifbwis logged out, deny; if it is locked, unlock again on the next request.HOME, a fixedPATH(forbw) and the one secret variable, a timeout, capped output, stdout never logged, stderr never read, and the whole process group killed after each run. A program dies with the broker. Each store has its own private home (0700).PATHdirectories, nobw-datadirectory next tobwornode, the password file's size and type.Valuetype that hides itself in every print and log form, and can be cleared. A strict JSON reader refuses repeated keys, keys in another case, invalid UTF-8 and NUL bytes.Docs
Review
Three rounds with the security-reviewer agent; the last said "ready to commit". The CLI behaviour comes from reading the source of
bws2.1.0 andbw2026.9.1; neither program was run.Fixed on the way:
bw sync --force: without it,bwtrusts the broker's clock and could keep handing out an item that was moved to the trash;bwgets a narrow fixedPATH; each directory and eachnodein it get the same check as a store program (config.CheckProgram, now exported);bw-datadirectory next tobwornodeis refused (bwwould keep its state there, outside the private home);idmust match; NUL bytes and archived items are refused; the password file's size is checked;Left for later issues: #11 (the broker sets its own core-dump limit, checks files before
New, fetches only after the decision is on disk), #16 (install, login and the example unit).Closes #8