Back to skill

Security audit

srv-guard

Security checks for vulnerabilities and agentic risk

Overview

This server-security skill needs review because its repair and rollback routines can unintentionally damage files or weaken security settings.

Use scanning and previews first. Before running repairs as root, have the symbolic-link handling corrected and verify each selected file. Have rollback restore recorded original kernel values rather than forcing them to 1. Keep the web UI on localhost and use only trusted rollback files. Most advisory scanner flags describe expected defensive checks; the concrete repair and rollback flaws justify this Review verdict.

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

T09 · Insecure Skill Coding Practices

Warning
Location
scripts/vuln_fix.py
Finding

Private-key permission repair follows attacker-controlled symbolic links

Content
View full analysis

Impact

An attacker can induce unauthorized permission changes to root-owned files. Changing /etc/passwd from its normal readable mode to 0600 prevents ordinary processes from reading account information and can disrupt account lookup and dependent services. Other targets can lose necessary read or executable permissions. This is an integrity and availability issue, not demonstrated credential theft or code execution.

Vulnerability Patterns
  • Privilege EscalationExcessive Permissions, Sudo/Root Execution, Credential Access
  • Tool MisuseTool Parameter Abuse, Chaining Abuse, Unsafe Defaults
  • Rogue AgentSelf-Modification, Session Persistence
  • Behavioral ASTexec() Call, eval() Call, Dynamic Import
  • MCP Least PrivilegeUnderdeclared Capability, Wildcard Permission, Missing Permission Declaration
Findings (35)

Credential Access

High
Category
Privilege Escalation
Confidence
60% confidence
Finding

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

Content

Scanner excerpt · references/attack-signatures.md (reported line 58)May include surrounding context.

md
**端口扫描**: 同一 IP 短时间访问大量不同端口(基于 syslog 连接拒绝记录或 auditd)。

**Web 扫描模式**(nginx/apache access.log):
- 路径包含: `/.env`, `/.git/`, `/wp-admin`, `/phpmyadmin`, `/%3Cscript`, `/etc/passwd`
- User-Agent: `sqlmap`, `nikto`, `nmap`, `masscan`, `dirbuster`, `gobuster`
- 大量 404 响应(同一 IP 在 window 内 > 20 个 404)

Credential Access

High
Category
Privilege Escalation
Confidence
60% confidence
Finding

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

Content

Scanner excerpt · references/scan-checklist.md (reported line 29)May include surrounding context.

md
| CFG-04 | SSH 协议版本 | `Protocol 1` → CRITICAL | CRITICAL | ⏳ |
| CFG-05 | SSH MaxAuthTries | > 6 → LOW(暴力破解容忍度高) | LOW | ⏳ |
| CFG-06 | 全局可读私钥 | `*.pem`/`id_rsa` 权限 > 0600 → HIGH | HIGH | ✅ |
| CFG-07 | /etc/passwd 空口令字段 | 第二字段为空 → CRITICAL | CRITICAL | ✅ |
| CFG-08 | sudo 免密配置 | `NOPASSWD` 用于高风险命令 → HIGH | HIGH | ✅ |
| CFG-09 | 文件权限 | `/etc/shadow` 非 0640 → HIGH | HIGH | ⏳ |
| CFG-10 | umask | 默认 umask > 022 → LOW | LOW | ⏳ |

Credential Access

High
Category
Privilege Escalation
Confidence
60% confidence
Finding

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

Content

Scanner excerpt · scripts/vuln_scan.py (reported line 99)May include surrounding context.

python
def scan_passwd_empty(target):
    out = []
    r = run_cmd(target, "awk -F: '$2==\"\" {print $1}' /etc/passwd", timeout=5)
    if r["rc"] == 0:
        for user in r["stdout"].split():
            if user and user not in ("nobody",):

Credential Access

High
Category
Privilege Escalation
Confidence
60% confidence
Finding

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

Content

Scanner excerpt · references/fix-playbook.md (reported line 53)May include surrounding context.

md
- **修复**: `chmod 600 <keyfile>`
- **回滚**: 记录原权限并恢复

### CFG-07: /etc/passwd 空口令 ✅

- **风险**: 账户无密码即可登录
- **修复**: `passwd -l <user>` 锁定账户

