T09 · Insecure Skill Coding Practices
- Location
index.js:49- Finding
API Token Stored Without Explicitly Restrictive File Permissions
- Content
View full analysis
Vulnerability Details
File Location:
index.js, lines 49-52
Vulnerability Type: Insecure local credential storage
Risk Level: MediumVulnerable Code:
js function saveToken(token) { fs.writeFileSync(TOKEN_FILE, token); console.log(`✅ Token saved to ${TOKEN_FILE}`); }Technical Analysis
The API token returned during agent registration is written to
~/.openproof-tokenwithout an explicit file mode. Consequently, the resulting permissions depend on the process environment and operating-system umask. Under permissive settings, the credential file may be readable by other local users.The token is subsequently placed in the bearer authorization header for authenticated publication requests. A local user who obtains this token could therefore impersonate the registered agent when interacting with the OpenProof API.
Attack Path
- A victim runs
openproof register, causing the API token to be saved in~/.openproof-token. - The process has a permissive umask, resulting in a token file readable by another local account.
- A local attacker reads the contents of that file.
- The attacker submits requests to the OpenProof API using the stolen token as a bearer credential.
- The attacker may publish content under the victim's registered agent identity, subject to the privileges associated with that token.
Impact Assessment
Exploitation requires local access and file-read permissions resulting from permissive file creation settings. It does not directly grant operating-system privilege escalation. However, it can compromise the victim's OpenProof identity and allow unauthorized authenticated API actions, particularly publication under that identity.
- A victim runs
- Remediation
View remediation
Remediation Suggestions
Create the token file with owner-only permissions and verify its state before using it:
js function saveToken(token) { fs.writeFileSync(TOKEN_FILE, token, { encoding: 'utf8', mode: 0o600 }); fs.chmodSync(TOKEN_FILE, 0o600); console.log(`✅ Token saved to ${TOKEN_FILE}`); }Additionally:
- Inspect the destination with
lstatand reject symbolic links before writing. - Where compatible with the intended registration workflow, use exclusive creation to prevent unintended replacement.
- Validate and correct the permissions of existing token files before reading them.
- Avoid printing the token beyond the already truncated registration message.
- Document that the token is a sensitive bearer credential and provide a secure token-revocation procedure.
- Inspect the destination with
