Back to skill

Security audit

Nex Decision Journal

Security checks for vulnerabilities and agentic risk

Overview

This is a local decision-journal skill, but it needs review because export paths are not contained and broad triggers could access sensitive journal data unexpectedly.

Review commands before letting an agent run this skill, especially export commands. Until the export path handling is fixed, use only simple filenames such as reviewed_decisions.csv and avoid any output path containing slashes, backslashes, or .. . Be aware the journal may contain sensitive business or personal reasoning stored locally in plaintext SQLite/export files.

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
nex-decision-journal.py:582
Finding

Arbitrary User-Writable File Overwrite via Export Path Traversal

Content
View full analysis

Vulnerability Details

File Location: nex-decision-journal.py, lines 582–586
Vulnerability Type: Unrestricted export path / path traversal leading to arbitrary file overwrite
Risk Level: Medium

Vulnerable Code

python
output_file = args.output or f"decisions_export.{args.format}"
output_path = EXPORT_DIR / output_file

with open(output_path, 'w', encoding='utf-8') as f:
    f.write(data)

Technical Analysis

The --output argument is used directly to construct the export destination without validating that it is a simple filename or confirming that the resolved destination remains inside EXPORT_DIR.

Python's pathlib path composition does not provide containment by itself:

  • An absolute output_file causes the intended EXPORT_DIR prefix to be discarded.
  • A relative value containing .. components can traverse outside the export directory.
  • Opening the destination with mode w creates the file if absent and truncates it if it already exists.

Consequently, an attacker who can influence the command arguments can direct JSON or CSV export data into any file writable by the account executing the Skill.

Attack Path

  1. The journal contains at least one decision, ensuring that export_decisions() returns non-empty data.

  2. An attacker influences the user or Agent to run an export command with a crafted destination, such as:

    bash
    nex-decision-journal export json --output ../../target-file
    

    An absolute user-writable path could also be supplied.

  3. The application combines the untrusted value with EXPORT_DIR but does not resolve and validate the resulting path.

  4. open(output_path, 'w') creates or truncates the selected target.

  5. Serialized decision-journal data is written over the target file.

Impact Assessment

Exploitation is limited to the filesystem privileges of the user running the Skill; no privilege escalation was identified. ...[truncated 692 chars]

Remediation
View remediation

Remediation Suggestions

Restrict exports to the configured export directory and prevent silent replacement of existing files:

  1. Reject absolute output paths.
  2. Prefer accepting only a filename, rejecting /, \, ./.. path components, and platform-specific path separators.
  3. Resolve both the export root and destination, then verify containment before opening the file.
  4. Create EXPORT_DIR before validation and account for symlinks.
  5. Use exclusive creation mode (x) by default, or require explicit confirmation or an --overwrite option before replacing an existing file.
  6. Return a clear error when validation fails.

Example hardening:

python
export_root = EXPORT_DIR.resolve()
output_file = args.output or f"decisions_export.{args.format}"

if Path(output_file).is_absolute():
    raise ValueError("Output must be a filename inside the export directory")

output_path = (export_root / output_file).resolve()

try:
    output_path.relative_to(export_root)
except ValueError:
    raise ValueError("Output path escapes the export directory")

if output_path.exists():
    raise FileExistsError(
        f"Export destination already exists: {output_path}"
    )

with open(output_path, "x", encoding="utf-8") as f:
    f.write(data)

If subdirectories are not required, enforce Path(output_file).name == output_file and write only directly beneath EXPORT_DIR. For stronger protection against symlink races, use descriptor-relative filesystem operations and prohibit following symlinks where the operating system supports those controls.

Vulnerability Patterns
  • Privilege EscalationExcessive Permissions, Sudo/Root Execution, Credential Access
  • Excessive AgencyUnrestricted Tool Access, Autonomous Decision Making, Scope Creep
  • Trigger AbuseOverly Broad Trigger, Shadow Command Trigger, Keyword Baiting Trigger
  • MCP Least PrivilegeUnderdeclared Capability, Wildcard Permission, Missing Permission Declaration
  • MCP Tool PoisoningHidden Instructions, Unicode Deception, Parameter Description Injection
