Browser-based graphical shell and control plane for a Linux server you own — real terminal, file manager, live metrics and BYOK AI in one mobile-first workspace. Next.js 16 · React 19 · node-pty · Tailwind v4 · shadcn/ui. Public alpha, self-hosted.
TypeScript browser-shellcontrol-planefile-managerhomelabmobile-firstnextjsptyreactself-hostedserver-managementshadcn-uisysadmintailwindcssterminaltypescriptvpsweb-desktopweb-terminal
fix(security): keep OpenClaw provider keys out of argv
Abdurrahman Fakhrul02d977e33ff1
diff --git a/lib/managed-apps/install.test.ts b/lib/managed-apps/install.test.tsindex 6510ce02..1854f925 100644--- a/lib/managed-apps/install.test.ts+++ b/lib/managed-apps/install.test.ts@@ -217,3 +217,14 @@ describe("the provider table and the install script agree", () => {expect(script).not.toMatch(/\bread -[rp]\b/);});});+++describe("OpenClaw provider secrets stay out of child argv", () => {+ const script = readFileSync(path.join(process.cwd(), "scripts", "managed-app-install"), "utf8");+ it("uses provider env SecretRefs instead of provider key flags", () => {+ const openclaw = script.slice(script.indexOf("install_openclaw() {"), script.indexOf("openclaw_bin() {"));+ expect(openclaw).toContain("--secret-input-mode ref");+ expect(openclaw).not.toMatch(/--(?:anthropic|openai|openrouter|gemini|groq|xai|deepseek)-api-key/);+ expect(openclaw).not.toContain('"$KEY"');+ });+});diff --git a/lib/managed-apps/install.ts b/lib/managed-apps/install.tsindex 09de1bef..c087af17 100644--- a/lib/managed-apps/install.ts+++ b/lib/managed-apps/install.ts@@ -97,9 +97,9 @@ export async function startInstall(id: ManagedAppId, options: InstallOptions = {if (!provider.apps.includes(id)) throw new Error(`${provider.label} is not supported by this application`);assertKeyShape(key);env.MSO_INSTALL_PROVIDER = provider.id;- // Both hand-offs at once: the name the CLI reads on its own (Hermes takes it- // straight from here and never sees a flag), and the generic pair the install- // script uses to build OpenClaw's flag.+ // The provider's documented environment variable is inherited only by the+ // installer child. Hermes reads it directly; OpenClaw stores an env SecretRef.+ // The generic MSO key remains for Hermes' private .env persistence path.env.MSO_INSTALL_API_KEY = key;env[provider.envVar] = key;}diff --git a/scripts/managed-app-install b/scripts/managed-app-installold mode 100755new mode 100644index e518a1f4..9dcaa54d--- a/scripts/managed-app-install+++ b/scripts/managed-app-install@@ -8,13 +8,10 @@# control where they can be read and diffed, and keeps the argv that ends up in the# persisted job record down to two elements.#-# SECRETS. The provider key arrives in the ENVIRONMENT and never in this script's-# argv, because mso stores a job's argv in the job record and writes it to the-# audit log (app/api/v1/managed-apps/[id]/install/route.ts). Where an upstream CLI-# has no env path, the key is re-exported to it as a flag: that argv belongs to a-# transient child of this box, visible in `ps` only to the uid that could read the-# resulting config file anyway, and it is never persisted. It is not passed to-# anything else, and it is not echoed.+# SECRETS. Provider keys arrive in the ENVIRONMENT and never in argv. Hermes reads+# its provider env directly. OpenClaw non-interactive onboarding uses its reviewed+# environment SecretRef mode, so the transient child also never exposes provider+# keys through /proc/<pid>/cmdline. Keys are never echoed or persisted in MSO jobs.## Everything here must be NON-INTERACTIVE. The job layer gives its child no stdin# (JOB_STDIO), so a prompt does not hang — it gets EOF and the install dies@@ -535,20 +532,20 @@ install_openclaw() {local -a auth=(--auth-choice skip)if [ -n "$KEY" ]; then- # OpenClaw's onboard takes the key as a flag. Env would be tidier, but a key- # that silently fails to register leaves an "installed" app that cannot answer- # a single prompt — the exact opposite of one-click. See the SECRETS note.+ # The provider-specific environment variable was already exported by MSO.+ # OpenClaw's non-interactive SecretRef mode validates it and stores only the+ # env reference. No provider key is copied into this process's argv.case "$PROVIDER" in- anthropic) auth=(--auth-choice apiKey --anthropic-api-key "$KEY") ;;- openai) auth=(--auth-choice openai-api-key --openai-api-key "$KEY") ;;- openrouter) auth=(--auth-choice openrouter-api-key --openrouter-api-key "$KEY") ;;- google) auth=(--auth-choice gemini-api-key --gemini-api-key "$KEY") ;;- groq) auth=(--auth-choice groq-api-key --groq-api-key "$KEY") ;;- xai) auth=(--auth-choice xai-api-key --xai-api-key "$KEY") ;;- deepseek) auth=(--auth-choice deepseek-api-key --deepseek-api-key "$KEY") ;;+ anthropic) auth=(--auth-choice apiKey --secret-input-mode ref) ;;+ openai) auth=(--auth-choice openai-api-key --secret-input-mode ref) ;;+ openrouter) auth=(--auth-choice openrouter-api-key --secret-input-mode ref) ;;+ google) auth=(--auth-choice gemini-api-key --secret-input-mode ref) ;;+ groq) auth=(--auth-choice groq-api-key --secret-input-mode ref) ;;+ xai) auth=(--auth-choice xai-api-key --secret-input-mode ref) ;;+ deepseek) auth=(--auth-choice deepseek-api-key --secret-input-mode ref) ;;*)- echo "unknown provider '$PROVIDER' — installing without one" >&2- auth=(--auth-choice skip)+ echo "unknown provider '$PROVIDER' — refusing credentialed install" >&2+ return 1;;esacfi