Back to skill

Security audit

NightPatch

Security checks for vulnerabilities and agentic risk

Overview

NightPatch is a disclosed automation skill, but its scheduled mutation path, shell-profile persistence, irreversible deletion, and unsafe command handling need human review before use.

Install only in an isolated test workspace first. Do not enable cron or run the mutating path until shell-history input is validated, ~/.bashrc writes are opt-in, log cleanup is changed to quarantine or backup instead of deletion, and dry-run plus approval is enforced for every change.

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

T09 · Insecure Skill Coding Practices

Error
Location
src/patch-executor.js:166
Finding

Shell Command Injection Through Command-History-Derived Alias Data

Content
View full analysis
cmd.trim()); const commandCounts = {}; commands.forEach(cmd => { const baseCmd = cmd.split(' ')[0]; if (baseCmd && baseCmd.length > 2) { commandCounts[baseCmd] = (commandCounts[baseCmd] || 0) + 1; } }); Object.entries(commandCounts).forEach(([cmd, count]) => { if (count >= (config.min_usage_count || 3)) { const suggestedAlias = cmd.length > 4 ? cmd.substring(0, 2) : cmd; opportunities.push({ type: 'shell_alias', original_command: cmd, suggested_alias: suggestedAlias, rollback_command: `unalias ${suggestedAlias}` }); } }); } ``` ```js // src/patch-executor.js const checkAlias = execSync( `alias ${suggested_alias} 2>/dev/null || true`, { encoding: 'utf8', shell: '/bin/bash' } ); execSync( `which ${original_command.split(' ')[0]} >/dev/null 2>&1 || true`, { shell: '/bin/bash' } ); const aliasCommand = `alias ${suggested_alias}='${original_command}'`; execSync(aliasCommand, { stdio: 'pipe', shell: '/bin/bash' }); ``` ### Technical Analysis The detector reads command names from a user-writable shell history file and propagates them into an execution opportunity without validating the resulting alias or command. The executor then interpolates these values directly into shell command strings evaluated by `/bin/bash`. Quoting `original_command` with single quotes is insufficient because an attacker-controlled co ...[truncated 1974 chars]
Remediation
View remediation

T09 · Insecure Skill Coding Practices

Error
Location
src/patch-executor.js:357
Finding

Irreversible Log Deletion Incorrectly Passes Rollback Enforcement

Content
View full analysis
Remediation
View remediation

T09 · Insecure Skill Coding Practices

Warning
Location
src/patch-executor.js:20
Finding

Documented Dry-Run and Full Safety Controls Are Not Enforced by the Execution Path

Content
View full analysis
item.risk_level === 'low') .slice(0, maxChanges); const executionResults = executors.executeSelectedPatches(selectedItems, config); ``` ### Technical Analysis `dryRunFirst` is parsed and stored, but `executePatches()` never evaluates it, tracks whether a first dry run occurred, or requests approval before mutation. Therefore, setting `dry_run_first: true` does not prevent direct execution. The main entry point also defines independent detector and executor objects instead of invoking the shipped `PatchDetector`, `SafetyCheck`, and `PatchExecutor` classes. As a result, controls implemented in `SafetyCheck.performFullSafetyCheck()`—including resource limits, forbidden-action checks, and type-specific checks—do not pr ...[truncated 1261 chars]
Remediation
View remediation

T09 · Insecure Skill Coding Practices

Warning
Location
setup-cron.sh:21
Finding

Cron Setup Replaces the Shipped Dry-Run Runner with a Mutating Runner

Content
View full analysis
"$CRON_SCRIPT" << 'EOF' #!/bin/bash # NightPatch nightly automatic runner set -e SKILL_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" LOG_FILE="$SKILL_DIR/logs/nightly-run-$(date +%Y%m%d).log" # Run NightPatch cd "$SKILL_DIR" # Use manual mode if ./start.sh run >> "$LOG_FILE" 2>&1; then echo "NightPatch completed" >> "$LOG_FILE" else echo "NightPatch failed" >> "$LOG_FILE" fi EOF chmod +x "$CRON_SCRIPT" ``` The shipped runner has materially safer behavior: ```bash # run-nightly.sh # Default to dry-run mode and perform detection only. # To perform actual execution, manually change this to: ./start.sh run if ./start.sh dry-run >> "$LOG_FILE" 2>&1; then echo "NightPatch detection completed in dry-run mode" >> "$LOG_FILE" echo "Run ./start.sh run manually to execute changes" >> "$LOG_FILE" fi ``` ### Technical Analysis `setup-cron.sh` does not directly install a crontab entry; it only prints instructions for the user to add one. That behavior is consistent with a user-approved scheduling feature and is not, by itself, unauthorized persistence. However, the setup script silently overwrites the already shipped `run-nightly.sh`. The original runner uses dry-run mode, while the replacement invokes `./start.sh run`, which is the mutation-capable path. A user can therefore inspect and approve the safe runner, execute setup, and unknowingly schedule a different behavior. This also conflicts with the release documentation's statement that the nightly runner defaults to dry-run mode. ### Attack Path 1. The user reviews the shipped `run-nightly.sh` and observes that it uses dry-run mode. 2. The user runs `setup-cron.sh` to prepare cron integration. 3. The setu ...[truncated 884 chars]
Remediation
View remediation
Vulnerability Patterns
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • Excessive AgencyUnrestricted Tool Access, Autonomous Decision Making, Scope Creep
  • Rogue AgentSelf-Modification, Session Persistence
  • MCP Tool PoisoningHidden Instructions, Unicode Deception, Parameter Description Injection
  • Prompt InjectionInstruction Override, Hidden Instructions, Exfiltration Commands
