T09 · Insecure Skill Coding Practices
- Location
scripts/auth.ts:156- Finding
Arbitrary JSON File Deletion Through Profile Logout Path Traversal
- Content
View full analysis
{ const targetHandle = handle || getHandleFromArgs() || getActiveHandle(); if (targetHandle) { const userSessionFile = path.join(sessionsDir, `${targetHandle}.json`); if (fs.existsSync(userSessionFile)) { fs.unlinkSync(userSessionFile); console.log(`✅ Logged out @${targetHandle}`); } ``` ### Technical Analysis The profile handle can originate from the `auth logout` argument or the global `--user` argument. It is interpolated directly into a filesystem path without validating that it is a legitimate Bluesky handle. `path.join()` normalizes traversal components such as `../`. Consequently, a crafted handle can cause `userSessionFile` to resolve outside `sessionsDir`. The forced `.json` suffix restricts the vulnerable operation to filenames ending in `.json`, but it does not guarantee that the target remains inside the intended session directory. No canonical-path containment check is performed before `fs.unlinkSync()` deletes the resolved file. ### Attack Path 1. Identify a JSON file writable by the account running Clawbsky. 2. Calculate a traversal path from `.config/sessions` to the target, omitting the target's `.json` suffix. 3. Invoke a command such as: ```bash clawbsky auth logout "../../../../path/to/target" ``` 4. The application appends `.json`, normalizes the path, checks whether the target exists, and deletes it. 5. No confirmation or containment validation prevents the deletion. ### Impact Assessment An attacker who can control Clawbsky command arguments can delete arbitrary accessible JSON files under the privileges of the Clawbsky process. Potential targets include application configuration, authentication material, persistent Agent state, ...[truncated 226 chars]- Remediation
View remediation
