Back to skill

Security audit

Protein Sequence Qc Pro

Security checks for vulnerabilities and agentic risk

Overview

This skill is related to protein analysis, but it ignores documented user-selected paths, writes to hard-coded root-directory locations, and uses unsafe shell command execution.

Review before installing. Use this only in a disposable, unprivileged environment with no sensitive files accessible, and expect it to operate on hard-coded IRED paths unless the scripts are fixed to honor explicit input and output directories.

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/run_complete_qc.py:41
Finding
Shell Command Injection Through Unquoted Path Interpolation## Vulnerability Details **File Location**: `scripts/run_complete_qc.py`, lines 41–45, 119–126, 240–246, and 273–278 **Vulnerability Type**: OS command injection **Risk Level**: Medium ### Vulnerable Code ```python def run_command(cmd, description): """运行命令并记录""" log(f"开始: {description}") log(f"命令: {cmd}") result = subprocess.run(cmd, shell=True, capture_output=True, text=True) ``` ```python cmd = f""" cd-hit -i {input_file} \ -o {output_file} \ -c 0.90 \ -n 5 \ -M 0 \ -T 8 """ if not run_command(cmd, "CD-HIT 去冗余"): return None ``` ```python cmd = f""" mafft --localpair \ --maxiterate 1000 \ --thread 8 \ {input_file} 1> {output_file} 2> {log_file} """ if not run_command(cmd, "MAFFT 多序列比对"): return None ``` ```python cmd = f""" trimal -in {input_file} \ -out {output_file} \ -automated1 """ if not run_command(cmd, "trimAl 比对修剪"): return None ``` ### Technical Analysis The pipeline constructs shell commands by directly interpolating `input_file`, `output_file`, and `log_file` into command strings. These strings are passed to `subprocess.run` with `shell=True`. Shell metacharacters contained in an interpolated path are consequently interpreted as shell syntax rather than as part of a filename. Relevant metacharacters include semicolons, command substitutions, pipes, redirection operators, and newline characters. The bundled `main()` currently obtains its initial input from a hardcoded path, which limits direct exploitation through the documented command line. However, the stage functions are ordinary module-level functions and can be imported and called with attacker-controlled path-like values. Future implementation of the documented input arguments would also make the flaw directly reachable unless command execution is corrected. ### Attack Path 1. A ...[truncated 1228 chars]
Remediation
## Remediation Suggestions 1. Remove `shell=True` and pass every executable and argument as a separate list element: ```python def run_command(cmd, description, stdout=None, stderr=None): log(f"Starting: {description}") result = subprocess.run( cmd, shell=False, stdout=stdout, stderr=stderr, text=True, check=False, ) return result.returncode == 0 ``` 2. Construct CD-HIT and trimAl invocations as argument arrays: ```python cmd = [ "cd-hit", "-i", str(input_file), "-o", str(output_file), "-c", "0.90", "-n", "5", "-M", "0", "-T", "8", ] ``` 3. Handle MAFFT output redirection through Python file handles rather than shell operators: ```python cmd = [ "mafft", "--localpair", "--maxiterate", "1000", "--thread", "8", str(input_file), ] with output_file.open("w") as output_handle, log_file.open("w") as log_handle: result = subprocess.run( cmd, shell=False, stdout=output_handle, stderr=log_handle, text=True, check=False, ) ``` 4. Validate that input files exist and are regular files before execution. 5. Resolve and validate output paths against the selected output directory. 6. Avoid attempting to secure shell commands solely through manual quoting; argument arrays provide the appropriate command/argument boundary. 7. Run the pipeline under a dedicated, unprivileged account with access limited to the required input and output directories.

T09 · Insecure Skill Coding Practices