Credential Access

High
Category
Privilege Escalation
Confidence
95% confidence
Finding

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

Content

Scanner excerpt · references/fix-playbook.md (reported line 60)May include surrounding context.

md
- **回滚**: `passwd -u <user>`(需确认账户应有密码)
- **注意**: 不锁定系统必需账户(如 nobody)

### CFG-09: /etc/shadow 权限 ⏳

- **修复**: `chmod 640 /etc/shadow; chown root:shadow /etc/shadow`(Debian 系)或 `chmod 000`(RHEL 系)
- **回滚**: 记录原权限恢复

Credential Access

High
Category
Privilege Escalation
Confidence
95% confidence
Finding

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

Content

Scanner excerpt · references/scan-checklist.md (reported line 31)May include surrounding context.

md
| CFG-06 | 全局可读私钥 | `*.pem`/`id_rsa` 权限 > 0600 → HIGH | HIGH | ✅ |
| CFG-07 | /etc/passwd 空口令字段 | 第二字段为空 → CRITICAL | CRITICAL | ✅ |
| CFG-08 | sudo 免密配置 | `NOPASSWD` 用于高风险命令 → HIGH | HIGH | ✅ |
| CFG-09 | 文件权限 | `/etc/shadow` 非 0640 → HIGH | HIGH | ⏳ |
| CFG-10 | umask | 默认 umask > 022 → LOW | LOW | ⏳ |

### service — 服务类

Credential Access

High
Category
Privilege Escalation
Confidence
95% confidence
Finding

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

Content

Scanner excerpt · references/fix-playbook.md (reported line 62)May include surrounding context.

md
### CFG-09: /etc/shadow 权限 ⏳

- **修复**: `chmod 640 /etc/shadow; chown root:shadow /etc/shadow`(Debian 系)或 `chmod 000`(RHEL 系)
- **回滚**: 记录原权限恢复

### SVC-01: 不必要服务 ✅

Credential Access

High
Category
Privilege Escalation
Confidence
95% confidence
Finding

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

Content

Scanner excerpt · references/fix-playbook.md (reported line 62)May include surrounding context.

md
### CFG-09: /etc/shadow 权限 ⏳

- **修复**: `chmod 640 /etc/shadow; chown root:shadow /etc/shadow`(Debian 系)或 `chmod 000`(RHEL 系)
- **回滚**: 记录原权限恢复

### SVC-01: 不必要服务 ✅

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 · references/scan-checklist.md (reported line 30)May include surrounding context.

md
| CFG-05 | SSH MaxAuthTries | > 6 → LOW(暴力破解容忍度高) | LOW | ⏳ |
| CFG-06 | 全局可读私钥 | `*.pem`/`id_rsa` 权限 > 0600 → HIGH | HIGH | ✅ |
| CFG-07 | /etc/passwd 空口令字段 | 第二字段为空 → CRITICAL | CRITICAL | ✅ |
| CFG-08 | sudo 免密配置 | `NOPASSWD` 用于高风险命令 → HIGH | HIGH | ✅ |
| CFG-09 | 文件权限 | `/etc/shadow` 非 0640 → HIGH | HIGH | ⏳ |
| CFG-10 | umask | 默认 umask > 022 → LOW | LOW | ⏳ |

Tool Parameter Abuse

High
Category
Tool Misuse
Confidence
90% confidence
Finding

Tool parameters are crafted to achieve unintended or unsafe behavior. Parameter abuse can bypass intended safety checks (e.g. shell=True, --force, dangerous glob patterns).

Content

Scanner excerpt · scripts/_common.py (reported line 63)May include surrounding context.

python
h", "user": m.group(1), "host": m.group(2),
                "port": int(m.group(3)) if m.group(3) else 22}
    raise ValueError(f"无法解析 target: {target}(应为 local 或 <redacted-url>")


