T09 · Insecure Skill Coding Practices
- Location
SKILL.md:50- Finding
Predictable Hard-Coded Password for a Sudo-Capable Account
- Content
View full analysis
- Remediation
View remediation
Security audit
Security checks for vulnerabilities and agentic risk
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.
SKILL.md:50Predictable Hard-Coded Password for a Sudo-Capable Account
SKILL.md:55Destructive and Incorrectly Targeted SSH Authorized-Key Modification
SKILL.md:64Non-Atomic SSH and Default-Deny Firewall Transition Can Cause Remote Lockout
SKILL.md:29APT Repository Configuration Uses Plaintext HTTP and Replaces Existing Sources
SKILL.md:184Unscoped Root-Level Cleanup Can Delete Active Data and Forensic Evidence
Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.
mkdir -p ~/.ssh chmod 700 ~/.ssh echo "你的公钥" > ~/.ssh/authorized_keys chmod 600 ~/.ssh/authorized_keys
Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.
mkdir -p ~/.ssh chmod 700 ~/.ssh echo "你的公钥" > ~/.ssh/authorized_keys chmod 600 ~/.ssh/authorized_keys
YARA rule matched a known malware signature (reverse shell, backdoor, ransomware, C2 framework, or info stealer).
CODENAME}-updates main contrib non-free non-free-firmware EOF
apt update
### 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
# 备份配置
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
# 安装 nftables(替代 ufw)
apt-get install -y nftables
# 配置规则(只开放 SSH�
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.
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 /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.
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 /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.
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 /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.
# 4. 清理临时文件
rm -rf /tmp/* 2>/dev/null
rm -rf /var/tmp/* 2>/dev/null
# 5. 清理用户缓存
rm -rf ~/.cache/* 2>/dev/null
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.
# 4. 清理临时文件
rm -rf /tmp/* 2>/dev/null
rm -rf /var/tmp/* 2>/dev/null
# 5. 清理用户缓存
rm -rf ~/.cache/* 2>/dev/null
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.
# 4. 清理临时文件
rm -rf /tmp/* 2>/dev/null
rm -rf /var/tmp/* 2>/dev/null
# 5. 清理用户缓存
rm -rf ~/.cache/* 2>/dev/null
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.
rm -rf /var/tmp/* 2>/dev/null
rm -rf ~/.cache/* 2>/dev/null
---
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.
rm -rf /var/tmp/* 2>/dev/null
rm -rf ~/.cache/* 2>/dev/null
---
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.
rm -rf /var/tmp/* 2>/dev/null
rm -rf ~/.cache/* 2>/dev/null
---
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.
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 "=== 清理完成 ==="
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.
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 "=== 清理完成 ==="
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.
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 "=== 清理完成 ==="
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.
# 清理临时文件
rm -rf /tmp/* 2>/dev/null
rm -rf /var/tmp/* 2>/dev/null
echo "=== 清理完成 ==="
df -h
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.
# 清理临时文件
rm -rf /tmp/* 2>/dev/null
rm -rf /var/tmp/* 2>/dev/null
echo "=== 清理完成 ==="
df -h
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.
# 清理临时文件
rm -rf /tmp/* 2>/dev/null
rm -rf /var/tmp/* 2>/dev/null
echo "=== 清理完成 ==="
df -h
Tool calls are chained to bypass individual safety checks or escalate capabilities beyond what any single tool call would allow.
| 权限 | 范围 | 用途 | 说明 |
|------|------|------|------|
| 执行 | sudo | 系统配置修改 | 换源、SSH 加固、防火墙、内核调优 |
| 文件系统 | 写入 | `/etc/`、`/etc/ssh/`、`/etc/nftables.conf` | 修改系统和服务配置 |
| 文件系统 | 写入 | `/etc/sysctl.d/` | 内核参数调优 |
| 文件系统 | 删除 | `/var/log/` 旧日志 | 日志清理(仅 *.log >7天、*.gz >30天) |
Commands invoke sudo or root privileges. Verify this elevated access is necessary and justified.
# 创建普通用户(禁止直接用 root)
useradd -m -s /bin/bash username
echo "username:StrongPassword123!" | chpasswd
usermod -aG sudo username
# 配置 SSH 密钥
mkdir -p ~/.ssh
Commands invoke sudo or root privileges. Verify this elevated access is necessary and justified.
# 创建普通用户(禁止直接用 root)
useradd -m -s /bin/bash username
echo "username:StrongPassword123!" | chpasswd
usermod -aG sudo username
# 配置 SSH 密钥
mkdir -p ~/.ssh
Commands invoke sudo or root privileges. Verify this elevated access is necessary and justified.
mkdir -p ~/.ssh chmod 700 ~/.ssh echo "你的公钥" > ~/.ssh/authorized_keys chmod 600 ~/.ssh/authorized_keys
Commands invoke sudo or root privileges. Verify this elevated access is necessary and justified.
mkdir -p ~/.ssh chmod 700 ~/.ssh echo "你的公钥" > ~/.ssh/authorized_keys chmod 600 ~/.ssh/authorized_keys
### 3. SSH 加固
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.
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.
} EOF
systemctl enable --now nftables
### 5. 性能优化