T05 · Unauthorized Access and Privilege Escalation
- Location
src/multi_writing_skills/config.py:13- Finding
Automatic Overbroad Reading of a Shared Credential File
- Content
View full analysis
bool: """检测是否在 openclaw 环境中运行""" openclaw_dir = Path.home() / ".openclaw" return openclaw_dir.exists() and openclaw_dir.is_dir() def load_openclaw_env() -> dict[str, str]: """从 ~/.openclaw/.env 加载环境变量""" env_file = Path.home() / ".openclaw" / ".env" env_vars = {} if env_file.exists(): with open(env_file, encoding="utf-8") as f: for line in f: line = line.strip() if line and not line.startswith("#"): if "=" in line: key, value = line.split("=", 1) env_vars[key.strip()] = value.strip() return env_vars ``` ```python def load(self) -> None: """从文件和环境变量加载配置""" # 如果在 openclaw 环境中,先加载 ~/.openclaw/.env openclaw_env = {} if is_openclaw_env(): openclaw_env = load_openclaw_env() ``` ```python @app.callback() def main() -> None: """初始化""" init_registry() ``` The callback invokes `init_registry()`, which calls `settings.load()`. Consequently, ordinary CLI commands trigger the credential-file access rather than only commands that require credentials. ### Technical Analysis The application automatically detects whether `~/.openclaw` exists and, if so, parses every assignment in `~/.openclaw/.env` into a dictionary. Only a limited set of values—such as `WECHAT_APP_SECRET`, `ZHIHU_COOKIE`, `TOUTIAO_COOKIE`, and `AI_API_KEY`—is needed for the declared publishing and AI features, but the loader reads and retains all entries in the shared file. This violates least-privilege and data-minimization principles. A shared OpenClaw environment file may conta ...[truncated 1620 chars]- Remediation
View remediation