def run_cmd(target, cmd, timeout=30):
    """执行 shell 命令(本地或远程 SSH)。

    返回 dict: {"rc": int, "stdout": str, "stderr": str}
    SSH 失败(连接错误)返回 rc=-1 并在 stderr 标注。
    不抛异常,由调用方判断 rc。
    """
    t = parse_target(target) if isinstance(target, str) else target
    try:
        if t["mode"] == "local":
            proc = subprocess.run(
                cmd, shell=True, capture_output=True, text=True,
                timeout=timeout, encoding="utf-8", errors="replace")
            return {"rc": proc.returncode, "stdout": proc.stdout, "stderr": proc.stderr}
        else:
            ssh_cmd = ["ssh", "-p", str(t["port"]),
                       "-o", "BatchMode=yes", "-o", "ConnectTimeout=10",
                       "-o", "StrictHostKeyChecking=accept-new",
                       f"{t['user']}@{t['host']}", cmd]
            p

Credential Access

High
Category
Privilege Escalation
Confidence
60% confidence
Finding

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

Content

Scanner excerpt · scripts/attack_monitor.py (reported line 23)May include surrounding context.

python
AUTH_LOGS = ["/var/log/auth.log", "/var/log/secure"]
WEB_LOGS = ["/var/log/nginx/access.log", "/var/log/apache2/access.log"]
WEB_SCAN_PATTERNS = [r'\.env\b', r'\.git/', r'wp-admin', r'phpmyadmin', r'%3Cscript', r'/etc/passwd',
                     r'sqlmap', r'nikto', r'nmap', r'masscan', r'dirbuster', r'gobuster']

_SYSLOG_TS = re.compile(r'^([A-Z][a-z]{2})\s+(\d{1,2})\s+(\d{2}):(\d{2}):(\d{2})')

Credential Access

High
Category
Privilege Escalation
Confidence
60% confidence
Finding

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

Content

Scanner excerpt · scripts/attack_monitor.py (reported line 141)May include surrounding context.

