You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
bitwarden-load-secrets: multiline values are split into bogus variables #5650
bitwarden-load-secrets.sh stores secret records in a newline-delimited PAIRS string (lib/bitwarden-load-secrets.sh:185-196). The BWS and Vault loaders emit raw jq values into tab/newline-delimited records (:223-225, :271-273), and each output mode later reads PAIRS one line at a time (:304-310, :315-320, :323-329). A newline inside a legitimate secret therefore becomes another record instead of remaining part of that secret.
Reproduced with a stub bws returning TLS_CERT = "BEGIN CERT\\nPRIVATE KEY\\nEND CERT": --format json produced TLS_CERT: "BEGIN CERT", plus bogus empty PRIVATE_KEY and END_CERT entries. The script documents direct CLI and sourced use (:5-8, :110-113); no in-repository callers or tests were found.
Why it matters
Multiline values such as private keys and certificates are silently truncated, so consumers receive invalid credentials; continuation text is also exposed as unintended environment-variable names in source/export modes. This is a functional defect in the loader's documented use.
Suggested fix
Keep key/value pairs in a representation that preserves newlines (rather than embedding raw values in a newline-delimited string), and add regression coverage for multiline values across the supported output formats. Shell output values are currently quoted; this finding is about record corruption, not a demonstrated shell-injection path.
Triage outcome — task 10098 (2026-11-05, lane code-p)
Verdict: CONFIRMED on current main — reproduced exactly as filed; fix path scoped, follow-up fix task enqueued.
Fresh verification (2026-11-05): issue #5650 OPEN, labels kind/bug, task/triage, area/infra, effort/s — no held / user/owned / do-not-merge / do-not-auto-edit labels. No competing or duplicate work: no open PR touches lib/bitwarden-load-secrets.sh, an issue search returns only #5650 itself, and git grep on origin/main finds no in-repo callers or tests for the script.
Code read (origin/main 04f78696ab, lib/bitwarden-load-secrets.sh):PAIRS is a newline-delimited KEY<TAB>VALUE string (:185-196, add_pair appends the raw value). The corruption has TWO stages, and a fix must cover both:
Loader stage — the BWS list loader (:223-225) and the Vault custom-fields loader (:271-273) read jq -r output with while IFS=$'\t' read -r k v, one line at a time: a multiline value is already split there, before PAIRS is involved.
Storage/output stage — single-value paths (:215, :247-287) preserve the multiline value into add_pair, but every output mode re-reads PAIRS line-by-line (source :304-310, export :315-320, env :323-329) and json mode splits each input line on tab (:330-338), splitting the value again.
Reproduction (laptop probe ~/git/fleet/probe-5650, real script from laptop main 04f78696ab, stub bws): secret TLS_CERT = "BEGIN CERT\nPRIVATE KEY\nEND CERT" plus a sane PLAIN=hello control —
--bws --format json → TLS_CERT: "BEGIN CERT" plus bogus "PRIVATE_KEY": "" and "END_CERT": "" entries (sanitized from the continuation lines); control intact.
Matches the filing exactly (the filed repro's variable spellings differ only by the sanitizer's space handling).
Fix path (scoped for the follow-up task): give key/value records a newline-safe representation end-to-end — e.g. loaders emit the value base64-encoded (jq @base64) so the read loops never see a raw newline, PAIRS stores the encoded value, and each output mode decodes before quoting/export (json mode decodes so the emitted JSON carries the true multiline string). Any representation with the same property is acceptable; patching only the output readers is NOT sufficient (stage 1 above). Regression coverage: a stub-bws test with a multiline value plus a sane control, asserted across json/export/env (and source-mode variable values), failing pre-fix and passing post-fix. No in-repo callers or existing tests constrain the internal representation.
Activity
developing-today commentedon Nov 4, 2026
CODE-1408
dezren39 commentedon Nov 5, 2026
Triage outcome — task 10098 (2026-11-05, lane code-p)
Verdict: CONFIRMED on current main — reproduced exactly as filed; fix path scoped, follow-up fix task enqueued.
Fresh verification (2026-11-05): issue #5650 OPEN, labels kind/bug, task/triage, area/infra, effort/s — no held / user/owned / do-not-merge / do-not-auto-edit labels. No competing or duplicate work: no open PR touches
lib/bitwarden-load-secrets.sh, an issue search returns only #5650 itself, andgit grepon origin/main finds no in-repo callers or tests for the script.Code read (origin/main
04f78696ab,lib/bitwarden-load-secrets.sh):PAIRSis a newline-delimitedKEY<TAB>VALUEstring (:185-196,add_pairappends the raw value). The corruption has TWO stages, and a fix must cover both:jq -routput withwhile IFS=$'\t' read -r k v, one line at a time: a multiline value is already split there, beforePAIRSis involved.add_pair, but every output mode re-readsPAIRSline-by-line (source :304-310, export :315-320, env :323-329) and json mode splits each input line on tab (:330-338), splitting the value again.Reproduction (laptop probe
~/git/fleet/probe-5650, real script from laptop main04f78696ab, stubbws): secretTLS_CERT = "BEGIN CERT\nPRIVATE KEY\nEND CERT"plus a sanePLAIN=hellocontrol —--bws --format json→TLS_CERT: "BEGIN CERT"plus bogus"PRIVATE_KEY": ""and"END_CERT": ""entries (sanitized from the continuation lines); control intact.--bws --format export→export TLS_CERT='BEGIN CERT'plus bogusexport PRIVATE_KEY=/export END_CERT=.Matches the filing exactly (the filed repro's variable spellings differ only by the sanitizer's space handling).
Fix path (scoped for the follow-up task): give key/value records a newline-safe representation end-to-end — e.g. loaders emit the value base64-encoded (
jq @base64) so the read loops never see a raw newline,PAIRSstores the encoded value, and each output mode decodes before quoting/export (json mode decodes so the emitted JSON carries the true multiline string). Any representation with the same property is acceptable; patching only the output readers is NOT sufficient (stage 1 above). Regression coverage: a stub-bwstest with a multiline value plus a sane control, asserted across json/export/env (and source-mode variable values), failing pre-fix and passing post-fix. No in-repo callers or existing tests constrain the internal representation.agent-note:v1
{"kind": "triage", "task": 10098, "issue": 5650, "state": "done", "outcome": "confirmed_reproduced_fix_scoped", "evidence": "main 04f7869; PAIRS newline-delimited at lib/bitwarden-load-secrets.sh:185-196; loader read loops :223-225/:271-273; laptop probe reproduced bogus PRIVATE_KEY/END_CERT in json+export"}
dezren39 commentedon Nov 5, 2026
🤖 Agent note · picked up
Merge pull request #6325 from developing-today/queue/10481-5650-bitwa…
dezren39 commentedon Nov 5, 2026
🤖 Agent note · done
fix(lib): bitwarden-load-secrets validates value options before parsi…