fix(gateway): add --password-file and --token-file to avoid ps exposure#27993
fix(gateway): add --password-file and --token-file to avoid ps exposure#27993Anandesh-Sharma wants to merge 1 commit into
Conversation
Add file-based secret options (--password-file, --token-file) to gateway run and call commands, following the existing ACP CLI pattern. When the direct --password or --token flags are used, emit a warning recommending file-based or environment variable alternatives. Closes openclaw#27948 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Greptile SummaryAdded Key changes:
Security improvement verified: The file-based approach keeps secrets out of process argument lists while maintaining backward compatibility with existing direct flag and environment variable methods. Confidence Score: 4/5
Last reviewed commit: 1f2c0f8 |
| export const callGatewayCli = async (method: string, opts: GatewayRpcOpts, params?: unknown) => { | ||
| const token = resolveCallSecret(opts.token, opts.tokenFile, "--token", "--token-file", "Gateway token"); | ||
| const password = resolveCallSecret(opts.password, opts.passwordFile, "--password", "--password-file", "Gateway password"); |
There was a problem hiding this comment.
missing warnings for direct CLI secret flags — unlike src/cli/gateway-cli/run.ts (lines 256-265) and the existing ACP CLI pattern (src/cli/acp-cli.ts lines 69-74), this doesn't warn users when --token or --password are passed directly (visible in ps aux). add checks after resolving secrets:
if (opts.token) {
console.warn("Warning: --token can be exposed via process listings. Prefer --token-file or OPENCLAW_GATEWAY_TOKEN.");
}
if (opts.password) {
console.warn("Warning: --password can be exposed via process listings. Prefer --password-file or OPENCLAW_GATEWAY_PASSWORD.");
}(or use defaultRuntime.error() to match the ACP CLI pattern)
Prompt To Fix With AI
This is a comment left during a code review.
Path: src/cli/gateway-cli/call.ts
Line: 47-49
Comment:
missing warnings for direct CLI secret flags — unlike `src/cli/gateway-cli/run.ts` (lines 256-265) and the existing ACP CLI pattern (`src/cli/acp-cli.ts` lines 69-74), this doesn't warn users when `--token` or `--password` are passed directly (visible in `ps aux`). add checks after resolving secrets:
```typescript
if (opts.token) {
console.warn("Warning: --token can be exposed via process listings. Prefer --token-file or OPENCLAW_GATEWAY_TOKEN.");
}
if (opts.password) {
console.warn("Warning: --password can be exposed via process listings. Prefer --password-file or OPENCLAW_GATEWAY_PASSWORD.");
}
```
(or use `defaultRuntime.error()` to match the ACP CLI pattern)
How can I resolve this? If you propose a fix, please make it concise.There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 1f2c0f892d
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| const tokenRaw = tokenFilePath | ||
| ? readSecretFromFile(tokenFilePath, "Gateway token") |
There was a problem hiding this comment.
Export token-file secret into OPENCLAW_GATEWAY_TOKEN
When --token-file is used, the token is loaded into tokenRaw but never written to OPENCLAW_GATEWAY_TOKEN, while the direct --token path still sets that env var earlier. Several runtime paths (for example resolveRelayAcceptedTokensForPort in src/browser/extension-relay-auth.ts) resolve the gateway token from config/env rather than this local tokenRaw, so starting with only --token-file and no configured gateway.auth.token can break browser relay/auth flows even though gateway auth override is present.
Useful? React with 👍 / 👎.
Summary
--password-fileand--token-fileoptions togateway runandgateway callcommands, following the existing ACP CLI pattern (src/cli/acp-cli.ts)--passwordor--tokenare passed directly on the CLI, since they are visible inps auxoutputreadSecretFromFile()utility fromsrc/acp/secret-file.tsContext
Gateway passwords passed via
--password <secret>appear in plaintext in process argument lists visible to all users on the host (ps aux,/proc/[pid]/cmdline). The environment variable (OPENCLAW_GATEWAY_PASSWORD) and config file alternatives already exist but the CLI lacked the file-based option that the ACP CLI already supports.Closes #27948
Test plan
openclaw gateway run --password-file /path/to/secretreads password from fileopenclaw gateway run --password mysecretemits a warning--passwordand--password-filetogether produces an errorgateway callsubcommands support--token-fileand--password-file🤖 Generated with Claude Code