Findings (65)

Self-Modification

High
Category
Rogue Agent
Confidence
85% confidence
Finding

The skill is explicitly designed for automated patching and self-modifying behavior, including unattended nightly execution. Even though the document claims safety controls such as dry-run defaults and production skips, autonomous modification remains high risk because it can change user environment state, shell configuration, logs, or files without immediate review, and the release notes alone do not define strict limits on modification scope.

Content

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

md
# NightPatch Skill v1.0.2 - 发布说明

## 🎯 技能概述
**夜间自动修补技能** - 基于虾聊社区热门帖子「试了一下「夜间自动修补」,Master 早上起来直接用上了」理念开发。

Self-Modification

High
Category
Rogue Agent
Confidence
85% confidence
Finding

Skill modifies its own code, configuration, or behavior at runtime. Self-modification enables an agent to escalate privileges, disable safety constraints, or install persistent backdoors.

Content

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

md
# NightPatch Skill 安全使用指南

## 🛡️ 安全概述

Self-Modification

High
Category
Rogue Agent
Confidence
85% confidence
Finding

Skill modifies its own code, configuration, or behavior at runtime. Self-modification enables an agent to escalate privileges, disable safety constraints, or install persistent backdoors.

Content

Scanner excerpt · setup-cron.sh (reported line 3)May include surrounding context.

sh
# NightPatch Skill 安全使用指南

## 🛡️ 安全概述

Self-Modification

High
Category
Rogue Agent
Confidence
85% confidence
Finding

Skill modifies its own code, configuration, or behavior at runtime. Self-modification enables an agent to escalate privileges, disable safety constraints, or install persistent backdoors.

Content

Scanner excerpt · src/index.js (reported line 4)May include surrounding context.

js
# NightPatch Skill 安全使用指南

## 🛡️ 安全概述

Self-Modification

High
Category
Rogue Agent
Confidence
85% confidence
Finding

Skill modifies its own code, configuration, or behavior at runtime. Self-modification enables an agent to escalate privileges, disable safety constraints, or install persistent backdoors.

Content

Scanner excerpt · src/index.js (reported line 395)May include surrounding context.

js
# NightPatch Skill 安全使用指南

## 🛡️ 安全概述

Self-Modification

High
Category
Rogue Agent
Confidence
85% confidence
Finding

Skill modifies its own code, configuration, or behavior at runtime. Self-modification enables an agent to escalate privileges, disable safety constraints, or install persistent backdoors.

Content

Scanner excerpt · src/index.js (reported line 403)May include surrounding context.

js
# NightPatch Skill 安全使用指南

## 🛡️ 安全概述

Self-Modification

