Back to skill

Security audit

Infrastructure

Security checks for vulnerabilities and agentic risk

Overview

This skill is a plain infrastructure guidance skill that gives user-run cloud and backup commands, but some examples need careful review before use because they can create resources, expose services, upload backups, or overwrite data.

Install only if you are comfortable reviewing infrastructure commands before running them. Treat the cloud, firewall, backup, and restore snippets as templates: verify account, region, bucket, database target, allowed IP ranges, encryption, IAM permissions, lifecycle rules, and image pinning before using them in production.

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
backups.md:12
Finding

Predictable Temporary Database Backup File Enables Local File Disclosure or Overwrite

Content
View full analysis

Vulnerability Details

File Location: backups.md, lines 12-34
Vulnerability Type: Predictable and insecure temporary file handling
Risk Level: Medium

Vulnerable Code

bash
#!/bin/bash
# backup-db.sh
TIMESTAMP=$(date +%Y%m%d_%H%M%S)
BUCKET="s3://myapp-backups/postgres"

# Dump
pg_dump -Fc $DATABASE_URL > /tmp/backup_$TIMESTAMP.dump

# Upload
aws s3 cp /tmp/backup_$TIMESTAMP.dump $BUCKET/

# Cleanup local
rm /tmp/backup_$TIMESTAMP.dump

# Cleanup old backups (keep 30 days)
aws s3 ls $BUCKET/ | while read -r line; do
  createDate=$(echo $line | awk '{print $1" "$2}')
  createDate=$(date -d "$createDate" +%s)
  olderThan=$(date -d "30 days ago" +%s)
  if [[ $createDate -lt $olderThan ]]; then
    fileName=$(echo $line | awk '{print $4}')
    aws s3 rm $BUCKET/$fileName
  fi
done

Technical Analysis

The example writes a potentially sensitive database dump into the shared /tmp directory using a filename derived solely from the current timestamp. The filename is predictable, and shell redirection creates or truncates the path without verifying that it is a regular file owned by the backup process.

On systems where relevant symbolic-link protections are absent, disabled, or ineffective for the execution context, another local user can create the expected path as a symbolic link before the backup runs. The shell may then follow that link when processing the redirection. This creates a time-of-check/time-of-use-style temporary-file vulnerability and can cause the database dump to be written to an unintended destination.

The script also does not set a restrictive umask. Depending on the process environment, the temporary dump can therefore be created with permissions that permit other local users to read it. The file remains on disk until the upload completes, and abnormal termination before the rm command can leave the plaintext backup behind.

Several variable expansion ...[truncated 2250 chars]

Remediation
View remediation

Remediation Suggestions

  • Create the backup with mktemp inside a private directory rather than constructing a predictable path in shared /tmp.
  • Set umask 077 before creating any backup so only the backup account can read newly created files.
  • Install an EXIT, INT, and TERM trap to remove temporary data even if upload or processing fails.
  • Quote every variable expansion used as a command argument.
  • Where operationally supported, stream the dump directly to encrypted object storage to avoid a plaintext intermediate file.
  • Run the backup under a dedicated, least-privileged service account rather than root.
  • Enable server-side encryption and restrictive bucket policies for uploaded backups.
  • Use native object-storage lifecycle rules for retention instead of parsing aws s3 ls output.

A hardened local-file pattern is:

bash
#!/usr/bin/env bash
set -euo pipefail
umask 077

BUCKET="s3://myapp-backups/postgres"
BACKUP_DIR=$(mktemp -d)
BACKUP_FILE=$(mktemp "${BACKUP_DIR}/backup_XXXXXXXX.dump")

cleanup() {
  rm -f -- "$BACKUP_FILE"
  rmdir -- "$BACKUP_DIR" 2>/dev/null || true
}
trap cleanup EXIT INT TERM

pg_dump -Fc -- "$DATABASE_URL" > "$BACKUP_FILE"
aws s3 cp "$BACKUP_FILE" "${BUCKET}/backup_$(date +%Y%m%d_%H%M%S).dump"

Credentials should preferably be supplied through a protected PostgreSQL password file or another secret mechanism that does not expose sensitive connection details in process arguments. Backup restoration should be tested regularly, and retention should be enforced through an authenticated storage lifecycle policy.

Vulnerability Patterns
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • Tool MisuseTool Parameter Abuse, Chaining Abuse, Unsafe Defaults
  • Prompt InjectionInstruction Override, Hidden Instructions, Exfiltration Commands
  • Privilege EscalationExcessive Permissions, Sudo/Root Execution, Credential Access
  • Supply ChainUnpinned Dependencies, External Script Fetching, Obfuscated Code
Findings (14)

Tool Parameter Abuse

High
Category
Tool Misuse
Confidence
85% 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 · backups.md (reported line 30)May include surrounding context.

md
aws s3 cp /tmp/backup_$TIMESTAMP.dump $BUCKET/

# Cleanup local
rm /tmp/backup_$TIMESTAMP.dump

# Cleanup old backups (keep 30 days)
aws s3 ls $BUCKET/ | while read -r line; do

Tool Parameter Abuse

High
Category
Tool Misuse
Confidence
85% confidence
Finding

