Back to skill

Security audit

Indesign-script-for-manga-typesetting

Security checks for vulnerabilities and agentic risk

Overview

The skill is coherent InDesign automation, but Review is warranted because trusted-looking configuration files can trigger local script/helper execution without strong trust checks.

Install only if you trust the skill source and the configuration directories you will use. Do not run config_editor.py run or open configs from downloaded/shared folders unless you have checked for companion run_manga_layout.sh/ps1 files and reviewed any segmentation.pythonScriptPath value. Back up InDesign documents before running automation and disable segmentation if you do not need the external helper.

Vulnerability Patterns
  • Tool Hijacking and SpoofingModifies or replaces tools so legitimate-looking calls execute attacker logic
  • 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
Findings (3)

T07 · Tool Hijacking and Spoofing

Error
Location
src/config_editor.py:371
Finding

Untrusted Configuration Directory Can Override the Manga Layout Launcher

Content
View full analysis

Vulnerability Details

File Location: src/config_editor.py:371-385, 398-424
Vulnerability Type: Untrusted local tool resolution and execution
Risk Level: High

Vulnerable Code

python
def find_run_script(config_path):
    script_dir = os.path.dirname(os.path.abspath(__file__))
    config_dir = os.path.dirname(os.path.abspath(config_path))
    if os.name == "posix":
        candidates = [
            os.path.join(config_dir, "run_manga_layout.sh"),
            os.path.join(script_dir, "run_manga_layout.sh"),
        ]
    else:
        candidates = [
            os.path.join(config_dir, "run_manga_layout.ps1"),
            os.path.join(script_dir, "run_manga_layout.ps1"),
        ]
    for path in candidates:
        if os.path.exists(path):
            return path
    return None


def get_run_command(script_path):
    if script_path.endswith(".sh"):
        return ["/bin/bash", script_path]
    return ["powershell", script_path]