Findings (8)

Tp4

High
Category
MCP Tool Poisoning
Confidence
98% confidence
Finding

The description claims a full-featured decision journaling application with SQLite storage, search, analytics, export, scheduling, and reflection tools. The provided code chunk does not implement any of these features; it is only an empty package initializer comment. This is a material description-to-code mismatch because the actual code shown does not substantiate the declared primary purpose. There are no undeclared malicious capabilities evident, but the declared functionality is not represented by the supplied code.

Content

No source excerpt is available for this finding.

Undeclared Tool Scope

Medium
Category
MCP Least Privilege
Confidence
91% confidence
Finding

The skill advertises executable setup and CLI usage that require shell access, local file writes, and environment interaction, but it does not declare any explicit tool scope such as allowed tools or permissions. This creates a least-privilege failure: an agent may invoke broader capabilities than users or the platform expect, increasing the chance of unintended command execution or filesystem modification.

Content

No source excerpt is available for this finding.

Vague Triggers

Medium
Category
Not specified by scanner
Confidence
97% confidence
Finding

The trigger phrases include broad, common language such as 'decision', 'deciding', and especially 'should I', which can match ordinary conversation far outside the intended context. Overbroad auto-invocation can cause the agent to launch shell-backed logging or retrieval commands unexpectedly, exposing sensitive personal/business data from the local journal or causing unintended writes.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
89% confidence
Finding

The delete_decision function permanently removes records from both the FTS index and the main decisions table, but the code provides no confirmation prompt, logging, print statement, or nearby warning comment beyond a minimal docstring. For a destructive and irreversible operation in a code file, this lacks visible user disclosure as required by the rule.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
93% confidence
Finding

The export command writes all decision data, which may include context, reasoning, predictions, and lessons learned, to a file on disk. Although the action is intentional, the code provides no warning, confirmation, or privacy notice that this operation creates a persistent plaintext export of potentially sensitive personal or organizational information.

Content

No source excerpt is available for this finding.

Sudo/Root Execution

Medium
Category
Privilege Escalation
Confidence
80% confidence
Finding

Commands invoke sudo or root privileges. Verify this elevated access is necessary and justified.

Content

Scanner excerpt · setup.sh (reported line 75)May include surrounding context.

sh
# Set permissions (non-Windows only)
if [[ "$(uname)" != MINGW* ]] && [[ "$(uname)" != MSYS* ]] && [[ "$(uname)" != CYGWIN* ]]; then
    chmod 700 "$DATA_DIR" 2>/dev/null || true
    chmod 700 "$DATA_DIR/exports" 2>/dev/null || true
fi

Sudo/Root Execution

Medium
Category
Privilege Escalation
Confidence
80% confidence
Finding

Commands invoke sudo or root privileges. Verify this elevated access is necessary and justified.

Content

Scanner excerpt · setup.sh (reported line 76)May include surrounding context.

sh
# Set permissions (non-Windows only)
if [[ "$(uname)" != MINGW* ]] && [[ "$(uname)" != MSYS* ]] && [[ "$(uname)" != CYGWIN* ]]; then
    chmod 700 "$DATA_DIR" 2>/dev/null || true
    chmod 700 "$DATA_DIR/exports" 2>/dev/null || true
fi

Context-Inappropriate Capability

Low
Category
Not specified by scanner
Confidence
82% confidence
Finding

The manifest describes a local decision journal stored in SQLite, with logging, search, reflection, and export features. Creating an executable wrapper under ~/.local/bin modifies the user's shell toolchain/environment convenience layer, which is not necessary to the core journaling capability and is not described in the manifest.

Content

No source excerpt is available for this finding.