T05 · Unauthorized Access and Privilege Escalation
- Location
assistant.js:2- Finding
Automatic Access to a Global Credential-Bearing Configuration File
- Content
View full analysis
Vulnerability Details
File Location:
assistant.js, lines 2-4
Vulnerability Type: Unauthorized access to a global credential-bearing configuration file
Risk Level: MediumVulnerable Code
javascript const https = require('https'), fs = require('fs'), path = require('path'); let KEY = process.env.DEEPSEEK_API_KEY || ''; try { const c = JSON.parse(fs.readFileSync(path.join(process.env.HOME,'.openclaw/openclaw.json'),'utf8')); KEY = KEY || c.models?.providers?.deepseek?.apiKey || ''; } catch(e){}Technical Analysis
The module automatically reads
~/.openclaw/openclaw.jsonwhenever it is executed or imported. This is a global, potentially credential-bearing configuration file rather than a file scoped to this skill.Although the code extracts only the configured DeepSeek API key and the reviewed implementation uses that key solely to authenticate requests to
api.deepseek.com, direct access to the entire configuration file violates least-privilege principles. The process necessarily obtains the contents of the complete file before selecting the nested API-key field.The broad
catchblock also suppresses every read and parsing error, making this credential-access behavior less visible to users and operators. No evidence was found that the current implementation transmits the key to an unrelated host or prints it.Attack Path
- A user installs the skill and executes
assistant.js, or another module imports it. - The module resolves the current user's home directory through
process.env.HOME. - It reads the complete
~/.openclaw/openclaw.jsonfile without an explicit consent step. - It parses the file and extracts
models.providers.deepseek.apiKeywhenDEEPSEEK_API_KEYis not already set. - The extracted credential is placed in the module-level
KEYvariable and used as a bearer token for DeepSeek API requests. - If the skill process or module were subsequently compromise ...[truncated 869 chars]
- A user installs the skill and executes
- Remediation
View remediation
Remediation Suggestions
- Remove automatic reads of
~/.openclaw/openclaw.jsonand require the credential to be supplied throughDEEPSEEK_API_KEYor a platform-provided secret API. - If configuration-file fallback is essential, request explicit user consent before accessing the file and document the exact file and field being read.
- Use a narrowly scoped credential broker or configuration interface so the skill receives only the DeepSeek token rather than permission to read the entire global configuration file.
- Prefer a dedicated, revocable API key with restricted permissions, quota limits, and billing limits.
- Avoid silently suppressing all exceptions. Report a sanitized error that explains whether the environment variable is missing or credential retrieval failed, without revealing the secret or sensitive file contents.
- Keep the key out of logs, model prompts, returned errors, and exported module state. Rotate the credential if unauthorized access to the skill process is suspected.
- Remove automatic reads of