def cli_run(args):
    config_path = args.config or find_default_config()
    if not config_path or not os.path.exists(config_path):
        print("Error: configuration file not found", file=sys.stderr, flush=True)
        sys.exit(1)

    script_path = find_run_script(config_path)
    if not script_path:
        script_name = "run_manga_layout.sh" if os.name == "posix" else "run_manga_layout.ps1"
        print(f"Error: script file not found: {script_name}", file=sys.stderr, flush=True)
        sys.exit(1)

    script_dir = os.path.dirname(script_path)
    target_config = os.path.join(script_dir, "manga_layout_config.json")
    try:
        abs_source = os.path.abspath(config_path)
        abs_target = os.path.abspath(target_config)
        if abs_source != abs_target:
            shutil.copyfile(config_path, target_config)
    except Exception as e:
        print(f"Error: failed to copy configuration into execution directo
...[truncated 2313 chars]
Remediation
View remediation

Remediation Suggestions

  • Resolve launchers exclusively from the trusted directory containing config_editor.py.
  • Canonicalize the selected path with os.path.realpath() and verify that it remains under the trusted project directory.
  • Check that the selected path is a regular file rather than only testing os.path.exists().
  • Do not automatically execute a launcher located beside an externally supplied configuration.
  • If external launchers are an intentional feature, require a separate explicit option, display the exact path, obtain user confirmation, and verify an approved digital signature or cryptographic digest.
  • On Windows, invoke PowerShell with an explicit file argument, such as powershell -File <trusted-path>, and apply an appropriate execution policy.
  • Add tests proving that a configuration directory containing a same-named launcher cannot override the bundled launcher.

T09 · Insecure Skill Coding Practices

Warning
Location
src/manga_layout.jsx:1931
Finding

Configuration-Controlled External Segmentation Helper Execution

Content
View full analysis

Vulnerability Details

File Location: src/manga_layout.jsx:1931-1947
Vulnerability Type: Unvalidated execution of a configuration-selected helper
Risk Level: Medium

Vulnerable Code

javascript
// Get the Python script path
var scriptPath = File($.fileName).parent.fsName;
var pythonScript;
if (config.segmentation.pythonScriptPath) {
    pythonScript = new File(config.segmentation.pythonScriptPath);
} else {
    pythonScript = new File(scriptPath + "/jieba_pytojs.pyw");
}

// Check whether the Python script exists
if (!pythonScript.exists) {
    if (inputFile.exists) inputFile.remove();
    return new StepResult(false, "Python segmentation script does not exist: " + pythonScript.fsName);
}

// Execute the Python script
pythonScript.execute('"' + inputFile.fsName + '" "' + outputFile.fsName + '"');

Technical Analysis

The segmentation.pythonScriptPath configuration field is treated as an executable helper path. The implementation verifies only that the target exists before invoking ExtendScript's File.execute() method.

There is no restriction to a trusted project directory, expected filename, approved interpreter, signature, or known cryptographic digest. There is also no confirmation that distinguishes opening local content from executing an external helper. Consequently, an untrusted or tampered configuration can redirect execution to an attacker-controlled local script or executable.

The fixed temporary-file arguments are quoted, so the demonstrated issue is not dependent on argument metacharacter injection. The vulnerability is the direct trust placed in the configured executable path.

Attack Path

  1. An attacker places a malicious executable or executable script at a location accessible to the victim.
  2. The attacker supplies or modifies the layout configuration so that:
    json
    {
      "segmentation": {
        "enabled": true,
        "pythonScrip
    

...[truncated 633 chars]

Remediation
View remediation

Remediation Suggestions

  • Remove configuration-based executable selection and use a fixed, bundled helper.
  • Canonicalize the helper path and require it to reside inside an approved project directory.
  • Verify the helper against a pinned cryptographic digest or trusted code signature before execution.
  • If custom helpers are required, present the resolved path and require explicit user confirmation for every untrusted helper.
  • Validate that the target is an expected regular file and reject symbolic-link or path-redirection cases where supported.
  • Prefer launching a pinned Python interpreter with a trusted script rather than relying on generic file association behavior.
  • Document that configuration files are active content and must not be accepted from untrusted sources without review.

T09 · Insecure Skill Coding Practices

Note
Location
src/manga_layout.jsx:1915
Finding

Predictable Shared Temporary Files Expose and Permit Manipulation of Manuscript Data

Content
View full analysis

Vulnerability Details

File Location: src/manga_layout.jsx:1915-1926, 1952-1980
Vulnerability Type: Insecure temporary-file handling
Risk Level: Low

Vulnerable Code

javascript
// Create temporary files
var tempFolder = Folder.temp;
var inputFile = new File(tempFolder.fsName + "/jieba_temp_input.txt");
var outputFile = new File(tempFolder.fsName + "/jieba_temp_output.txt");

// Write text content
inputFile.encoding = "UTF-8";
inputFile.open("w");
for (var i = 0; i < textFrames.length; i++) {
    var content = textFrames[i].parentStory.contents;
    content = content.replace(/[\r\n]/g, "");
    inputFile.write(content + "\n");
}
inputFile.close();

// Wait for the output file
var maxWait = 30000;
var waited = 0;
while (!outputFile.exists && waited < maxWait) {
    delay(500);
    waited += 500;
}

if (!outputFile.exists) {
    if (inputFile.exists) inputFile.remove();
    return new StepResult(false, "Python segmentation script timed out");
}

// Read the result
outputFile.encoding = "UTF-8";
outputFile.open("r");
var segmentedContent = outputFile.read();
outputFile.close();

// Apply the result
var contentLines = segmentedContent.split("\n");
var processedCount = 0;
for (var j = 0; j < textFrames.length && j < contentLines.length; j++) {
    var processedContent = contentLines[j].replace(/\\r/g, "\n");
    textFrames[j].parentStory.contents = processedContent || '';
    processedCount++;
}

if (inputFile.exists) inputFile.remove();
if (outputFile.exists) outputFile.remove();

Technical Analysis

Every invocation uses the same two filenames in the shared system temporary directory. The code neither creates a per-run private directory nor uses unpredictable names or exclusive creation. It also accepts an output file based only on its existence, without validating its provenance, freshness, ownership, or permissions.

A concurrent process ...[truncated 1236 chars]

Remediation
View remediation

Remediation Suggestions

  • Create a unique, cryptographically unpredictable temporary directory for each run.
  • Restrict directory and file permissions to the current user where the runtime permits it.
  • Use randomized input and output filenames and pass those exact paths to the helper.
  • Ensure files are created exclusively rather than overwriting pre-existing paths.
  • Remove any pre-existing output before launching the helper and verify output creation time and file type before reading it.
  • Avoid following symbolic links or other redirections where platform APIs permit such checks.
  • Place cleanup in a guaranteed finalization path so files are removed after success, failure, cancellation, or timeout.
  • Consider passing data through a secure process pipe instead of shared temporary files.
Vulnerability Patterns
  • Prompt InjectionInstruction Override, Hidden Instructions, Exfiltration Commands
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • Excessive AgencyUnrestricted Tool Access, Autonomous Decision Making, Scope Creep
  • Output HandlingUnvalidated Output Injection, Cross-Context Output, Unbounded Output
  • Trigger AbuseOverly Broad Trigger, Shadow Command Trigger, Keyword Baiting Trigger
Findings (18)

Hidden Instructions

High
Category
Prompt Injection
Confidence
60% confidence
Finding

Hidden instructions were detected in comments or invisible text. These could contain malicious directives. Manual review is recommended.

Content

Scanner excerpt · SKILL.md (reported line 1)May include surrounding context.

md
---
name: Indesign-script-for-claw
description: 基于用户排版需求自动生成适用于Adobe InDesign的脚本,支持通用排版与漫画嵌字自动化处理,兼容Windows和Mac平台。
version: 1.1.5

Unvalidated Output Injection

High
Category
Output Handling
Confidence
94% confidence
Finding

The call pythonScript.execute('"' + inputFile.fsName + '" "' + outputFile.fsName + '"') constructs an execution string from file-system paths without robust escaping or validation. If those paths contain shell- or command-interpreter-significant characters, or if the host resolves execution through a command shell, this can enable command/argument injection or unintended execution behavior.

Content

Scanner excerpt · src/manga_layout.jsx (reported line 1947)May include surrounding context.

jsx
}
        
        // 执行Python脚本
        pythonScript.execute('"' + inputFile.fsName + '" "' + outputFile.fsName + '"');
        
        // 等待输出文件(最多30秒)
        var maxWait = 30000;

Context-Inappropriate Capability

Medium
Category
Not specified by scanner
Confidence
92% confidence
Finding

The tool is presented primarily as a configuration editor, but it also includes the ability to execute external shell/PowerShell scripts. In an agent or automation context, that broadens the trust boundary: a caller expecting safe config manipulation may unintentionally trigger arbitrary local code execution by invoking the run feature against a directory containing a malicious companion script.

Content

No source excerpt is available for this finding.

Context-Inappropriate Capability

Medium
Category
Not specified by scanner
Confidence
96% confidence
Finding

The CLI run command copies the selected configuration into the script directory and then executes a discovered shell/PowerShell script from either the config directory or source directory. In agent settings, this creates a code-execution primitive tied to user-controlled filesystem placement, making the feature materially more dangerous than a normal config editor.

Content

No source excerpt is available for this finding.

subprocess module call

Medium
Category
Dangerous Code Execution
Confidence
70% confidence
Finding

subprocess module calls execute external commands. Without careful input validation, this enables command injection.

Content

Scanner excerpt · src/config_editor.py (reported line 424)May include surrounding context.

python
popen_kwargs = {"cwd": script_dir}
        if os.name != "posix":
            popen_kwargs["creationflags"] = subprocess.CREATE_NEW_CONSOLE
        subprocess.Popen(cmd, **popen_kwargs)
        print(f"已启动脚本: {script_path} (使用配置: {target_config})", flush=True)
    except Exception as e:
        print(f"错误: 启动脚本失败: {e}", file=sys.stderr, flush=True)

subprocess module call

Medium
Category
Dangerous Code Execution
Confidence
70% confidence
Finding

subprocess module calls execute external commands. Without careful input validation, this enables command injection.

Content

Scanner excerpt · src/config_editor.py (reported line 744)May include surrounding context.

python
popen_kwargs = {"cwd": script_dir}
        if os.name != "posix":
            popen_kwargs["creationflags"] = subprocess.CREATE_NEW_CONSOLE
        subprocess.Popen(cmd, **popen_kwargs)
        print(f"已启动脚本: {script_path} (使用配置: {target_config})", flush=True)
    except Exception as e:
        print(f"错误: 启动脚本失败: {e}", file=sys.stderr, flush=True)

Context-Inappropriate Capability

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

The GUI exposes a one-click action that runs an external script discovered in the config or source directory. Because the path is derived from the opened configuration location, a user opening an untrusted project folder could end up executing a malicious local script with minimal friction.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
93% confidence
Finding

The GUI launches external code immediately without any user-facing warning, path display, or consent step. That increases the likelihood of accidental execution of untrusted scripts, especially when users open configuration files from shared or downloaded project folders.

Content

No source excerpt is available for this finding.

Intent-Code Divergence

Medium
Category
Not specified by scanner
Confidence
86% confidence
Finding

The header describes a headless manga layout automation script focused on document/layout operations. Later, the script invokes an external Python program for segmentation at L1903-L1947, which is a materially different execution behavior than purely internal automation. This is a meaningful intent/documentation divergence because external execution expands operational behavior beyond the documented steps.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
85% confidence
Finding

The script’s natural-language metadata and operational strings are entirely oriented around Chinese usage, including Chinese-only naming and workflow assumptions for manga localization. There is no indication that users can choose language or locale, nor any explicit justification that the skill is intentionally limited to a Chinese-language environment.

Content

No source excerpt is available for this finding.

Context-Inappropriate Capability

Medium
Category
Not specified by scanner
Confidence
90% confidence
Finding

The script executes an external Python file from a configurable path or a local relative path, which expands trust beyond the JSX file itself. If an attacker can replace the Python script, alter the configuration, or place a malicious helper in the expected location, arbitrary code execution occurs under the user's privileges when segmentation runs.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
93% confidence
Finding

At the execution site, document text is exported to a temporary file and passed to an external Python process without any explicit warning or consent. This creates a confidentiality boundary crossing: sensitive manuscript text leaves the InDesign scripting context and is processed by another executable component that may be modified, monitored, or behave unexpectedly.

Content

No source excerpt is available for this finding.

Context-Inappropriate Capability

Medium
Category
Not specified by scanner
Confidence
92% confidence
Finding

The script accepts a user-supplied path and passes it directly to InDesign's DoScript COM method, which executes the referenced JSX file. This expands the skill from running a fixed bundled script to executing arbitrary local or network-accessible code, creating a code-execution primitive if an attacker can influence the argument or convince a user/agent to run an untrusted script.

Content

No source excerpt is available for this finding.

Missing User Warnings

Low
Category
Not specified by scanner
Confidence
91% confidence
Finding

The skill explicitly instructs the agent to modify configuration files and execute commands that can affect user documents and InDesign project state, but it does not prominently warn that these actions may change files, trigger automation, or overwrite outputs. In a document-automation skill this is expected behavior, but the lack of explicit modification/backup warnings can still lead to unintended changes or data loss if the user misunderstands what will be altered.

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 and user-facing CLI/GUI text are written in Chinese throughout, with no indication that language is selectable or that the tool is intentionally limited to a Chinese-speaking context. This creates a natural-language locale constraint without opt-in, which matches the policy-violation category for forced language/locale behavior.

Content

No source excerpt is available for this finding.

Intent-Code Divergence

Low
Category
Not specified by scanner
Confidence
97% confidence
Finding

The comment at L0034 says log entries are appended to a file and 'not output to console'. However, the actual logging path calls $.writeln in logMessage at L2554, and many code paths invoke logMessage. This is an active contradiction between documentation and behavior.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
91% confidence
Finding

This JSON manifest contains user-facing natural-language descriptions in Chinese, starting at L008 and repeated in several other description fields. Because the file does not indicate that the skill is Chinese-only or offer any language/locale opt-in, it can violate a language/locale policy requiring user choice or explicit justification.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
96% confidence
Finding

The shell script includes Chinese-only error messages at L48, L58, and L63, which imposes a specific language on users. Under the stated policy, forcing a language without user opt-in or documented justification is a natural-language policy violation.

Content

No source excerpt is available for this finding.