openclaw - 💡(How to fix) Fix Bug: gateway install --force persists secrets into user systemd unit files [1 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
openclaw/openclaw#61340Fetched 2026-04-08 02:59:44
View on GitHub
Comments
0
Participants
1
Timeline
0
Reactions
0
Participants

On a Linux host using user systemd services, openclaw gateway install --force appears to persist sensitive environment variables into the generated gateway unit file, including:

  • OPENAI_API_KEY
  • OPENCLAW_GATEWAY_TOKEN

The reinstall flow also copied those plaintext values into backup files such as openclaw-gateway.service.bak*.

This looks like a local secret-hygiene / installer issue rather than a proven remote vulnerability, but it is still security-relevant because plaintext secrets are being written to disk and copied into backups.

Root Cause

This looks like a local secret-hygiene / installer issue rather than a proven remote vulnerability, but it is still security-relevant because plaintext secrets are being written to disk and copied into backups.

Fix Action

Fix / Workaround

Additional note

During local mitigation, manually scrubbing the current unit file removed the secret lines successfully, but running openclaw gateway install --force later caused them to reappear. That suggests the service generation path itself is the source of the secret persistence.

RAW_BUFFERClick to expand / collapse

Bug report draft — openclaw gateway install --force persists secrets into user systemd unit files

Summary

On a Linux host using user systemd services, openclaw gateway install --force appears to persist sensitive environment variables into the generated gateway unit file, including:

  • OPENAI_API_KEY
  • OPENCLAW_GATEWAY_TOKEN

The reinstall flow also copied those plaintext values into backup files such as openclaw-gateway.service.bak*.

This looks like a local secret-hygiene / installer issue rather than a proven remote vulnerability, but it is still security-relevant because plaintext secrets are being written to disk and copied into backups.

Environment

  • OpenClaw version: 2026.4.2
  • OS: Linux
  • Service mode: user systemd (~/.config/systemd/user/openclaw-gateway.service)
  • Gateway installed via: openclaw gateway install --force

Reproduction (redacted)

  1. Start from a working user-systemd gateway install.
  2. Ensure gateway-related secrets are available in the environment/config used by OpenClaw.
  3. Run:
    • openclaw gateway install --force
  4. Inspect the generated unit file:
    • ~/.config/systemd/user/openclaw-gateway.service
  5. Inspect any generated backup files:
    • ~/.config/systemd/user/openclaw-gateway.service.bak*

Actual behavior

The generated unit file contained plaintext env lines like:

  • Environment=OPENAI_API_KEY=<redacted>
  • Environment=OPENCLAW_GATEWAY_TOKEN=<redacted>

Related backup files also contained those secret-bearing lines.

In this environment, openclaw doctor --non-interactive also suggested reinstalling the gateway service to remove embedded service-token issues, but reinstalling the service reintroduced embedded secrets into the unit file.

Expected behavior

Expected safer behavior would be one of:

  1. do not embed sensitive env vars into the generated unit file
  2. use EnvironmentFile= or another secret-ref-based mechanism instead
  3. do not copy inline secrets into .bak* backups
  4. do not recommend reinstall as a cleanup path if reinstall re-embeds the token

Security impact

This appears to create a local plaintext secret exposure risk:

  • secrets are written to disk in unit files
  • the same secrets are propagated into backup copies
  • if file permissions are not sufficiently strict, the exposure surface is larger

This report is not claiming confirmed remote exploitability or auth bypass. It is reporting an installer/service-generation secret persistence issue with security implications.

Additional note

During local mitigation, manually scrubbing the current unit file removed the secret lines successfully, but running openclaw gateway install --force later caused them to reappear. That suggests the service generation path itself is the source of the secret persistence.

Suggested areas to inspect

Potentially relevant code paths in the installed build were the gateway install / systemd unit generation logic, including:

  • gateway install environment collection
  • systemd unit generation from collected environment
  • backup creation during reinstall
  • doctor guidance for embedded-token cleanup

extent analysis

TL;DR

Modify the openclaw gateway install process to avoid embedding sensitive environment variables into the generated systemd unit file.

Guidance

  • Review the openclaw gateway install command to determine why it is including sensitive environment variables like OPENAI_API_KEY and OPENCLAW_GATEWAY_TOKEN in the generated unit file.
  • Consider using an EnvironmentFile directive in the unit file to reference sensitive variables, rather than embedding them directly.
  • Inspect the backup creation process during reinstall to prevent copying inline secrets into .bak* files.
  • Update the openclaw doctor command to avoid recommending reinstall as a cleanup path if it will re-embed sensitive tokens.

Example

A potential fix could involve modifying the systemd unit file generation logic to use an EnvironmentFile directive, like this:

EnvironmentFile=/path/to/sensitive/env/file

Instead of embedding sensitive variables directly:

Environment=OPENAI_API_KEY=<redacted>

Notes

The exact fix will depend on the specifics of the openclaw gateway install command and the systemd unit file generation logic. It may be necessary to modify the code that generates the unit file to use a more secure approach to handling sensitive environment variables.

Recommendation

Apply a workaround by manually scrubbing the sensitive environment variables from the generated unit file and using an EnvironmentFile directive to reference them securely. This will prevent plaintext secret exposure until a more permanent fix can be implemented.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

FAQ

Expected behavior

Expected safer behavior would be one of:

  1. do not embed sensitive env vars into the generated unit file
  2. use EnvironmentFile= or another secret-ref-based mechanism instead
  3. do not copy inline secrets into .bak* backups
  4. do not recommend reinstall as a cleanup path if reinstall re-embeds the token

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING