Back to skill

Security audit

sjht-server-audit

Security checks for vulnerabilities and agentic risk

Overview

The skill is a coherent SSH server-audit tool, but it defaults to root access and gathers sensitive infrastructure details into local reports without enough scoping or handling controls.

Install only if you intend to audit servers you own or are authorized to inspect. Avoid running the default root mode casually; specify a least-privileged audit user where possible, review what will be collected, and treat generated reports as sensitive infrastructure data that should not be committed, synced broadly, or shared without redaction.

Vulnerability Patterns
  • Unauthorized Access and Privilege EscalationObtains permissions beyond the task's legitimate needs
  • 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)

T05 · Unauthorized Access and Privilege Escalation

Warning
Location
scripts/server-audit.sh:10
Finding

Privileged remote reconnaissance defaults to the root account

Content
View full analysis

Vulnerability Details

File Location: scripts/server-audit.sh, lines 10–124
Vulnerability Type: T05: Unauthorized Access and Privilege Escalation
Risk Level: Medium

bash
HOST="${1:?❌ 用法: bash server-audit.sh <host> [user]}"
USER="${2:-root}"
TMPFILE=$(mktemp)
trap "rm -f $TMPFILE" EXIT

echo "🔍 正在巡检 ${USER}@${HOST} ..."

ssh -o ConnectTimeout=10 "${USER}@${HOST}" bash -s > "$TMPFILE" << 'AUDIT_SCRIPT'

systemctl list-units --type=service --state=running --no-pager --legend=no 2>/dev/null
ss -tlnp 2>/dev/null
firewall-cmd --list-all 2>/dev/null || echo "(未配置)"

for f in /etc/nginx/conf.d/*.conf /www/server/nginx/conf/vhost/*.conf; do
  [ -f "$f" ] && echo "[$f]" && grep -E "server_name|listen|root" "$f" 2>/dev/null
done

grep -E "^PermitRootLogin|^PasswordAuthentication|^Port|^PubkeyAuthentication|^MaxAuthTries" /etc/ssh/sshd_config 2>/dev/null || echo "(使用默认配置)"
lastb 2>/dev/null | head -5 || echo "(无记录)"
crontab -l 2>/dev/null || echo "(无用户 crontab)"

for f in /etc/cron.d/*; do
  [ -f "$f" ] && echo "[$f]" && cat "$f"
done

ps aux --sort=-%mem | head -12

Technical Analysis

The optional SSH username defaults to root. Consequently, an invocation that supplies only a host automatically attempts to execute every audit operation with the highest remote privilege level. Although privileged visibility may improve audit completeness, making root the default does not follow least-privilege principles.

Many operations, including operating-system discovery, service enumeration, basic port inspection, and software version checks, can be conducted using an unprivileged audit account. Only checks requiring additional access should receive narrowly scoped elevation.

The collected output can include security-sensitive operational information:

  • Listening ports and associated process identities
  • Firewall rules and ...[truncated 2746 chars]
Remediation
View remediation

Remediation Suggestions

  1. Remove the implicit root default and require the caller to provide an explicit SSH username.
  2. Prefer a dedicated, unprivileged audit account as the documented and enforced default operating model.
  3. Separate ordinary inventory checks from privileged checks. Use narrowly scoped sudo rules for only the commands that genuinely require elevated visibility.
  4. Make collection of failed-login records, process arguments, cron contents, and full configuration details explicitly opt-in.
  5. Redact likely credentials, tokens, usernames, internal addresses, and sensitive command arguments before displaying or storing results.
  6. Avoid printing complete cron files by default. Report metadata and suspicious patterns instead, with a separate authorized mode for full contents.
  7. Configure SSH with strict host-key verification, an explicit known-hosts policy, noninteractive authentication, and an allowlist of approved target hosts where appropriate.
  8. Store generated reports with permissions such as 0600, document their retention period, and securely delete them when no longer required.
  9. Add a pre-execution warning describing the information that will be collected and require confirmation before using a privileged SSH identity.
  10. Correct the final status message claiming that raw data remains at the temporary path, because the EXIT trap deletes that file when the script terminates.
Vulnerability Patterns
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • Rogue AgentSelf-Modification, Session Persistence
  • Trigger AbuseOverly Broad Trigger, Shadow Command Trigger, Keyword Baiting Trigger
  • Prompt InjectionInstruction Override, Hidden Instructions, Exfiltration Commands
  • Privilege EscalationExcessive Permissions, Sudo/Root Execution, Credential Access
Findings (7)

Vague Triggers

Medium
Category
Not specified by scanner
Confidence
93% confidence
Finding

The skill advertises very broad trigger phrases such as '巡检', '安全检查', and '服务器检查', which can cause it to activate for generic server-related requests without clear user intent to perform remote access or sensitive enumeration. In this context, the skill performs SSH-based inspection and collects detailed system and security data, so overbroad routing increases the chance of unnecessary access to sensitive infrastructure information.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
93% confidence
Finding

The skill instructs saving a detailed audit report locally and warns only against uploading it to GitHub, but it does not clearly classify the report contents as sensitive. Because the report includes open ports, SSH settings, web and database configuration, suspicious processes, and cron jobs, local storage without explicit handling guidance can expose high-value reconnaissance data if the workspace is shared, synced, or later exfiltrated.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
91% confidence
Finding

The script performs broad remote enumeration and saves the full results to a local temporary file, including running services, listening ports, SSH configuration, failed login history, cron entries, process lists, and web/server configuration details. In the context of an agent skill, this is sensitive operational data collection, and the script gives only a generic 'audit' message rather than clearly warning the user about the scope, sensitivity, and local retention of the collected data.

Content

No source excerpt is available for this finding.

Session Persistence

Medium
Category
Rogue Agent
Confidence
85% 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 · scripts/server-audit.sh (reported line 120)May include surrounding context.

sh
echo ""

echo "--- 定时任务 ---"
crontab -l 2>/dev/null || echo "(无用户 crontab)"
echo ""
for f in /etc/cron.d/*; do
  [ -f "$f" ] && echo "[$f]" && cat "$f"

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
88% confidence
Finding

This markdown file contains user-facing natural language entirely in Chinese, including the changelog description and audit rule summaries. Under the policy criteria, forcing a specific language without opt-in or justification can be a locale-policy violation.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
88% confidence
Finding

The skill description and instructions are written as Chinese-only operational guidance, indicating a fixed language/locale expectation without opt-in or alternatives. Under the policy, language constraints should either be optional for the user or clearly justified as region-specific.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
95% confidence
Finding

The script's comments, usage text, and runtime messages are written in Chinese, which imposes a specific language on users without any opt-in or alternative. Under the language/locale policy, hard-coded language constraints should either be user-selectable or clearly documented as region-specific and justified.

Content

No source excerpt is available for this finding.

Static analysis

No suspicious patterns detected.