T09 · Insecure Skill Coding Practices
- Location
scripts/friends_db.py:648- Finding
External Calendar CLI Inherits the Complete Process Environment
- Content
View full analysis
Vulnerability Details
File Location:
scripts/friends_db.py, lines 648–666
Vulnerability Type: Excessive credential exposure to an external subprocess
Risk Level: MediumVulnerable Code
python def load_gog_env() -> dict[str, str]: env = os.environ.copy() config_path = Path.home() / ".openclaw" / "openclaw.json" if config_path.exists(): try: config = json.loads(config_path.read_text()) gog_env = config.get("skills", {}).get("entries", {}).get("gog", {}).get("env", {}) except json.JSONDecodeError: gog_env = {} for key, value in gog_env.items(): env.setdefault(key, str(value)) return env def run_gog_json(args: list[str]) -> Any: env = load_gog_env() cmd = ["gog", *args, "--json", "--results-only", "--no-input"] try: result = subprocess.run(cmd, check=True, capture_output=True, text=True, env=env)Technical Analysis
Calendar synchronization legitimately requires an authenticated external service, and the implementation invokes
gogwithoutshell=True, so command arguments are not interpreted by a shell. However,load_gog_env()copies every variable from the parent process and passes the resulting environment to an external executable. The environment may contain unrelated API keys, access tokens, cloud credentials, or other sensitive configuration that the calendar operation does not require.The executable is also selected using the bare name
gog, causing operating-systemPATHresolution. Consequently, a PATH-shadowed, replaced, or compromisedgogexecutable would receive both all inherited process secrets and the Skill-specificgogconfiguration loaded from~/.openclaw/openclaw.json.The reviewed source does not explicitly transmit these secrets and contains no attacker-controlled network destination. The weakness is the unnecessary exposure of credentials across the subprocess trust boundary.
Attac
...[truncated 1395 chars]
- Remediation
View remediation
Remediation Suggestions
- Replace
os.environ.copy()with a minimal allowlist containing only variables required to launch and authenticategog, such as explicitly documentedgogcredential variables, a controlledPATH, and necessary locale settings. - Resolve
gogto an explicitly configured absolute path and verify that it points to a regular file owned by a trusted user and is not writable by untrusted users. - Pin and document the trusted
gogdistribution source and version, and verify its checksum or signature during installation or deployment. - Keep unrelated API keys and credentials out of the Skill process environment where possible.
- Validate that the
envobject loaded from~/.openclaw/openclaw.jsonis a dictionary with an explicit set of permitted keys before passing values to the subprocess. - Preserve the existing safe argument-array invocation and continue avoiding
shell=True.
- Replace
