ECC/scripts/lib
@aaronjmars 1c3280dc0d
fix(security): add host/origin allowlist + validate git refs + quote workflow input (#2185)
Three defense-in-depth fixes around untrusted input flowing to subprocess execution:

1. **Control-pane HTTP server (scripts/lib/control-pane/server.js)**
   The local control-pane API binds to 127.0.0.1 but had no Host or Origin
   validation, so a DNS-rebinding attack from a malicious website could pivot
   into the loopback endpoints — including POST /api/actions/:id, which spawns
   'cargo run -- graph ...' with caller-supplied query strings. Add a hostname
   allowlist (loopback variants plus the explicitly configured --host) and
   reject mismatched Host (421) or non-loopback Origin (403) before any route
   handler runs.

2. **OpenCode git-summary tool (.opencode/tools/git-summary.ts)**
   The tool was building 'git diff ${baseBranch}...HEAD --stat' with execSync
   and a raw model-supplied baseBranch string. Switch run() to execFileSync
   with an args array (no shell), validate baseBranch against a conservative
   git-ref allowlist (rejects shell metacharacters, leading -, embedded ..),
   and clamp the depth arg to a small positive integer before interpolating
   into 'git log --oneline -<N>'.

3. **Reusable test workflow (.github/workflows/reusable-test.yml)**
   The 'Install dependencies' step interpolated ${{ inputs.package-manager }}
   directly into a bash 'case' and into an echo, so a downstream caller that
   forwarded attacker-controllable input could inject into the runner. Move
   the input into a PACKAGE_MANAGER env var and reference $PACKAGE_MANAGER
   inside the script per the GitHub script-injection guidance.

Detected by Aeon + semgrep p/security-audit (host check via threat-model
manual-review axis; git-summary via detect-child-process; workflow via
run-shell-injection).

Verification: node tests/run-all.js — 2686/2687 pre-existing tests pass; the
one failure (observe.sh legacy output fallback) reproduces on main without
this branch applied. Added 2 new control-pane tests covering the allowlist
classifier and the DNS-rebinding-gate behavior end-to-end.

---
Filed by [Aeon](https://github.com/aaronjmars/aeon-aaron).

Co-authored-by: aeonframework <aeon@aaronjmars.com>
2026-06-15 13:49:40 -04:00
..
control-pane fix(security): add host/origin allowlist + validate git refs + quote workflow input (#2185) 2026-06-15 13:49:40 -04:00
install Fix claude-project target for legacy language installs (#2147) 2026-06-07 13:26:11 +08:00
install-targets fix(install-targets): validate compiled OpenCode plugin before install (#2041) 2026-05-25 14:07:52 -04:00
mcp-inventory feat: worktree-lifecycle service (deterministic conflict prediction + safe GC) (#2164) 2026-06-07 13:00:08 +08:00
session-adapters feat: worktree-lifecycle service (deterministic conflict prediction + safe GC) (#2164) 2026-06-07 13:00:08 +08:00
skill-evolution feat(design): skill health dashboard mockup (#518) 2026-03-16 14:01:41 -07:00
skill-improvement fix: port safe ci cleanup from backlog 2026-04-01 16:09:54 -07:00
state-store feat: add work items CLI 2026-05-11 12:24:12 -04:00
worktree-lifecycle feat: worktree-lifecycle service (deterministic conflict prediction + safe GC) (#2164) 2026-06-07 13:00:08 +08:00
agent-compress.js feat: agent description compression with lazy loading (#696) 2026-03-20 03:53:22 -07:00
agent-data-home.js feat: Cursor-independent ECC memory via ECC_AGENT_DATA_HOME (#2066) 2026-06-07 13:27:00 +08:00
cost-estimate.js feat: add ECC statusline observability hooks 2026-05-11 23:44:06 -04:00
cursor-agent-names.js fix: namespace cursor agent installs 2026-04-30 02:19:57 -04:00
ecc_dashboard_runtime.py fix: port hook session and dashboard safety fixes 2026-05-11 02:53:28 -04:00
github-discussions.js fix: skip disabled discussion queries in platform audit 2026-05-17 20:32:09 -04:00
harness-adapter-compliance.js feat: add zed install target 2026-05-17 07:06:49 -04:00
hook-flags.js feat: deliver v1.8.0 harness reliability and parity updates 2026-03-04 14:48:06 -08:00
inspection.js feat: agent compression, inspection logic, governance hooks (#491, #485, #482) (#688) 2026-03-20 01:38:13 -07:00
install-executor.js feat: Cursor-independent ECC memory via ECC_AGENT_DATA_HOME (#2066) 2026-06-07 13:27:00 +08:00
install-lifecycle.js fix(scripts): add os.homedir() fallback for Windows compatibility 2026-03-28 11:28:12 +08:00
install-manifests.js fix: shrink default OpenCode install surface and gate hooks-runtime (#2140) 2026-06-07 13:26:14 +08:00
install-state.js feat: strengthen install lifecycle and target adapters (#512) 2026-03-15 21:47:31 -07:00
mcp-config.js feat: support disabling bundled mcp servers 2026-04-05 14:37:28 -07:00
observer-sessions.js fix: port continuous-learning observer fixes 2026-05-11 03:35:42 -04:00
orchestration-session.js feat: orchestration harness, selective install, observer improvements 2026-03-14 12:55:25 -07:00
package-manager.d.ts fix: Windows path support, error handling, and dedup in validators 2026-02-12 15:57:20 -08:00
package-manager.js Fix failing workflows: trim action in getCommandPattern and remove broken AgentShield scan 2026-02-18 08:06:25 +00:00
project-detect.js fix(project-detect): match packageKeys on boundaries, not substrings (#2181) 2026-06-07 13:25:34 +08:00
resolve-ecc-root.js fix(hooks): avoid escaped quotes in plugin bootstrap 2026-05-19 05:15:42 -04:00
resolve-formatter.js refactor: deduplicate config lists and unify resolveFormatterBin branches 2026-03-11 10:45:28 +09:00
session-aliases.d.ts feat: Cursor-independent ECC memory via ECC_AGENT_DATA_HOME (#2066) 2026-06-07 13:27:00 +08:00
session-aliases.js feat: Cursor-independent ECC memory via ECC_AGENT_DATA_HOME (#2066) 2026-06-07 13:27:00 +08:00
session-bridge.js fix(lib): retry rename on Windows EPERM/EACCES/EBUSY in writeBridgeAtomic 2026-05-19 04:57:10 -04:00
session-manager.d.ts fix: fold session manager blockers into one candidate 2026-03-24 23:08:27 -04:00
session-manager.js fix: finish blocker lane hook and install regressions 2026-03-25 04:00:50 -04:00
shell-split.js fix(hooks): allow tmux-wrapped dev server commands (#321) 2026-03-07 14:47:49 -08:00
shell-substitution.js fix(hooks): close grouped command bypasses in gateguard (#1912) 2026-05-15 01:39:15 -04:00
tmux-worktree-orchestrator.js fix: resolve 8 test failures on main (install pipeline, orchestrator, repair) (#564) 2026-03-18 03:03:31 -07:00
transcript-context.js fix: context-size /compact trigger, Codex marketplace plugin path, live README badges (#2237) 2026-06-11 16:21:53 -04:00
utils.d.ts feat: Cursor-independent ECC memory via ECC_AGENT_DATA_HOME (#2066) 2026-06-07 13:27:00 +08:00
utils.js feat: Cursor-independent ECC memory via ECC_AGENT_DATA_HOME (#2066) 2026-06-07 13:27:00 +08:00