Back to skill

Security audit

vps-maintenance

Security checks for vulnerabilities and agentic risk

Overview

This VPS maintenance skill is mostly purpose-aligned, but its root-level setup commands include unsafe defaults that could lock users out or damage system state.

Review this skill carefully before installing or following it. Treat the commands as risky examples, not a safe runbook: replace the hard-coded password, target SSH keys to a specific user without overwriting existing keys, validate SSH and firewall changes before enabling them, prefer HTTPS package sources, and avoid the broad cleanup commands on production systems.

Vulnerability Patterns
  • Insecure DependenciesIntroduces malicious components through unsafe dependency sources
  • 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 (5)

T09 · Insecure Skill Coding Practices

Error
Location
SKILL.md:50
Finding

Predictable Hard-Coded Password for a Sudo-Capable Account

Content
View full analysis
Remediation
View remediation

T09 · Insecure Skill Coding Practices

Error
Location
SKILL.md:55
Finding

Destructive and Incorrectly Targeted SSH Authorized-Key Modification

Content
View full analysis
~/.ssh/authorized_keys chmod 600 ~/.ssh/authorized_keys ``` ### Technical Analysis The redirection operator `>` replaces the entire `authorized_keys` file instead of safely adding a validated key. Any existing administrative keys are consequently destroyed. The use of `~` targets the home directory of the shell's current user. Because the broader workflow requires root privileges, these commands may modify `/root/.ssh/authorized_keys` rather than the authorized-key file of the account created earlier. The literal placeholder is also not a valid public key. No backup, key-format validation, ownership assignment, duplicate check, or post-write authentication test is performed. This becomes especially dangerous because the subsequent instructions disable password authentication and restart SSH. Although SSH key configuration is within the declared VPS-hardening functionality, overwriting an implicitly selected credential file exceeds the minimum safe behavior needed to install a key. ### Attack Path 1. An administrator executes the VPS setup commands from a root shell. 2. `~/.ssh/authorized_keys` resolves to the root account's credential file. 3. The existing file is truncated and replaced by the literal invalid placeholder. 4. Existing root SSH keys stop working, while the intended non-root user's key is not installed. 5. The later hardening commands disable password authentication and restart SSH. 6. After the current session closes, the administrator cannot establish a new authenticated SSH session. If an untrusted key is substituted for the placeholder, the same operation can instead remove legitimate keys while granting the holder of the substituted private key remote access. ### Impact Assessment The primary impact ...[truncated 325 chars]
Remediation
View remediation

T09 · Insecure Skill Coding Practices

Error
Location
SKILL.md:64
Finding

Non-Atomic SSH and Default-Deny Firewall Transition Can Cause Remote Lockout

Content
View full analysis
> /etc/ssh/sshd_config < /etc/nftables.conf <
Remediation
View remediation

T08 · Insecure Dependencies

Warning
Location
SKILL.md:29
Finding

APT Repository Configuration Uses Plaintext HTTP and Replaces Existing Sources

Content
View full analysis
/etc/apt/sources.list <
Remediation
View remediation

T09 · Insecure Skill Coding Practices

Error
Location
SKILL.md:184
Finding

Unscoped Root-Level Cleanup Can Delete Active Data and Forensic Evidence

Content
View full analysis
/dev/null | grep '^ii' | grep -v "$(uname -r | sed 's/-.*//')" | awk '{print $2}' | xargs apt-get -y purge 2>/dev/null # 3. 清理日志(保留最近 7 天) journalctl --vacuum-time=7d find /var/log -type f -name "*.log" -mtime +7 -delete 2>/dev/null find /var/log -type f -name "*.gz" -mtime +30 -delete 2>/dev/null find /var/log -type f -name "*.old" -delete 2>/dev/null # 4. 清理临时文件 rm -rf /tmp/* 2>/dev/null rm -rf /var/tmp/* 2>/dev/null # 5. 清理用户缓存 rm -rf ~/.cache/* 2>/dev/null ``` The periodic cleanup example repeats part of the behavior: ```bash journalctl --vacuum-time=7d find /var/log -type f -name "*.log" -mtime +7 -delete 2>/dev/null rm -rf /tmp/* 2>/dev/null rm -rf /var/tmp/* 2>/dev/null ``` ### Technical Analysis These commands perform broad deletion across shared system locations while operating with the root privileges required by the rest of the Skill. They are not limited to files created by this Skill. Deleting all matching files under `/var/log` bypasses service-specific retention rules and can remove audit trails, incident evidence, or logs that applications still expect. Modification time alone is not sufficient to determine whether a log is safe to delete. The wildcard deletion of `/tmp/*` and `/var/tmp/*` can remove files, directories, sockets, lock data, installation state, or application working data belonging to unrelated services and users. Shell globbing also does not remove dot-prefixed entries consistently, making the cleanup both dangerous and incomplete. The old-kernel pipeline suppresses errors and automatically purges packages based on text processing. This can remove fallback ...[truncated 1129 chars]
Remediation
View remediation
Vulnerability Patterns
  • Privilege EscalationExcessive Permissions, Sudo/Root Execution, Credential Access
  • Excessive AgencyUnrestricted Tool Access, Autonomous Decision Making, Scope Creep
  • Tool MisuseTool Parameter Abuse, Chaining Abuse, Unsafe Defaults
  • Rogue AgentSelf-Modification, Session Persistence
  • YARA SignaturesMalware Match, Webshell Match, Cryptominer Match
