T09 · Insecure Skill Coding Practices
- Location
scripts/vault.js:34- Finding
Vault credentials and cached secrets are stored without restrictive file permissions
- Content
View full analysis
Vulnerability Details
File Location:
scripts/vault.js:34-36andscripts/vault.js:87-89
Vulnerability Type: Insecure storage of sensitive information
Risk Level: HighVulnerable Code
Configuration writing at
scripts/vault.js:34-36:js function saveConfig(cfg) { fs.mkdirSync(path.dirname(CONFIG_PATH), { recursive: true }); fs.writeFileSync(CONFIG_PATH, JSON.stringify(cfg, null, 2)); }Cache writing at
scripts/vault.js:87-89:js function saveCache(cache) { fs.writeFileSync(CACHE_PATH, JSON.stringify(cache, null, 2)); }Technical Analysis
The configuration file contains the Vault authentication token, and the cache file contains complete plaintext secret values retrieved from Vault. Both files are written without an explicit restrictive mode such as
0600.Node.js therefore creates these files using permissions derived from the process umask. In environments with a permissive or incorrectly configured umask, other local users or processes may be able to read the files. The code also does not inspect or repair the permissions of existing files.
The cache increases the exposure scope because retrieved API keys, database credentials, and other secrets remain on disk until manually removed, even after their configured cache expiration time. Cache expiration only prevents the application from using stale entries; it does not erase expired values from the file.
Attack Path
- A user runs
vault.js setup, causing the Vault token to be written to~/.openclaw/vault.json. - The user runs
vault.js get, causing retrieved secret values to be written to~/.openclaw/vault-cache.json. - The files are created under the permissions allowed by the ambient process umask.
- Another local account or compromised process reads one or both files if their resulting permissions permit access.
- The attacker directly uses cached credentials or submits the stolen V ...[truncated 746 chars]
- A user runs
- Remediation
View remediation
Remediation Suggestions
-
Create both sensitive files with owner-only permissions:
js fs.writeFileSync(CONFIG_PATH, JSON.stringify(cfg, null, 2), { mode: 0o600 }); fs.writeFileSync(CACHE_PATH, JSON.stringify(cache, null, 2), { mode: 0o600 }); -
Apply
fs.chmodSync(file, 0o600)after writing so existing files with unsafe permissions are repaired. -
Ensure
~/.openclawis accessible only to its owner, preferably with mode0700. -
Use atomic writes through a securely created temporary file in the same protected directory, followed by a rename.
-
Refuse or safely handle symbolic links to reduce the risk of writing sensitive data to an unintended target.
-
Consider disabling persistent secret caching by default. If caching is required, remove expired entries from disk and provide a command that securely clears the cache.
-
Where feasible, store the Vault token through an operating-system credential store or secret service rather than a plaintext JSON file.
-
