Back to skill

Security audit

Disk Watch

Security checks for vulnerabilities and agentic risk

Overview

DiskWatch does what it says, but its local history file handling has a real file-overwrite risk in shared temp directories.

Review before installing. The skill appears to be a straightforward local disk monitor with no external transmission, but configure historyFile to a private user-owned directory and avoid running it as root or under a privileged service account until the temp-file handling is hardened.

Vulnerability Patterns
  • Insecure Skill Coding PracticesFinds exploitable flaws such as hardcoded secrets or command injection
  • Skill Instruction HijackingAlters the agent's session goals or safety constraints when the skill loads
  • Agent Memory PoisoningWrites attacker-controlled rules into memory that affect later sessions
  • Remote Payload Retrieval and ExecutionFetches external code whose behavior can change after review
  • Embedded Malicious CodeShips malicious scripts inside the skill and executes them locally
Findings (1)

T09 · Insecure Skill Coding Practices

Warning
Location
src/disk-watch.js:17
Finding
Predictable Shared Temporary History File Permits Symlink-Based File Overwrite## Vulnerability Details **File Location**: `src/disk-watch.js:17` and `src/disk-watch.js:161-166` **Vulnerability Type**: Unsafe temporary file handling and symlink following **Risk Level**: Medium ### Vulnerable Code ```javascript this.historyFile = options.historyFile || path.join(os.tmpdir(), 'disk-watch-history.json'); ``` ```javascript _saveHistory(drives) { try { let history = []; try { history = JSON.parse(fs.readFileSync(this.historyFile, 'utf8')); } catch {} history.push({ timestamp: Date.now(), drives }); if (history.length > 168) history = history.slice(-168); // Keep 1 week at hourly fs.writeFileSync(this.historyFile, JSON.stringify(history, null, 2)); } catch {} } ``` ### Technical Analysis DiskWatch stores its history at a fixed, predictable filename under the operating system's shared temporary directory. The code subsequently opens that path with `fs.writeFileSync()`, which follows symbolic links by default. The implementation does not: - Verify the file with `lstat()` before writing. - Confirm that the file is a regular file owned by the current user. - Reject symbolic links. - Create the file exclusively. - Use a private per-user directory with restrictive permissions. - Perform an atomic, securely validated replacement. On systems where another local user can create the predictable path, an attacker can place a symbolic link at that location. If a victim subsequently runs DiskWatch with permissions to modify the symlink target, `_saveHistory()` follows the link and truncates or replaces the target's contents with JSON history data. Exploitability can be reduced by operating-system protections for shared temporary directories, such as sticky-directory and protected-symlink policies, but the application itself does not enforce those protections. ### Attack Path 1. A local attacker determines the temporary directory returned by `os.tmpdir()`. 2. B ...[truncated 1500 chars]
Remediation
## Remediation Suggestions 1. Store history in a private per-user application data directory rather than directly in the shared temporary directory. 2. Create the containing directory with mode `0700` and verify that it is owned by the current user. 3. Before reading or replacing an existing history file, use `fs.lstatSync()` and reject symbolic links, non-regular files, unexpected ownership, and overly permissive modes. 4. Create new files with restrictive permissions such as `0600` and exclusive creation flags where appropriate. 5. Write updates to a securely created temporary file in the same private directory, flush and close it, and then atomically rename it over the validated history file. 6. Where supported, use no-follow filesystem semantics when opening files. Do not rely solely on a separate check followed by an open, because that introduces a time-of-check/time-of-use race. 7. Avoid silently swallowing history I/O and validation errors. Surface or log security-relevant failures so unsafe path conditions can be diagnosed. 8. If callers provide `historyFile`, document that the path must reside in a trusted directory and apply the same ownership, file-type, and symlink validation.
Vulnerability Patterns
  • Excessive AgencyUnrestricted Tool Access, Autonomous Decision Making, Scope Creep
  • Prompt InjectionInstruction Override, Hidden Instructions, Exfiltration Commands
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • Privilege EscalationExcessive Permissions, Sudo/Root Execution, Credential Access
  • Supply ChainUnpinned Dependencies, External Script Fetching, Obfuscated Code
Findings (2)

Scope Creep

Low
Category
Excessive Agency
Content
**USE AT YOUR OWN RISK.**

- The author(s) are NOT liable for any damages, losses, or consequences arising from 
  the use or misuse of this software — including but not limited to financial loss, 
  data loss, security breaches, business interruption, or any indirect/consequential damages.
- This software does NOT constitute financial, legal, trading, or professional advice.
- Users are solely responsible for evaluating whether this software is suitable for
Confidence
70% confidence
Finding
Skill's behavior or capabilities extend beyond its stated purpose. Scope creep allows an agent to perform actions unrelated to its documented functionality, increasing the attack surface.

Scope Creep

Low
Category
Excessive Agency
Content
**USE AT YOUR OWN RISK.**

- The author(s) are NOT liable for any damages, losses, or consequences arising from 
  the use or misuse of this software — including but not limited to financial loss, 
  data loss, security breaches, business interruption, or any indirect/consequential damages.
- This software does NOT constitute financial, legal, trading, or professional advice.
- Users are solely responsible for evaluating whether this software is suitable for
Confidence
70% confidence
Finding
Skill's behavior or capabilities extend beyond its stated purpose. Scope creep allows an agent to perform actions unrelated to its documented functionality, increasing the attack surface.

Static analysis

No suspicious patterns detected.