T05 · Unauthorized Access and Privilege Escalation
- Location
scripts/kie_client.py:50- Finding
Overbroad Loading of Sensitive Global Environment Configuration
- Content
View full analysis
Vulnerability Details
File Location:
scripts/kie_client.py, lines 50–64
Vulnerability Type: Violation of least privilege through unnecessary credential access
Risk Level: Mediumpython try: cfg_path = Path.home() / ".openclaw" / "openclaw.json" if not cfg_path.is_file(): return with open(cfg_path, encoding="utf-8") as f: cfg = json.load(f) global_env = cfg.get("globalEnv") or {} if not isinstance(global_env, dict): return for key, value in global_env.items(): if key not in os.environ and value is not None: os.environ[key] = str(value) except (OSError, ValueError): # Silently ignore — skill will fail later with a clear KIE_API_KEY error # if the key really is missing. passTechnical Analysis
Importing
scripts/kie_client.pyinvokes_load_openclaw_global_env(), which reads the user's~/.openclaw/openclaw.jsonfile and copies every entry underglobalEnvinto the process environment.The Skill's declared functionality requires only
KIE_API_KEYand, when webhook verification is used,KIE_WEBHOOK_HMAC_KEY. Loading all other environment entries gives the process access to credentials and configuration unrelated to music generation, violating least-privilege principles.No reviewed code transmits these unrelated values, so this is not confirmed data exfiltration. Nevertheless, exposing them through
os.environexpands the sensitive-data scope available to any other imported module, future code modification, diagnostic routine, or compromised component running in the same process.Attack Path
- A user stores
KIE_API_KEYtogether with unrelated service credentials in OpenClaw'sglobalEnv. - The user invokes the Skill, causing
scripts/generate.pyto importscripts/kie_client.py. - Module initialization reads the complete
globalEnvobject from~/.openclaw/openclaw.json. 4 ...[truncated 903 chars]
- A user stores
- Remediation
View remediation
Remediation Suggestions
Replace unrestricted iteration over
globalEnvwith an explicit allowlist containing only the values required by this Skill:python allowed_keys = ("KIE_API_KEY", "KIE_WEBHOOK_HMAC_KEY") for key in allowed_keys: value = global_env.get(key) if key not in os.environ and value is not None: os.environ[key] = str(value)For stronger isolation:
- Avoid copying configuration into the global process environment.
- Return only requested Kie values from a narrowly scoped configuration loader.
- Pass the API key directly to
KieClientand the HMAC key directly to webhook verification. - Keep unrelated OpenClaw credentials inaccessible to this process wherever runtime isolation permits.
- Add tests verifying that unrelated
globalEnventries are neither loaded nor exposed throughos.environ. - Document precisely which configuration keys the Skill reads and under which features they are required.
