T05 · Unauthorized Access and Privilege Escalation
- Location
scripts/send_message.py:20- Finding
Overbroad Loading of Sensitive OpenClaw Environment Files
- Content
View full analysis
Vulnerability Details
File Location:
scripts/send_message.py, lines 20–34
Vulnerability Type:T05: Unauthorized Access and Privilege Escalation
Risk Level: Mediumpython def load_openclaw_env(): """加载OpenClaw的.env配置文件""" env_paths = [ Path.home() / ".openclaw" / "workspace" / ".env", Path.home() / ".openclaw" / ".env", ] for env_path in env_paths: if env_path.exists(): with open(env_path, 'r', encoding='utf-8') as f: for line in f: line = line.strip() if line and not line.startswith('#') and '=' in line: key, value = line.split('=', 1) os.environ.setdefault(key, value)Technical Analysis
The Skill requires only
JIUWU_MESSAGE_GATEWAY_URL, butload_openclaw_env()reads every key-value pair from two shared OpenClaw.envfiles and inserts all of them into the process environment.These configuration files may contain unrelated API keys, authentication tokens, database credentials, or service secrets. Loading every entry violates least privilege because the declared message-sending functionality does not require access to unrelated configuration values.
No direct secret transmission or intentional credential theft was identified. However, once loaded, the additional secrets become accessible to any other code running in the same Python process. This is particularly relevant when
send_messageis imported as a library, as documented by the Skill, rather than run in a dedicated process.Attack Path
- The OpenClaw
.envfiles contain both the gateway URL and unrelated sensitive credentials. - The Skill is imported into a process that also contains compromised, untrusted, or vulnerable Python code.
- A call to
send_message()invokesget_gateway_url(), which invokesload_openclaw_env(). - The loader reads ...[truncated 894 chars]
- The OpenClaw
- Remediation
View remediation
Remediation Suggestions
- Prefer requiring
JIUWU_MESSAGE_GATEWAY_URLto be supplied directly through the existing process environment. - If
.envfallback behavior is necessary, parse and return only the value ofJIUWU_MESSAGE_GATEWAY_URL. - Do not copy unrelated values into
os.environ. - Apply restrictive filesystem permissions to any
.envfile containing credentials. - Consider using a dedicated configuration file containing only this Skill's non-secret gateway setting.
- Document the exact configuration value read by the Skill and avoid implying that broad access to shared secret stores is required.
A safer implementation would inspect lines only until it finds the exact
JIUWU_MESSAGE_GATEWAY_URLkey and return that value without mutating the process environment.- Prefer requiring