High
Category
Rogue Agent
Confidence
85% confidence
Finding

Skill modifies its own code, configuration, or behavior at runtime. Self-modification enables an agent to escalate privileges, disable safety constraints, or install persistent backdoors.

Content

Scanner excerpt · src/index.js (reported line 483)May include surrounding context.

js
# NightPatch Skill 安全使用指南

## 🛡️ 安全概述

Self-Modification

High
Category
Rogue Agent
Confidence
85% confidence
Finding

Skill modifies its own code, configuration, or behavior at runtime. Self-modification enables an agent to escalate privileges, disable safety constraints, or install persistent backdoors.

Content

Scanner excerpt · src/index.js (reported line 502)May include surrounding context.

js
# NightPatch Skill 安全使用指南

## 🛡️ 安全概述

Self-Modification

High
Category
Rogue Agent
Confidence
85% confidence
Finding

Skill modifies its own code, configuration, or behavior at runtime. Self-modification enables an agent to escalate privileges, disable safety constraints, or install persistent backdoors.

Content

Scanner excerpt · src/patch-executor.js (reported line 454)May include surrounding context.

js
# NightPatch Skill 安全使用指南

## 🛡️ 安全概述

Self-Modification

High
Category
Rogue Agent
Confidence
85% confidence
Finding

Skill modifies its own code, configuration, or behavior at runtime. Self-modification enables an agent to escalate privileges, disable safety constraints, or install persistent backdoors.

Content

Scanner excerpt · src/report-generator.js (reported line 210)May include surrounding context.

js
# NightPatch Skill 安全使用指南

## 🛡️ 安全概述

Self-Modification

High
Category
Rogue Agent
Confidence
85% confidence
Finding

Skill modifies its own code, configuration, or behavior at runtime. Self-modification enables an agent to escalate privileges, disable safety constraints, or install persistent backdoors.

Content

Scanner excerpt · src/report-generator.js (reported line 268)May include surrounding context.

js
# NightPatch Skill 安全使用指南

## 🛡️ 安全概述

Self-Modification

High
Category
Rogue Agent
Confidence
85% confidence
Finding

Skill modifies its own code, configuration, or behavior at runtime. Self-modification enables an agent to escalate privileges, disable safety constraints, or install persistent backdoors.

Content

Scanner excerpt · src/report-generator.js (reported line 321)May include surrounding context.

js
# NightPatch Skill 安全使用指南

## 🛡️ 安全概述

Self-Modification

High
Category
Rogue Agent
Confidence
85% confidence
Finding

Skill modifies its own code, configuration, or behavior at runtime. Self-modification enables an agent to escalate privileges, disable safety constraints, or install persistent backdoors.

Content

Scanner excerpt · start.sh (reported line 3)May include surrounding context.

sh
# NightPatch Skill 安全使用指南

## 🛡️ 安全概述

Self-Modification

High
Category
Rogue Agent
Confidence
85% confidence
Finding

Skill modifies its own code, configuration, or behavior at runtime. Self-modification enables an agent to escalate privileges, disable safety constraints, or install persistent backdoors.

Content

Scanner excerpt · start.sh (reported line 22)May include surrounding context.

sh
# NightPatch Skill 安全使用指南

## 🛡️ 安全概述

Self-Modification

High
Category
Rogue Agent
Confidence
85% confidence
Finding

Skill modifies its own code, configuration, or behavior at runtime. Self-modification enables an agent to escalate privileges, disable safety constraints, or install persistent backdoors.

Content

Scanner excerpt · tests/basic.test.js (reported line 2)May include surrounding context.

js
# NightPatch Skill 安全使用指南

## 🛡️ 安全概述

Self-Modification

High
Category
Rogue Agent
Confidence
85% confidence
Finding

Skill modifies its own code, configuration, or behavior at runtime. Self-modification enables an agent to escalate privileges, disable safety constraints, or install persistent backdoors.

Content

Scanner excerpt · tests/basic.test.js (reported line 299)May include surrounding context.

js
# NightPatch Skill 安全使用指南

## 🛡️ 安全概述

Self-Modification

High
Category
Rogue Agent
Confidence
89% confidence
Finding

