T09 · Insecure Skill Coding Practices
- Location
scripts/flows/run_config_openkey_flow.mjs:32- Finding
OpenKey Credential File Is Written Without Restrictive Permissions
- Content
View full analysis
{ if (line.startsWith("KUNGFU_OPENKEY=")) { replaced = true; return `KUNGFU_OPENKEY=${openkey}`; } return line; }); if (!replaced) { updated.push(`KUNGFU_OPENKEY=${openkey}`); } const finalContent = updated.join("\n").replace(/\n{3,}/g, "\n\n").trimEnd() + "\n"; writeFileSync(OPENCLAW_ENV_PATH, finalContent, "utf-8"); ``` ### Technical Analysis The configuration flow stores `KUNGFU_OPENKEY` as plaintext in `~/.openclaw/.env`. Persisting this credential is part of the declared configuration functionality, but the file is created without an explicit owner-only permission mode. `writeFileSync()` therefore relies on the process umask. Under a common `022` umask, a newly created file can receive mode `0644`, making it readable by other local users. If the file already exists with permissive permissions, the implementation also does not correct those permissions. The containing directory is likewise created without an explicit `0700` mode. Although an existing `~/.openclaw` directory may already be protected, the code does not enforce that security boundary. The flow also performs a check followed by a path-based write without checking whether the destination is a symbolic link. In a locally compromised or shared environment, this can enable redirection of the write to another file writable by the victim account. ### Attack Path 1. A user runs the documented `config-openkey` command with a valid credential. 2. The Skill validates the credential against the ...[truncated 1137 chars]- Remediation
View remediation
