Back to skill

Security audit

安全文件编辑器

Security checks for vulnerabilities and agentic risk

Overview

This file-editing skill is coherent, but it needs review because its advertised safety controls are not fully enforced and its implementation can mishandle sensitive or important files.

Install only if you are comfortable reviewing each diff yourself and treating this as a convenience helper, not an enforced safety boundary. Avoid using it on secrets, credentials, or sensitive configuration until the confirmation check, temporary-file handling, backup uniqueness, metadata preservation, and logging behavior are fixed.

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

T09 · Insecure Skill Coding Practices

Error
Location
safe_file_editor.py:127
Finding

Predictable Temporary File Path Permits Symlink-Based File Overwrite

Content
View full analysis
Remediation
View remediation

T09 · Insecure Skill Coding Practices

Warning
Location
safe_file_editor.py:127
Finding

Atomic Replacement Can Weaken Target File Permissions

Content
View full analysis
Remediation
View remediation

T09 · Insecure Skill Coding Practices

Warning
Location
safe_file_editor.py:105
Finding

Plaintext Edit Logging May Disclose Secrets and Allow Log Injection

Content
View full analysis
50 else f"- {old_text}\n+ {new_text}" ``` ```python def log_edit(file_path: str, action: str, hash_before: str, hash_after: str, changes: str, backup_path: Optional[Path] = None): """记录编辑日志""" SAFE_EDIT_LOG.parent.mkdir(parents=True, exist_ok=True) timestamp = datetime.now().isoformat() log_entry = f"[{timestamp}] {action}: {file_path} | {hash_before[:8]}->{hash_after[:8]} | {changes[:100]}" with open(SAFE_EDIT_LOG, 'a', encoding='utf-8') as f: f.write(log_entry + "\n") ``` ### Technical Analysis The audit logger persists up to 100 characters of the edit description, which contains caller-controlled portions of both `old_text` and `new_text`. Edits to passwords, tokens, connection strings, private keys, or other sensitive configuration can therefore copy those values into a separate plaintext log. The content is also written without escaping newline or other control characters. An attacker controlling edit text or a file path may inject additional lines that resemble legitimate audit records, reducing the integrity and reliability of the log. The logger creates the log and parent directory without explicitly enforcing restrictive permissions. ### Attack Path 1. Cause the editor to replace text containing a secret, or supply crafted text containing newline characters and a forged log entry. 2. Invoke either preview or commit mode; both paths call `log_edit()`. 3. The raw text fragment is appended to `safe-file-editor.log`. 4. A local user or process with access to the log reads the secret, or an operator interprets the injected line as a legitimate event. ### Impact Assessment The vulnerability may expose credentials or sensitive configur ...[truncated 269 chars]
Remediation
View remediation

T09 · Insecure Skill Coding Practices

Warning
Location
safe_file_editor.py:154
Finding

Backup Filename Collisions Can Overwrite Recovery Data

Content
View full analysis
Path: """创建备份文件""" ensure_backup_dir() timestamp = datetime.now().strftime("%Y%m%d-%H%M%S") backup_name = f"{file_path.stem}-{timestamp}{file_path.suffix}.bak" backup_path = BACKUP_DIR / backup_name shutil.copy2(file_path, backup_path) return backup_path ``` ### Technical Analysis All backups are stored in one centralized directory, while each filename contains only the source file stem, suffix, and a timestamp with one-second precision. The original directory path is not represented. Two different source files with the same basename and extension will produce the same backup path if edited during the same second. Repeated edits to one file during the same second have the same issue. Because `shutil.copy2()` does not use exclusive destination creation, a later operation overwrites the earlier backup. This violates the backup system's integrity guarantee and can cause rollback to restore unrelated or stale content. ### Attack Path 1. Prepare two distinct files named `config.json` in different directories. 2. Trigger committed edits to both files within the same second. 3. Both operations calculate the same centralized backup filename. 4. The second backup overwrites the first. 5. Attempt to roll back the first file using the reported path. 6. Content from the second file is restored into the first file, or the intended recovery data is no longer available. ### Impact Assessment The issue can cause loss of backup data, incorrect rollback, cross-file data contamination, and service misconfiguration. It primarily affects integrity and availability. If one file contains sensitive data, incorrect restoration may also disclose that data through another file. ]]>
Remediation
View remediation

T09 · Insecure Skill Coding Practices

Warning
Location
safe_file_editor.py:232
Finding

Executable Demonstration Uses an Unsafe Predictable Path in the Shared Temporary Directory

Content
View full analysis
Remediation
View remediation
Vulnerability Patterns
  • Trigger AbuseOverly Broad Trigger, Shadow Command Trigger, Keyword Baiting Trigger
  • MCP Tool PoisoningHidden Instructions, Unicode Deception, Parameter Description Injection
  • Prompt InjectionInstruction Override, Hidden Instructions, Exfiltration Commands
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • Privilege EscalationExcessive Permissions, Sudo/Root Execution, Credential Access
Findings (5)

Vague Triggers

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

The skill declares it should be used for essentially any file modification operation, which is an overly broad trigger for a high-impact capability. In agent environments, broad activation criteria can cause the editor to be invoked in inappropriate contexts, increasing the chance of unintended file writes, confirmation bypass patterns, or misuse on sensitive files despite the documented dry-run safeguards.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

The primary natural-language documentation and descriptions in the module are written exclusively in Chinese, including the module title and core design notes. This imposes a locale/language constraint without offering a user choice or stating a justified region-specific scope, which matches the language-policy violation criteria.

Content

No source excerpt is available for this finding.

Intent-Code Divergence

Medium
Category
Not specified by scanner
Confidence
97% confidence
Finding

The module-level documentation explicitly claims a '4-eyes principle' and secondary confirmation, but the implementation performs writes whenever dry_run=False without any approval workflow. This mismatch can cause callers to trust the tool's safety properties and permit edits that occur without the expected human verification, increasing the chance of unauthorized or accidental file modification.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
78% confidence
Finding

The file mixes Chinese documentation with prescriptive English phrases such as 'always dry_run first' and 'show complete diff' in the best-practices section, without stating that language is optional or user-selectable. This can amount to an implicit language constraint rather than offering a locale choice.

Content

No source excerpt is available for this finding.

Intent-Code Divergence

Low
Category
Not specified by scanner
Confidence
97% confidence
Finding

The constructor exposes require_confirmation as if it controls a security boundary, but the value is never checked before modifying files. This creates a false sense of protection for integrators who may instantiate the editor expecting confirmation enforcement, while the code still allows direct writes.

Content

No source excerpt is available for this finding.