Skip to content

Avoid evaluating Bitwarden secret values as shell code in drain wrapper #12261

Closed

Description

@dezren39

Finding

infra/github-backup/systemd/drain-wrapper.sh:23-35 fetches the Worker URL and bearer from Bitwarden, then runs eval over Python output built with repr():

eval "$(python3 - <<'PY'
...
print(f"export GHB_WORKER_URL={get('github-app.backup-worker-url')!r}")
print(f"export GHB_WORKER_BEARER={get('github-app.backup-worker-bearer')!r}")
PY
)"

Python string repr() is not shell escaping. A value containing both quote types can make the generated shell statement execute injected syntax. This was reproduced in an isolated wrapper harness using fabricated secret data; the command executed with the wrapper's user privileges. The existing wrapper tests (infra/github-backup/tests/test_drain_wrapper.py) exercise only simple values such as https://worker.invalid and stub-bearer, so they miss this boundary case.

Impact

A malicious or accidentally malformed Bitwarden value can execute arbitrary shell commands whenever the systemd drain wrapper runs, before drain_queue.py starts. This affects the host account running the backup service. No real credentials or external services were used in reproduction.

Suggested fix

Do not feed Python repr() output to eval. Pass values to the child process without shell interpretation, or emit values using a shell-specific quoting function and add regression tests containing quotes and shell metacharacters that assert no command execution and exact environment round-tripping.

Related: #12260 (scheduled suggestions pass that found this issue).

Activity

  1. added
    kind/securitySecurity issue or security hardening
    source/queue-workerFiled or worked by the queue/worker pilot
    priority/normalOrdinary priority (the default)
    effort/sSmall: expected under 2 hours of work
    on Nov 21, 2026
  2. developing-today commented on Nov 21, 2026

    @developing-today
    Contributor
  3. added
    mode/onlineFully doable remotely: design, config, code, cloud
    app/github-backupinfra/github-backup estate mirror system
    work/assignedQueue worker lifecycle state
    queue/claimedQueue worker lifecycle state
    on Nov 21, 2026
  4. dezren39 commented on Nov 21, 2026

    @dezren39
    MemberAuthor

    Picked up by scheduled lane oc-code-03 (worker repo-worker-code). Revalidating the reported shell-evaluation issue and routing a bounded fix; triage only, no implementation in this task.

  5. dezren39 commented on Nov 21, 2026

    @dezren39
    MemberAuthor

    Triage verified: the current wrapper still runs Python repr() output through eval. In an isolated temporary harness, a fabricated value containing shell command substitution created a marker file, confirming command execution; no real credentials or external services were used. The existing test suite passes (21 checks) but covers only simple values. Routed the bounded fix to queue task 20935: remove shell interpretation and add a hostile-value round-trip/no-execution regression, scoped to the wrapper and its tests.

  6. 8 remaining items

  7. added
    queue/parkedQueue task is parked (waiting on CI, time, or an event)
    status/parkedDeliberately paused with a recorded resume condition
    on Nov 21, 2026
  8. dezren39 commented on Nov 21, 2026

    @dezren39
    MemberAuthor

    Parked pending CI on PR #12262: CodeRabbit is still in progress (Proof check was skipped). Resume by checking PR checks fresh; merge only after required checks are green. Local targeted test passes 24/24.

  9. added
    queue/claimedQueue worker lifecycle state
    and removed
    status/parkedDeliberately paused with a recorded resume condition
    queue/parkedQueue task is parked (waiting on CI, time, or an event)
    on Nov 21, 2026
  10. dezren39 commented on Nov 21, 2026

    @dezren39
    MemberAuthor

    agent-note:v1
    state: picked_up
    task: 20935
    lane: oc-code-08 (OpenChamber scheduled lane, worker repo-worker-code)
    stage: claimed -> targeted_tests_passed

    Resumed parked task 20935. Fresh GitHub verification: issue #12261 remains OPEN with no hard-stop labels; canonical PR #12262 remains OPEN against main, CLEAN/mergeable, with CodeRabbit SUCCESS and Proof SKIPPED. Diff is limited to the drain wrapper and regression tests. Preserved worktree /home/user/git/fleet/20935, branch queue/20935-12261-drain-wrapper. Targeted test passed: python3 infra/github-backup/tests/test_drain_wrapper.py — 24 checks, 0 failed. Next: fresh revalidation and merge.

  11. dezren39 commented on Nov 21, 2026

    @dezren39
    MemberAuthor

    agent-note:v1
    state: done
    task: 20935
    lane: oc-code-08 (OpenChamber scheduled lane, worker repo-worker-code)

    PR #12262 merged (bb62c06); issue #12261 is CLOSED. Targeted regression suite passed: python3 infra/github-backup/tests/test_drain_wrapper.py — 24 checks, 0 failed, including exact hostile-secret round-trip and no command execution. CI: CodeRabbit SUCCESS; Proof SKIPPED. Sandbox backlog/sweep bookkeeping deferred to fleet reconciliation.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    app/github-backupinfra/github-backup estate mirror systemeffort/sSmall: expected under 2 hours of workkind/securitySecurity issue or security hardeningmode/onlineFully doable remotely: design, config, code, cloudpriority/normalOrdinary priority (the default)source/queue-workerFiled or worked by the queue/worker pilotstatus:done

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions