[Bug/Security] CodexBar installer executes user-controlled `BASH_ENV` as administrator
Version
Affected version tested:
CodexBar v0.53.0
commit 5a2a70458d95e73e02e971a69f04e25d2ee4852e
file: bin/install-codexbar-cli.sh
Summary
The installer executes bash -c through AppleScript with administrator privileges while inheriting the caller's environment. A same-user attacker can set BASH_ENV or ENV to an attacker-controlled script.
Details
Non-interactive Bash sources BASH_ENV before executing its -c command. The privileged shell therefore executes the attacker-controlled startup file after the administrator approves the installer.
PoC
Run the attached poc.sh in a disposable Linux container or root test environment. It invokes the real installer and uses a local osascript shim only to emulate the macOS privileged boundary:
git clone https://github.com/steipete/CodexBar.git
cd CodexBar
git checkout v0.53.0
bash /path/to/poc.sh
The script creates an attacker-controlled startup file, exports it through BASH_ENV and ENV, provisions the helper path expected by the installer, consumes the real AppleScript program, reconstructs its installCommand, and executes the privileged bash -c boundary with the caller environment inherited.
Observed on the affected tag:
POC_TARGET: .../bin/install-codexbar-cli.sh
ATTACKER_ENV: BASH_ENV=... ENV=...
ADMIN_BOUNDARY_REACHED: do shell script "bash -c <installCommand>" with administrator privileges (emulated)
BYPASS_SUCCESS: attacker-controlled content executed with administrator privileges
ATTACKER_CONTENT_EXECUTED_WITH_ADMIN_PRIVILEGES
Impact
A same-user local attacker can obtain administrator-level code execution when a user runs the installer and approves its privilege request. This requires the macOS installer flow and user approval.
Codex review: keeping this open for maintainer follow-up; there is still a little grit to resolve. Reviewed August 26, 2026, 3:14 AM ET / 07:14 UTC.
Summary
Keep open as an active security issue: current main still invokes an administrator-privileged bash -c without clearing Bash startup-file state. Likely related people: Peter Steinberger (high confidence, current installer author).
Reproducibility: yes. —source inspection gives a high-confidence path: set BASH_ENV before invoking the documented installer, whose administrator bash -c boundary can source that file.
Maintainer decision needed
| Question | Recommendation |
|---|---|
| Should the repository ship a targeted security fix immediately and coordinate further disclosure through its security process? | Patch and ship promptly: Clear Bash startup variables or use a non-Bash privileged command, add regression coverage, and release the corrected installer. |
Why: The code repair is narrow, but release timing and disclosure handling for a publicly reported local privilege-boundary flaw require maintainer authority.
Next step Security remediation and release/disclosure handling require maintainer ownership; do not auto-dispatch a fix PR.
Security Needs attention: Current main retains a concrete elevated-shell environment-inheritance concern in the documented installer path.
Review details
Best possible solution:
Use a minimal explicitly controlled environment at the privileged boundary (or avoid Bash), add a regression check for hostile startup variables, and ship the correction in a security update.
Do we have a high-confidence way to reproduce the issue?
Yes—source inspection gives a high-confidence path: set BASH_ENV before invoking the documented installer, whose administrator bash -c boundary can source that file.
Is this the best way to solve the issue?
Yes—the narrowest durable repair is to prevent Bash startup state from reaching the privileged shell and verify hostile startup variables cannot affect it.
AGENTS.md: found and applied where relevant.
Remaining risk / open question:
- A caller-controlled
BASH_ENVcan be sourced before the elevatedbash -cprogram executes, crossing the installer’s intended privilege boundary after administrator approval.
Codex review notes: model internal, reasoning high; reviewed against cf79d1310493.
Label changes
Label changes:
- add
P1: The documented installer can enter an administrator shell while retaining hostile caller-controlled Bash startup state. - add
impact:security: The report concerns code execution across the macOS administrator privilege boundary. - add
issue-rating: 🦞 diamond lobster: Current issue advisory state selects this label. - add
clawsweeper:source-repro: Current issue advisory state selects this label. - add
clawsweeper:no-new-fix-pr: Current issue advisory state selects this label. - add
clawsweeper:needs-maintainer-review: Current issue advisory state selects this label. - add
clawsweeper:needs-security-review: Current issue advisory state selects this label.
Label justifications:
P1: The documented installer can enter an administrator shell while retaining hostile caller-controlled Bash startup state.impact:security: The report concerns code execution across the macOS administrator privilege boundary.
Evidence reviewed
Security concerns:
- [high] Elevated Bash inherits startup-file controls —
bin/install-codexbar-cli.sh:25The privileged AppleScript command startsbash -cwithout clearingBASH_ENV; Bash can source that caller-controlled file before executing the generated link program. Confidence: 0.95
What I checked:
- Current source: Current main still builds an install command and invokes
bash -cthrough AppleScript with administrator privileges; no environment scrubbing is present. (bin/install-codexbar-cli.sh:25, cf79d1310493) - Documented affected path: The CLI documentation presents this script as the repository install path and identifies the two system-wide symlink targets. (
docs/cli.md:15, cf79d1310493) - Current-main continuity: There is no diff for the installer between the v0.55.1 commit and current main, so the vulnerable elevated invocation remains unchanged. (
bin/install-codexbar-cli.sh:25, 10587234b54e) - Feature provenance: Blame attributes the current installer implementation, including the elevated shell invocation, to this commit. (
bin/install-codexbar-cli.sh:25, 10587234b54e)
Likely related people:
- Peter Steinberger: Git blame attributes the installer and its elevated shell invocation to the v0.55.1 commit. (role: introduced the current installer implementation; confidence: high; commits: 10587234b54e; files:
bin/install-codexbar-cli.sh,Sources/CodexBar/PreferencesAdvancedPane.swift)
How this review workflow works
- ClawSweeper keeps one durable marker-backed review comment per issue or PR.
- Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
- A fresh review can be triggered by eligible
@clawsweeper re-reviewcomments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch. - PR/issue authors and users with repository write access can comment
@clawsweeper re-reviewor@clawsweeper re-runon an open PR or issue to request a fresh review only. - Maintainers can also comment
@clawsweeper reviewto request a fresh review only. - Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
- Maintainer-only repair and merge flows require explicit commands such as
@clawsweeper autofix,@clawsweeper automerge,@clawsweeper fix ci, or@clawsweeper address review. - Maintainers can comment
@clawsweeper explainto ask for more context, or@clawsweeper stopto stop active automation.
Fixed on main by #3217, commit 0b54a928ff0602e292efc4b4c26c022356917f2e.
The repository installer now blocks inherited shell functions/startup hooks before validation and error handling, uses absolute system tools, and clears the environment before the administrator-command boundary. Administrator approval and the two symlink destinations are unchanged.
The actual macOS Bash-export regression passed locally and in CI, including missing/non-executable helpers and failure propagation under contaminated environments. make check, the full local test suite, independent review, and exact-head macOS/Linux CI passed: https://github.com/steipete/CodexBar/actions/runs/33012784084. Tests remained nonprivileged with temporary destinations; real macOS authorization was not exercised. This is on main for the next release, not a newly published version. Thanks for the report.