The script derives fileName from parsed aws s3 ls output and passes it directly into aws s3 rm $BUCKET/$fileName without quoting or safer object enumeration. This can cause unintended deletions if parsing is ambiguous, object names contain unexpected characters, or the bucket listing format changes, which is especially risky in backup-retention logic.

Content

Scanner excerpt · backups.md (reported line 39)May include surrounding context.

olderThan=$(date -d "30 days ago" +%s) if [[ $createDate -lt $olderThan ]]; then fileName=$(echo $line | awk '{print $4}') aws s3 rm $BUCKET/$fileName fi done

text

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
94% confidence
Finding

The backup script performs both data transmission to cloud storage and destructive deletion of old backups without prominently warning the operator. In an infrastructure skill, users may run snippets with minimal review, so the combination of upload and retention deletion increases the chance of accidental data loss or unintended exposure of sensitive backups.

Content

No source excerpt is available for this finding.

Cloud Storage Exfiltration

Medium
Category
Data Exfiltration
Confidence
60% confidence
Finding

Data is uploaded to cloud storage (S3 / GCS / Azure Blob). This may be a legitimate backup or exfiltration to an external bucket. Manual review is recommended.

Content

Scanner excerpt · backups.md (reported line 27)May include surrounding context.

md
pg_dump -Fc $DATABASE_URL > /tmp/backup_$TIMESTAMP.dump

# Upload
aws s3 cp /tmp/backup_$TIMESTAMP.dump $BUCKET/

# Cleanup local
rm /tmp/backup_$TIMESTAMP.dump

Cloud Storage Exfiltration

Medium
Category
Data Exfiltration
Confidence
60% confidence
Finding

Data is uploaded to cloud storage (S3 / GCS / Azure Blob). This may be a legitimate backup or exfiltration to an external bucket. Manual review is recommended.

Content

Scanner excerpt · backups.md (reported line 53)May include surrounding context.

md
pg_dump -Fc $DATABASE_URL > /tmp/backup_$TIMESTAMP.dump

# Upload
aws s3 cp /tmp/backup_$TIMESTAMP.dump $BUCKET/

# Cleanup local
rm /tmp/backup_$TIMESTAMP.dump

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
92% confidence
Finding

The restore instructions omit a warning that pg_restore -d $DATABASE_URL can modify or overwrite data in the target database. In an infrastructure-focused skill, restore commands are highly action-oriented, so missing cautions materially increase the risk of a user restoring into production by mistake.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
91% confidence
Finding

The volume restore example extracts an archive directly into /data and may overwrite or intermingle with existing volume contents without warning. In this skill context, that is dangerous because operators may apply the snippet to live Docker volumes and cause irreversible application-state corruption.

Content

No source excerpt is available for this finding.

Rp1

Medium
Category
MCP Rug Pull
Confidence
75% confidence
Finding

Docker image references without a specific tag (:latest is implicit) or digest (@sha256:...) can be silently replaced by a malicious image.

Content

No source excerpt is available for this finding.

Rp1

Medium
Category
MCP Rug Pull
Confidence
75% confidence
Finding

Docker image references without a specific tag (:latest is implicit) or digest (@sha256:...) can be silently replaced by a malicious image.

Content

No source excerpt is available for this finding.

Tool Parameter Abuse

Low
Category
Tool Misuse
Confidence
15% 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 · backups.md (reported line 94)May include surrounding context.

Docker Volumes

bash
# Backup volume to tarball
docker run --rm -v myapp_data:/data -v $(pwd):/backup \
  alpine tar czf /backup/data_backup.tar.gz /data

# Restore

Tool Parameter Abuse

Low
Category
Tool Misuse
Confidence
15% 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 · backups.md (reported line 98)May include surrounding context.

Docker Volumes

bash
# Backup volume to tarball
docker run --rm -v myapp_data:/data -v $(pwd):/backup \
  alpine tar czf /backup/data_backup.tar.gz /data

# Restore

Missing User Warnings

Low
Category
Not specified by scanner
Confidence
82% confidence
Finding

This markdown file includes commands to create servers and apply firewalls, which can affect system integrity and incur charges, but the surrounding text does not explicitly warn the user before these actions. Under the markdown-specific SQP-2 criteria, descriptions should disclose impactful behaviors that could affect user data, privacy, or systems.

Content

No source excerpt is available for this finding.

Missing User Warnings

Low
Category
Not specified by scanner
Confidence
89% confidence
Finding

The example creates an EC2 instance and authorizes inbound HTTPS from 0.0.0.0/0, which changes network exposure and may incur ongoing cost. Although the file later mentions cost gotchas, it does not clearly warn users at the action point that running these commands makes live infrastructure and security changes.

Content

No source excerpt is available for this finding.

Missing User Warnings

Low
Category
Not specified by scanner
Confidence
85% confidence
Finding

These commands create a live droplet and firewall rules, including public HTTPS exposure, but the markdown does not explicitly disclose the operational and cost impact. SQP-2 for markdown files calls for warnings when described behavior could affect system integrity or user environments.

Content

No source excerpt is available for this finding.

Static analysis

No suspicious patterns detected.