Findings (31)

Credential Access

High
Category
Privilege Escalation
Confidence
90% confidence
Finding

Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.

Content

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

配置 SSH 密钥

mkdir -p ~/.ssh chmod 700 ~/.ssh echo "你的公钥" > ~/.ssh/authorized_keys chmod 600 ~/.ssh/authorized_keys

text

Credential Access

High
Category
Privilege Escalation
Confidence
90% confidence
Finding

Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.

Content

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

配置 SSH 密钥

mkdir -p ~/.ssh chmod 700 ~/.ssh echo "你的公钥" > ~/.ssh/authorized_keys chmod 600 ~/.ssh/authorized_keys

text

YARA rule 'backdoor_persistence': Backdoor persistence with malicious payloads (shell commands, SSH key injection, hidden root users) [malware]

High
Category
YARA Match
Confidence
75% confidence
Finding

YARA rule matched a known malware signature (reverse shell, backdoor, ransomware, C2 framework, or info stealer).

Content

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

CODENAME}-updates main contrib non-free non-free-firmware EOF

国外用户用官方源

deb https://deb.debian.org/debian/ ${CODENAME} main ...

apt update

text

### 2. 账户安全

```bash
# 创建普通用户(禁止直接用 root)
useradd -m -s /bin/bash username
echo "username:StrongPassword123!" | chpasswd
usermod -aG sudo username

# 配置 SSH 密钥
mkdir -p ~/.ssh
chmod 700 ~/.ssh
echo "你的公钥" > ~/.ssh/authorized_keys
chmod 600 ~/.ssh/authorized_keys

3. SSH 加固

bash
# 备份配置
cp /etc/ssh/sshd_config /etc/ssh/sshd_config.backup

# 修改默认端口(防扫描)
sed -i 's/^#*Port .*/Port 54321/' /etc/ssh/sshd_config

# 加固配置
cat >> /etc/ssh/sshd_config <<EOF
PasswordAuthentication no
PermitRootLogin prohibit-password
PubkeyAuthentication yes
LoginGraceTime 30
MaxAuthTries 3
EOF

systemctl restart ssh

4. 防火墙 (nftables)

bash
# 安装 nftables(替代 ufw)
apt-get install -y nftables

# 配置规则(只开放 SSH�

Tool Parameter Abuse

High
Category
Tool Misuse
Confidence
90% confidence
Finding

rm -rf /tmp/* is a broad destructive command that can delete active temporary files, sockets, PID-related artifacts, or application state, causing service disruption. In a root-capable maintenance skill, this becomes more dangerous because a caller may run it non-interactively across production systems.

Content

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

md
find /var/log -type f -name "*.old" -delete 2>/dev/null

# 4. 清理临时文件
rm -rf /tmp/* 2>/dev/null
rm -rf /var/tmp/* 2>/dev/null

# 5. 清理用户缓存

Tool Parameter Abuse

High
Category
Tool Misuse
Confidence
88% confidence
Finding

rm -rf /tmp/* is a broad destructive command that can delete active temporary files, sockets, PID-related artifacts, or application state, causing service disruption. In a root-capable maintenance skill, this becomes more dangerous because a caller may run it non-interactively across production systems.

Content

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

md
find /var/log -type f -name "*.old" -delete 2>/dev/null

# 4. 清理临时文件
rm -rf /tmp/* 2>/dev/null
rm -rf /var/tmp/* 2>/dev/null

# 5. 清理用户缓存

Tool Parameter Abuse

High
Category
Tool Misuse
Confidence
90% confidence
Finding

rm -rf /tmp/* is a broad destructive command that can delete active temporary files, sockets, PID-related artifacts, or application state, causing service disruption. In a root-capable maintenance skill, this becomes more dangerous because a caller may run it non-interactively across production systems.

Content

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

md
find /var/log -type f -name "*.old" -delete 2>/dev/null

# 4. 清理临时文件
rm -rf /tmp/* 2>/dev/null
rm -rf /var/tmp/* 2>/dev/null

# 5. 清理用户缓存

Tool Parameter Abuse

High
Category
Tool Misuse
Confidence
90% confidence
Finding

rm -rf /var/tmp/* is similarly over-broad and especially risky because /var/tmp is intended to preserve temporary files across reboots. Deleting everything can break installers, applications, or maintenance jobs that rely on persisted temporary state.

Content

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

md
# 4. 清理临时文件
rm -rf /tmp/* 2>/dev/null
rm -rf /var/tmp/* 2>/dev/null

# 5. 清理用户缓存
rm -rf ~/.cache/* 2>/dev/null

Tool Parameter Abuse

High
Category
Tool Misuse
Confidence
88% confidence
Finding

rm -rf /var/tmp/* is similarly over-broad and especially risky because /var/tmp is intended to preserve temporary files across reboots. Deleting everything can break installers, applications, or maintenance jobs that rely on persisted temporary state.

Content

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

md
# 4. 清理临时文件
rm -rf /tmp/* 2>/dev/null
rm -rf /var/tmp/* 2>/dev/null

# 5. 清理用户缓存
rm -rf ~/.cache/* 2>/dev/null

Tool Parameter Abuse

High
Category
Tool Misuse
Confidence
90% confidence
Finding

rm -rf /var/tmp/* is similarly over-broad and especially risky because /var/tmp is intended to preserve temporary files across reboots. Deleting everything can break installers, applications, or maintenance jobs that rely on persisted temporary state.

Content

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

md
# 4. 清理临时文件
rm -rf /tmp/* 2>/dev/null
rm -rf /var/tmp/* 2>/dev/null

# 5. 清理用户缓存
rm -rf ~/.cache/* 2>/dev/null

Tool Parameter Abuse

High
Category
Tool Misuse
Confidence
90% confidence
Finding

rm -rf ~/.cache/* can wipe caches for the effective user, which may be root if executed as instructed, producing unnecessary data loss or side effects in administrative tooling. The use of ~ also makes the target depend on execution context, increasing the chance of unintended deletion.

Content

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

rm -rf /var/tmp/* 2>/dev/null

5. 清理用户缓存

rm -rf ~/.cache/* 2>/dev/null

text

---

Tool Parameter Abuse

High
Category
Tool Misuse
Confidence
85% confidence
Finding

rm -rf ~/.cache/* can wipe caches for the effective user, which may be root if executed as instructed, producing unnecessary data loss or side effects in administrative tooling. The use of ~ also makes the target depend on execution context, increasing the chance of unintended deletion.

Content

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

rm -rf /var/tmp/* 2>/dev/null

5. 清理用户缓存

rm -rf ~/.cache/* 2>/dev/null

text

---

Tool Parameter Abuse

High
Category
Tool Misuse
Confidence
90% confidence
Finding

rm -rf ~/.cache/* can wipe caches for the effective user, which may be root if executed as instructed, producing unnecessary data loss or side effects in administrative tooling. The use of ~ also makes the target depend on execution context, increasing the chance of unintended deletion.

Content

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

rm -rf /var/tmp/* 2>/dev/null

5. 清理用户缓存

rm -rf ~/.cache/* 2>/dev/null

text

---

Tool Parameter Abuse

High
Category
Tool Misuse
Confidence
90% confidence
Finding

The cleanup script repeats the broad rm -rf /tmp/* deletion, making the risky action easier to automate and schedule. Automation amplifies the chance of recurring service disruption or deletion of needed temporary runtime files.

Content

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

md
find /var/log -type f -name "*.log" -mtime +7 -delete 2>/dev/null

# 清理临时文件
rm -rf /tmp/* 2>/dev/null
rm -rf /var/tmp/* 2>/dev/null

echo "=== 清理完成 ==="

Tool Parameter Abuse

High
Category
Tool Misuse
Confidence
88% confidence
Finding

The cleanup script repeats the broad rm -rf /tmp/* deletion, making the risky action easier to automate and schedule. Automation amplifies the chance of recurring service disruption or deletion of needed temporary runtime files.

Content

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

md
find /var/log -type f -name "*.log" -mtime +7 -delete 2>/dev/null

# 清理临时文件
rm -rf /tmp/* 2>/dev/null
rm -rf /var/tmp/* 2>/dev/null

echo "=== 清理完成 ==="

Tool Parameter Abuse

High
Category
Tool Misuse
Confidence
90% confidence
Finding

The cleanup script repeats the broad rm -rf /tmp/* deletion, making the risky action easier to automate and schedule. Automation amplifies the chance of recurring service disruption or deletion of needed temporary runtime files.

Content

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

md
find /var/log -type f -name "*.log" -mtime +7 -delete 2>/dev/null

# 清理临时文件
rm -rf /tmp/* 2>/dev/null
rm -rf /var/tmp/* 2>/dev/null

echo "=== 清理完成 ==="

Tool Parameter Abuse

High
Category
Tool Misuse
Confidence
90% confidence
Finding

The script also automates rm -rf /var/tmp/*, extending the same destructive behavior to a location designed for longer-lived temporary data. Scheduled execution increases blast radius because failures may recur silently.

Content

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

md
# 清理临时文件
rm -rf /tmp/* 2>/dev/null
rm -rf /var/tmp/* 2>/dev/null

echo "=== 清理完成 ==="
df -h

Tool Parameter Abuse

High
Category
Tool Misuse
Confidence
88% confidence
Finding

The script also automates rm -rf /var/tmp/*, extending the same destructive behavior to a location designed for longer-lived temporary data. Scheduled execution increases blast radius because failures may recur silently.

Content

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

md
# 清理临时文件
rm -rf /tmp/* 2>/dev/null
rm -rf /var/tmp/* 2>/dev/null

echo "=== 清理完成 ==="
df -h

Tool Parameter Abuse

High
Category
Tool Misuse
Confidence
90% confidence
Finding

The script also automates rm -rf /var/tmp/*, extending the same destructive behavior to a location designed for longer-lived temporary data. Scheduled execution increases blast radius because failures may recur silently.

Content

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

md
# 清理临时文件
rm -rf /tmp/* 2>/dev/null
rm -rf /var/tmp/* 2>/dev/null

echo "=== 清理完成 ==="
df -h

Chaining Abuse

High
Category
Tool Misuse
Confidence
75% confidence
Finding

Tool calls are chained to bypass individual safety checks or escalate capabilities beyond what any single tool call would allow.

Content

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

md
| 权限 | 范围 | 用途 | 说明 |
|------|------|------|------|
| 执行 | sudo | 系统配置修改 | 换源、SSH 加固、防火墙、内核调优 |
| 文件系统 | 写入 | `/etc/`、`/etc/ssh/`、`/etc/nftables.conf` | 修改系统和服务配置 |
| 文件系统 | 写入 | `/etc/sysctl.d/` | 内核参数调优 |
| 文件系统 | 删除 | `/var/log/` 旧日志 | 日志清理(仅 *.log >7天、*.gz >30天) |

Sudo/Root Execution

Medium
Category
Privilege Escalation
Confidence
70% confidence
Finding

Commands invoke sudo or root privileges. Verify this elevated access is necessary and justified.

Content

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

md
# 创建普通用户(禁止直接用 root)
useradd -m -s /bin/bash username
echo "username:StrongPassword123!" | chpasswd
usermod -aG sudo username

# 配置 SSH 密钥
mkdir -p ~/.ssh

Sudo/Root Execution

Medium
Category
Privilege Escalation
Confidence
70% confidence
Finding

Commands invoke sudo or root privileges. Verify this elevated access is necessary and justified.

Content

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

md
# 创建普通用户(禁止直接用 root)
useradd -m -s /bin/bash username
echo "username:StrongPassword123!" | chpasswd
usermod -aG sudo username

# 配置 SSH 密钥
mkdir -p ~/.ssh

Sudo/Root Execution

Medium
Category
Privilege Escalation
Confidence
80% confidence
Finding

Commands invoke sudo or root privileges. Verify this elevated access is necessary and justified.

Content

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

配置 SSH 密钥

mkdir -p ~/.ssh chmod 700 ~/.ssh echo "你的公钥" > ~/.ssh/authorized_keys chmod 600 ~/.ssh/authorized_keys

text

Sudo/Root Execution

Medium
Category
Privilege Escalation
Confidence
80% confidence
Finding

Commands invoke sudo or root privileges. Verify this elevated access is necessary and justified.

Content

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

mkdir -p ~/.ssh chmod 700 ~/.ssh echo "你的公钥" > ~/.ssh/authorized_keys chmod 600 ~/.ssh/authorized_keys

text

### 3. SSH 加固

Scope Creep

Medium
Category
Not specified by scanner
Confidence
92% confidence
Finding

The skill performs package installation, removal, and dpkg reconfiguration, but the declared permissions mention only outbound access for apt sources and do not clearly disclose package-management changes. That mismatch can mislead a caller about the breadth of software and system-state modifications being performed.

Content

No source excerpt is available for this finding.

Session Persistence

Medium
Category
Rogue Agent
Confidence
80% confidence
Finding

Skill establishes unauthorized persistence across sessions via cron jobs, startup scripts, or state files. Session persistence allows an attacker to maintain access beyond the current interaction.

Content

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

} EOF

systemctl enable --now nftables

text

### 5. 性能优化