openclaw - 💡(How to fix) Fix [Feature Request] Add config encryption for credentials at rest [1 comments, 2 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#43794Fetched 2026-04-08 00:18:03
View on GitHub
Comments
1
Participants
2
Timeline
2
Reactions
0
Author
Participants
Timeline (top)
commented ×1subscribed ×1
RAW_BUFFERClick to expand / collapse

Problem

According to the threat model (THREAT-MODEL-ATLAS.md), credential theft from config files is a known high-risk issue (T-PERSIST-001). Currently, tokens and API keys are stored in plaintext in ~/.openclaw/openclaw.json.

Expected Feature

  • Encrypt sensitive fields (tokens, API keys) in config files
  • Use system keychain or master password for decryption
  • Maintain backward compatibility

Reference

  • Official threat model already flags this as "Residual Risk: High"
  • Recommendation: "Implement token encryption at rest, add token rotation"

Please prioritize this security improvement. Thanks!

extent analysis

Problem Summary

Plain‑text API tokens in ~/.openclaw/openclaw.json violate the threat model (T‑PERSIST‑001).
We need to encrypt those fields at rest, using either the OS keychain or a user‑supplied master password, while keeping the existing file format usable for older versions.


Root Cause

  • The config loader reads the JSON file directly and stores secrets as clear text.
  • No encryption or secure storage layer is used, so anyone with file‑system access can steal credentials.

Fix Plan

1. Choose a storage strategy

OptionProsCons
OS keyring (keyring Python lib)No password prompt, secrets stored in OS‑native vault (macOS Keychain, Windows Credential Locker, Linux Secret Service).Requires the OS to have a keyring service; not available in minimal containers.
Master password + AES‑GCMWorks everywhere; user controls the secret.Must prompt for password on each run (or cache in memory).

Implement both; default to OS keyring and fall back to master‑password mode when a keyring backend is unavailable.

2. Add a small encryption helper (crypto.py)

# openclaw/crypto.py
import os, json, base64, hashlib
from cryptography.hazmat.primitives.ciphers.aead import AESGCM
import keyring  # optional, pip install keyring

_KEYRING_SERVICE = "openclaw"
_KEYRING_ACCOUNT = "config_master_key"
_SALT_FILE = os.path.expanduser("~/.openclaw/.salt")

def _derive_key(password: bytes, salt: bytes) -> bytes:
    # PBKDF2-HMAC-SHA256, 200k iterations
    return hashlib.pbkdf2_hmac("sha256", password, salt, 200_000, dklen=32)

def _get_salt() -> bytes:
    if not os.path.exists(_SALT_FILE):
        os.makedirs(os.path.dirname(_SALT_FILE), exist_ok=True)
        salt = os.urandom(16)
        with open(_SALT_FILE, "wb") as f:
            f.write(salt)
        return salt
    with open(_SALT_FILE, "rb") as f:
        return f.read()

def _load_master_key() -> bytes:
    """Try OS keyring first, otherwise raise."""

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…

Still need to ship something?

×6

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

Back to top recommendations

TRENDING