Note
Location
scripts/run_complete_qc.py:17
Finding
Hardcoded Absolute Paths Cause Undocumented Filesystem Access and Overwrites## Vulnerability Details **File Location**: `scripts/run_complete_qc.py`, lines 17–29 **Additional Locations**: `scripts/generate_analysis_figures.py`, lines 21–23; `scripts/generate_more_figures.py`, lines 22–24; `scripts/generate_nature_conservation_landscape.py`, lines 25–26 **Vulnerability Type**: Unsafe filesystem configuration and unexpected side effects **Risk Level**: Low ### Vulnerable Code ```python # 工作目录 WORK_DIR = Path("/root/autodl-tmp/ou_a1d19d5984eecd78f231c50f774eddb0/ChemRxiv_QC_analysis") INPUT_FASTA = Path("/root/autodl-tmp/ou_a1d19d5984eecd78f231c50f774eddb0/ChemRxiv_QC_analysis/input/all_ired_merged.fasta") # 创建日志 LOG_FILE = WORK_DIR / "logs" / f"qc_analysis_{datetime.now().strftime('%Y%m%d_%H%M%S')}.log" # 确保目录存在 WORK_DIR.mkdir(parents=True, exist_ok=True) (WORK_DIR / "logs").mkdir(exist_ok=True) (WORK_DIR / "sequences").mkdir(exist_ok=True) (WORK_DIR / "alignment").mkdir(exist_ok=True) (WORK_DIR / "analysis").mkdir(exist_ok=True) ``` The figure scripts use the same pattern: ```python BASE_DIR = Path("/root/autodl-tmp/ou_a1d19d5984eecd78f231c50f774eddb0") OUTPUT_DIR = BASE_DIR / "analysis_figures" OUTPUT_DIR.mkdir(exist_ok=True) ``` ### Technical Analysis The scripts are documented as accepting user-selected input and output locations, but the QC script does not parse those command-line arguments. Instead, it reads from and writes to fixed absolute paths under `/root/autodl-tmp`. Directory creation occurs at module import time in `run_complete_qc.py`, before `main()` is called. Merely importing the module can therefore create directories outside the importing program’s expected working area. Subsequent stages write predictable filenames such as `01_length_filtered.fasta`, `05_aligned.fasta`, and `06_trimmed.fasta`. Existing files at those locations may be replaced without an explicit overwrite confirmation. The figure scripts similarly read fixed local datasets and write t ...[truncated 1644 chars]
Remediation
## Remediation Suggestions 1. Implement the command-line interface documented in `README.md` and `SKILL.md`: ```python def parse_args(): parser = argparse.ArgumentParser() parser.add_argument("--input", type=Path, required=True) parser.add_argument("--output", type=Path, required=True) parser.add_argument("--threads", type=int, default=8) return parser.parse_args() ``` 2. Pass input, output, and thread settings explicitly to pipeline functions rather than storing them in mutable module-level globals. 3. Move all directory creation into `main()` or a dedicated setup function so importing the module has no filesystem side effects. 4. Resolve paths before use and verify that generated outputs remain beneath the selected output directory: ```python output_root = args.output.expanduser().resolve() output_root.mkdir(parents=True, exist_ok=True) ``` 5. Reject an input path that does not exist, is not a regular file, or unexpectedly resolves inside the output directory. 6. Require an explicit `--overwrite` option before replacing existing result files, or create a unique run directory. 7. Apply the same configurable path handling to all figure-generation scripts. 8. Avoid recommending privileged execution; use a dedicated unprivileged account and a narrowly scoped working directory.
Vulnerability Patterns
  • Tool MisuseTool Parameter Abuse, Chaining Abuse, Unsafe Defaults
  • Behavioral ASTexec() Call, eval() Call, Dynamic Import
  • MCP Least PrivilegeUnderdeclared Capability, Wildcard Permission, Missing Permission Declaration
  • MCP Tool PoisoningHidden Instructions, Unicode Deception, Parameter Description Injection
  • Prompt InjectionInstruction Override, Hidden Instructions, Exfiltration Commands
Findings (11)

Tp4

High
Category
MCP Tool Poisoning
Confidence
98% confidence
Finding
The declared description presents a comprehensive protein sequence QC and visualization workflow with multiple analytical stages and publication-ready figure creation. However, the supplied code only defines a command-line interface, creates the output directory, prints configuration/status text, and enumerates existing PNG/PDF files. Although it claims to 'generate all publication-ready figures,' no figure-generation functions are imported or called in the shown code, and no protein-analysis steps are present. Therefore, the actual behavior of this code chunk is materially narrower than the declared purpose.

Tp4

High
Category
MCP Tool Poisoning
Confidence
95% confidence
Finding
The description presents a complete protein sequence quality-control and analysis workflow, implying the skill carries out the underlying sequence-processing and analytical steps. The supplied code chunk does not do that. It is a visualization script only: it reads existing result files from fixed local paths, uses some hardcoded dataset counts and mutation priorities, and writes PNG figures. While the generated plots are consistent with the described domain and support the declared visualization aspect, the code does not actually implement the core QC pipeline or analytical computations it claims. Therefore the description materially overstates the behavior of this code chunk.