python
hits[ip]["lines"].append(f"{lp}:{ln.strip()[:200]}")
                    break
        for ip, info in hits.items():
            sev = "HIGH" if any(p in str(info["patterns"]) for p in ["sqlmap", "nikto", "/etc/passwd", "%3Cscript"]) else "MEDIUM"
            events.append({
                "type": "web_scan", "source_ip": ip, "hit_count": info["count"],
                "patterns_matched": sorted(info["patterns"])[:5], "evidence": info["lines"],

Credential Access

High
Category
Privilege Escalation
Confidence
60% confidence
Finding

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

Content

Scanner excerpt · scripts/vuln_scan.py (reported line 104)May include surrounding context.

python
for user in r["stdout"].split():
            if user and user not in ("nobody",):
                out.append(finding("CFG-07", f"账户 {user} 无密码", "CRITICAL", "config",
                                   f"/etc/passwd: {user} 第二字段为空", user=user))
    return out

Credential Access

High
Category
Privilege Escalation
Confidence
95% confidence
Finding

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

Content

Scanner excerpt · scripts/vuln_scan.py (reported line 88)May include surrounding context.

python
if parts and int(parts[0], 8) > 0o600:
                    out.append(finding("CFG-06", f"私钥文件权限过宽: {kf}", "HIGH", "config",
                                       f"stat: {pr['stdout'].strip()}", keyfile=kf))
    sh = run_cmd(target, "stat -c '%a %n' /etc/shadow", timeout=5)
    if sh["rc"] == 0:
        parts = sh["stdout"].split()
        if parts and parts[0] not in ("640", "000", "600"):

Credential Access

High
Category
Privilege Escalation
Confidence
95% confidence
Finding

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

Content

Scanner excerpt · scripts/vuln_scan.py (reported line 92)May include surrounding context.

python
if sh["rc"] == 0:
        parts = sh["stdout"].split()
        if parts and parts[0] not in ("640", "000", "600"):
            out.append(finding("CFG-09", "/etc/shadow 权限异常", "HIGH", "config",
                               f"stat: {sh['stdout'].strip()}"))
    return out

Code capability 'network' detected in scripts/web_ui.py but not covered by declared permissions.

High
Category
MCP Least Privilege
Confidence
75% confidence
Finding

The skill uses 'network' capability that is not covered by the declared 'allowed-tools' preapproval. Review the host runtime's actual enforcement policy; runtime permissions are unknown unless separately verified, and this declaration alone does not establish a permission ceiling.

Content

No source excerpt is available for this finding.

Credential Access

High
Category
Privilege Escalation
Confidence
70% confidence
Finding

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

Content

Scanner excerpt · scripts/web_ui.py (reported line 139)May include surrounding context.

python
def do_POST(self):
        if not self._authorized():
            return self._json(403, {"error": "forbidden: local access token required"})
        try:
            body = self._body()
            route = urlparse(self.path).path

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 · references/attack-signatures.md (reported line 72)May include surrounding context.

md
| 新地理位置登录 | 与历史登录 IP 段差异大(需历史基线) | MEDIUM |
| 首次出现 IP 登录成功 | 历史未见过的 IP 成功登录 | LOW |
| root 直接登录成功 | `Accepted password/key for root` | HIGH |
| 用户提权异常 | 短时间多次 `sudo` / `su root` 失败后成功 | HIGH |

**历史基线**: 首次运行无基线时,标注 `baseline_unavailable`,仅做规则匹配不做异常比对;后续运行以历史成功登录 IP 集为基线。

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 · references/fix-playbook.md (reported line 27)May include surrounding context.

systemctl reload sshd

text
- **回滚**: 恢复备份文件并 `systemctl reload sshd`
- **注意**: 确保有普通用户 sudo 权限,否则可能锁死 root 远程管理

### CFG-02: SSH PasswordAuthentication ✅

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 · references/fix-playbook.md (reported line 69)May include surrounding context.

md
- **修复**: `systemctl stop <svc>; systemctl disable <svc>`
- **业务确认**: telnet/rsh/rlogin/tftp 直接禁用;ftp 需人工确认是否业务必需
- **回滚**: `systemctl enable --now <svc>`

### SVC-04: Docker daemon 无 TLS ⏳

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 · references/fix-playbook.md (reported line 91)May include surrounding context.

md
### PCH-03: 已知高危软件版本 ⏳

- **修复**: 针对特定 CVE 的包升级(如 `sudo` CVE-2021-3156 → 升级 sudo 包)
- **回滚**: 记录原版本

## 不自动修复的项

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 · references/scan-checklist.md (reported line 30)May include surrounding context.

md
| CFG-05 | SSH MaxAuthTries | > 6 → LOW(暴力破解容忍度高) | LOW | ⏳ |
| CFG-06 | 全局可读私钥 | `*.pem`/`id_rsa` 权限 > 0600 → HIGH | HIGH | ✅ |
| CFG-07 | /etc/passwd 空口令字段 | 第二字段为空 → CRITICAL | CRITICAL | ✅ |
| CFG-08 | sudo 免密配置 | `NOPASSWD` 用于高风险命令 → HIGH | HIGH | ✅ |
| CFG-09 | 文件权限 | `/etc/shadow` 非 0640 → HIGH | HIGH | ⏳ |
| CFG-10 | umask | 默认 umask > 022 → LOW | LOW | ⏳ |

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 · references/scan-checklist.md (reported line 59)May include surrounding context.

md
|----|--------|----------|--------|------|
| PCH-01 | 可用安全更新 | apt/yum 可升级的安全包数量 > 0 → HIGH | HIGH | ✅ |
| PCH-02 | 内核版本 | 运行内核与已安装最新内核不一致 → MEDIUM(需重启) | MEDIUM | ⏳ |
| PCH-03 | 已知高危软件版本 | bash Shellshock、sudo CVE-2021-3156 等 → CRITICAL | CRITICAL | ⏳ |

### ssh — SSH 专项(config 子集,独立便于 --scope 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 · scripts/vuln_fix.py (reported line 166)May include surrounding context.

python
target = args.target
    if not _common.is_root(target) and not dry_run:
        log("修复需要 root/sudo 权限,当前用户非 root。将以 dry-run 模式运行。", "WARN")
        dry_run = True

    wanted = set(args.items.split(",")) if args.items else None

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 · scripts/_common.py (reported line 63)May include surrounding context.

python
t = parse_target(target) if isinstance(target, str) else target
    try:
        if t["mode"] == "local":
            proc = subprocess.run(
                cmd, shell=True, capture_output=True, text=True,
                timeout=timeout, encoding="utf-8", errors="replace")
            return {"rc": proc.returncode, "stdout": proc.stdout, "stderr": proc.stderr}