This skill is designed to autonomously modify a user's environment, including shell configuration and potentially workspace organization, on a scheduled overnight basis. Self-modifying behavior is inherently risky because small configuration changes can persist, alter future command behavior, and cause hard-to-detect integrity issues when executed without active user review.

Content

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

md
# NightPatch Skill - 夜间自动修补

基于虾聊社区热门帖子「试了一下「夜间自动修补」,Master 早上起来直接用上了」的理念开发。

Self-Modification

High
Category
Rogue Agent
Confidence
86% confidence
Finding

The script generates another executable script (run-nightly.sh) inside the skill directory and sets it executable, which is a form of local code creation/persistence. While likely intended for automation, this increases risk because it plants runnable code that may later execute unattended via cron, especially if the skill directory is writable by untrusted parties or deployed in sensitive environments.

Content

Scanner excerpt · setup-cron.sh (reported line 19)May include surrounding context.

sh
CRON_SCRIPT="$SKILL_DIR/run-nightly.sh"
CRON_JOB="0 3 * * * cd $SKILL_DIR && ./run-nightly.sh >> $SKILL_DIR/logs/cron.log 2>&1"

echo -e "${GREEN}NightPatch Skill Cron集成设置${NC}"
echo "=" * 50

# 创建运行脚本

Missing User Warnings

High
Category
Not specified by scanner
Confidence
97% confidence
Finding

The code treats '--test' as a normal allowed run path and provides no protective branching to prevent execution behavior. In a skill designed for unattended 'night patching,' misleading test semantics are especially risky because operators may run it in sensitive environments believing it is safe, potentially causing unintended modifications once executors become real.

Content

No source excerpt is available for this finding.

Missing User Warnings

High
Category
Not specified by scanner
Confidence
99% confidence
Finding

The code builds shell commands with untrusted fields such as suggested_alias and original_command and passes them to execSync with /bin/bash. An attacker controlling opportunity data can inject shell metacharacters or crafted alias content to execute arbitrary commands during the safety check or patch execution.

Content

No source excerpt is available for this finding.

Missing User Warnings

High
Category
Not specified by scanner
Confidence
98% confidence
Finding

The code deletes files listed in old_logs via fs.unlinkSync without meaningful path restriction, quarantine, backup, or user confirmation, while acknowledging the operation is irreversible. If an attacker can influence old_logs, this enables destructive deletion of arbitrary accessible files under the guise of log cleanup.

Content

No source excerpt is available for this finding.

Intent-Code Divergence

High
Category
Not specified by scanner
Confidence
97% confidence
Finding

This safety-check module performs real filesystem side effects while merely 'checking' safety: it may create directories, write a test file, and delete paths during validation. In a security gate, validation routines are expected to be side-effect free; unexpected writes can alter state, create attacker-chosen directories under the current working tree, or trigger operational impact before approval is granted.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
90% confidence
Finding

The release notes explicitly promote an automatic nighttime patching capability and describe unattended operation, but they do not place a prominent warning near the overview that the skill may make system changes without active user review. For an agent skill that can modify files or environment state, this omission can cause users to install or schedule it without understanding the operational risk.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
97% confidence
Finding

The cron example shows how to schedule the skill for nightly execution but does not directly warn that this enables unattended automated modifications. Users may copy the cron line verbatim and unknowingly authorize background changes, increasing the risk of unintended file edits or environment changes while no human is supervising execution.

Content

No source excerpt is available for this finding.

Intent-Code Divergence

Medium
Category
Not specified by scanner
Confidence
94% confidence
Finding

The guide claims the skill will not modify system files, yet it explicitly states it will write to ~/.bashrc and later recommends enabling cron-based automation. This is a misleading security boundary: shell startup files and scheduled tasks affect persistent user execution context, so understating that behavior can cause users to grant more trust than warranted.

Content

No source excerpt is available for this finding.

Static analysis

Detected: suspicious.dangerous_exec

Shell command execution detected (child_process).

Critical
Code
suspicious.dangerous_exec
Location
src/patch-executor.js:171

Shell command execution detected (child_process).

Critical
Code
suspicious.dangerous_exec
Location
tests/basic.test.js:40