Back to skill

Security audit

Thinking Spark

Security checks for vulnerabilities and agentic risk

Overview

This is a local note-capture skill that stores user thoughts in a JSON file, with some file-safety caveats but no evidence of hidden or malicious behavior.

Install only if you are comfortable storing thought records locally in ~/.openclaw/workspace/collection/思考火花.json. Keep that directory private, avoid running concurrent create/update commands, and consider hardening the scripts to use locked writes and 0600 file permissions.

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 (2)

T09 · Insecure Skill Coding Practices

Warning
Location
scripts/create_spark.py:20
Finding

Predictable Temporary File Permits Symlink-Based File Overwrite and Concurrent Write Races

Content
View full analysis

Vulnerability Details

File Location: scripts/create_spark.py:20-23; scripts/update_spark.py:17-20
Vulnerability Type: Predictable and symlink-following temporary file
Risk Level: Medium

Vulnerable Code

scripts/create_spark.py:20-23:

python
tmp_file = DATA_FILE + ".tmp"
with open(tmp_file, 'w') as f:
    json.dump(data, f, ensure_ascii=False, indent=2)
os.replace(tmp_file, DATA_FILE)

scripts/update_spark.py:17-20:

python
tmp_file = DATA_FILE + ".tmp"
with open(tmp_file, 'w') as f:
    json.dump(data, f, ensure_ascii=False, indent=2)
os.replace(tmp_file, DATA_FILE)

Technical Analysis

Both write operations use the fixed pathname 思考火花.json.tmp. The ordinary open(..., 'w') operation follows symbolic links and truncates the resolved target before writing. If another local process can create or replace this temporary path, it can point the path at another file writable by the user running the skill.

The fixed name also causes all concurrently running create and update operations to use the same temporary file. Because the scripts perform an unlocked read-modify-write sequence, concurrent executions can overwrite each other's temporary data, fail during os.replace, generate duplicate identifiers, or silently lose updates.

Exploitation requires the attacker to have write access to the ~/.openclaw/workspace/collection directory or otherwise control the temporary path. This does not independently cross OS-user privilege boundaries.

Attack Path

  1. The attacker obtains write access to ~/.openclaw/workspace/collection.
  2. The attacker creates 思考火花.json.tmp as a symbolic link to another file writable by the victim account.
  3. The victim invokes create_spark.py or update_spark.py.
  4. open(tmp_file, 'w') follows the symbolic link and truncates the linked target.
  5. The script writes attacker-influenced or application-generated JSON into that targe ...[truncated 1109 chars]
Remediation
View remediation

Remediation Suggestions

  • Create a uniquely named temporary file in the destination directory with tempfile.NamedTemporaryFile(delete=False, dir=destination_directory).
  • Open the temporary file with restrictive permissions, ideally mode 0600.
  • Use protections such as O_NOFOLLOW and O_EXCL where supported to prevent symbolic-link following and pre-existing-file races.
  • Flush Python buffers and call os.fsync() before atomically replacing the destination.
  • Clean up the unique temporary file if serialization or replacement fails.
  • Protect the entire load-modify-save operation with an inter-process file lock. Locking only the final write is insufficient to prevent lost updates and duplicate IDs.
  • Ensure ~/.openclaw/workspace/collection is owned by the intended user and is not writable by other accounts.

T09 · Insecure Skill Coding Practices

Note
Location
scripts/create_spark.py:21
Finding

Thought Records May Be Created with Overly Permissive File Permissions

Content
View full analysis

Vulnerability Details

File Location: scripts/create_spark.py:21; scripts/update_spark.py:18
Vulnerability Type: Insecure permissions on potentially sensitive local data
Risk Level: Low

Vulnerable Code

scripts/create_spark.py:21:

python
with open(tmp_file, 'w') as f:

scripts/update_spark.py:18:

python
with open(tmp_file, 'w') as f:

These statements create the temporary data file without requesting an explicit restrictive permission mode. The subsequent os.replace preserves the temporary file's permissions when it becomes the primary JSON file.

Technical Analysis

Newly created files receive permissions based on the process umask. Under a common umask of 022, the temporary file can be created as mode 0644. After os.replace, the resulting 思考火花.json retains those permissions.

The file is intended to contain personal thought content, tags, confidence values, external references, timestamps, and edit history. If the parent directories allow traversal, other local users may therefore be able to read information that should reasonably be private.

This exposure depends on the runtime umask and permissions of all parent directories. If the user's home and workspace directories are already inaccessible to other users, practical exploitation is prevented by those directory permissions.

Attack Path

  1. The victim executes a create or update script with a permissive umask, such as 022.
  2. The script creates 思考火花.json.tmp without an explicit private mode.
  3. The temporary file receives permissions such as 0644.
  4. os.replace moves that file to 思考火花.json while retaining its permissions.
  5. A local user with traversal access to the parent directories reads the stored thoughts and metadata.

Impact Assessment

The issue can disclose all records stored in the JSON file to other local accounts that can traverse the containing directories. Exposed data ...[truncated 342 chars]

Remediation
View remediation

Remediation Suggestions

  • Create temporary files with mode 0600, for example by using os.open with explicit flags and permissions or a securely configured tempfile.NamedTemporaryFile.
  • After replacement, enforce os.chmod(DATA_FILE, 0o600) so existing permissive files are corrected.
  • Create and validate the collection directory with mode 0700.
  • Verify that the directory and data file are owned by the expected user before writing.
  • Document that the stored records may contain sensitive personal information and should not be placed in a shared directory.
  • Consider rejecting operation when the destination is a symbolic link or has unexpected ownership or permissions.
Vulnerability Patterns
  • MCP Least PrivilegeUnderdeclared Capability, Wildcard Permission, Missing Permission Declaration
  • 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 (6)

Undeclared Tool Scope

Medium
Category
MCP Least Privilege
Confidence
94% confidence
Finding

The skill performs file read/write operations against collection/思考火花.json and references helper scripts, but it does not declare any explicit tool scope such as permissions or allowed-tools. This creates an authorization ambiguity where an agent runtime may permit broader filesystem access than intended, increasing the risk of unintended file modification or data exposure.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
86% confidence
Finding

The file's description, commands, and usage instructions consistently require Chinese-language interaction, but there is no opt-in, alternative language, or justification that the skill is intended only for a Chinese-speaking context. This can violate a language/locale policy that prohibits forcing a specific language without user choice.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

This file contains multiple user-facing strings in Chinese, including the module docstring, default data description, usage text context, and success output. Under the policy, forcing a specific language without user opt-in is a natural-language policy violation, and this file does not provide any alternative locale or opt-in mechanism.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
95% confidence
Finding

The module docstring is written only in Chinese, and the script's user-facing output elsewhere also uses Chinese labels, indicating a fixed language choice. The policy requires flagging language or locale constraints when the skill does not offer user opt-in or document a justified region-specific limitation.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
89% confidence
Finding

The formatted output labels such as 内容, 标签, 关联, and 创建 are hardcoded in Chinese, which constrains the skill to a specific language. There is no visible option for localization or explanation that the skill is intended only for Chinese-speaking users.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
88% confidence
Finding

The module docstring is written only in Chinese ("更新/整理思考火花"), which indicates a language-specific skill presentation without any visible opt-in or explanation that the skill is intended only for a Chinese-speaking context. The policy requires flagging language or locale constraints when the skill does not offer a user choice or clearly justify the restriction.

Content

No source excerpt is available for this finding.

Static analysis

No suspicious patterns detected.