Tp4

High
Category
MCP Tool Poisoning
Confidence
95% confidence
Finding
The description presents a comprehensive protein sequence QC and analysis workflow, but this code chunk does not execute that workflow. It only consumes existing outputs (JSON, CSV, FASTA, TXT) from earlier steps and renders publication-style figures. While conservation/coevolution visualization is consistent with part of the description, the primary claimed capability—a complete QC pipeline—is absent from the code shown. Therefore the declared purpose materially overstates what this specific code chunk actually does.

Tp4

High
Category
MCP Tool Poisoning
Confidence
92% confidence
Finding
The description overstates the implemented functionality. The supplied code does cover much of the QC pipeline named in the description: length filter, CD-HIT, complexity check, motif verification, multiple sequence alignment, and trimming. However, several prominently declared capabilities are absent from this chunk: there is no conservation analysis, no coevolution analysis, and no visualization or publication-ready figure generation. Additionally, the code includes an extra QC step not explicitly declared—filtering out sequences containing non-standard amino acid characters—though that alone would normally be a supporting detail. More materially, the script is tightly bound to hard-coded local filesystem paths and a specific IRED input FASTA, so it behaves more like a dataset-specific batch QC script than the broader end-to-end analysis and visualization workflow described. Overall, the description does not accurately represent what this code chunk actually does.

Tool Parameter Abuse

High
Category
Tool Misuse
Content
log(f"开始: {description}")
    log(f"命令: {cmd}")
    
    result = subprocess.run(cmd, shell=True, capture_output=True, text=True)
    
    if result.returncode != 0:
        log(f"❌ 失败: {description}")
Confidence
97% confidence
Finding
This is the same underlying issue as the AST4 finding but framed as tool parameter abuse: shell=True allows shell metacharacters, redirections, and command chaining to be interpreted. In a bioinformatics pipeline that passes filesystem paths into external tools, this becomes more dangerous because datasets, output paths, or future user-supplied parameters may contain hostile content and the script invokes multiple powerful binaries.

Lp3

Medium
Category
MCP Least Privilege
Confidence
89% confidence
Finding
The skill advertises and demonstrates shell execution, file reads, and file writes, but it does not declare any tool scope such as permissions or allowed-tools. That creates an overbroad execution surface where a host agent may permit more capabilities than intended, increasing the chance of unsafe command execution or filesystem access when the skill is invoked.

Natural-Language Policy Violations

Medium
Confidence
95% confidence
Finding
This Python file contains natural-language strings and comments that present the skill entirely in Chinese, including the module description and all runtime status messages. Because the script does not offer any user opt-in or configurable locale, it imposes a specific language on users, which matches the language/locale policy violation criteria.

Natural-Language Policy Violations

Medium
Confidence
95% confidence
Finding
This code file contains natural-language documentation entirely in Chinese, which imposes a specific language on users without any opt-in or alternative. Under the policy, forcing a specific language without user choice is a natural-language policy violation unless the locale restriction is explicitly justified.

subprocess module call

Medium
Category
Dangerous Code Execution
Content
log(f"开始: {description}")
    log(f"命令: {cmd}")
    
    result = subprocess.run(cmd, shell=True, capture_output=True, text=True)
    
    if result.returncode != 0:
        log(f"❌ 失败: {description}")
Confidence
96% confidence
Finding
The helper executes dynamically constructed shell command strings with shell=True, which makes command parsing dependent on the shell rather than on explicit argument boundaries. If any part of the command ever becomes attacker-controlled or is influenced by crafted filenames/paths, this can lead to command injection and arbitrary command execution.

Intent-Code Divergence

Medium
Confidence
95% confidence
Finding
The stage is documented as "Motif 验证" and described as a QC pipeline step, which implies sequences would be validated or filtered based on motif presence. However, after classifying sequences into with_motif and without_motif, the code explicitly writes all original sequences back out at L217-L219, so motif absence has no effect on the workflow.

Natural-Language Policy Violations

Low
Confidence
96% confidence
Finding
This code file contains natural-language strings that force a specific language for user-visible output and documentation. Under the policy, locale constraints should offer user opt-in or be clearly justified as region-specific, neither of which is present here.

Static analysis

No suspicious patterns detected.