T09 · Insecure Skill Coding Practices
- Location
scripts/db-reset.py:33- Finding
Shell Command Injection Through DATABASE_URL
- Content
View full analysis
- Remediation
View remediation
Security audit
Security checks for vulnerabilities and agentic risk
The skill is a coherent Reactive Resume development guide, but its included database reset and deployment examples contain high-impact unsafe patterns that users should review before use.
Install only if you are comfortable reviewing and controlling the setup steps. Do not run scripts/db-reset.py against any database that is not disposable, do not let untrusted values control DATABASE_URL, replace all example secrets and tokens, avoid exposing Browserless or databases publicly, and treat Docker socket, sudo, cron, and restore examples as high-impact operations requiring explicit user approval.
scripts/db-reset.py:33Shell Command Injection Through DATABASE_URL
scripts/db-reset.py:73Predictable Temporary SQL File Enables Symlink and Race Attacks
scripts/db-reset.py:63Production Database Safeguard Is Bypassable and Connection Credentials Are Printed
scripts/create-template.py:112Template Name Path Traversal and Unconditional File Overwrite
references/api-reference.md:296File Upload Example Omits Resource Authorization and File Security Controls
references/api-reference.md:346PDF Export Example Allows Rendering Without Resume Ownership Verification
references/deployment.md:12Deployment Examples Use Predictable Secrets and Mutable Container Tags
Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.
cp .env.example .env
关键配置:
Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.
cp .env.example .env
关键配置:
Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.
### 4. 配置环境变量
```bash
cp .env.example .env
```
**关键配置**:
Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.
### 4. 配置环境变量
```bash
cp .env.example .env
```
**关键配置**:
Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.
pnpm install
# 配置环境变量
cp .env.example .env
# 编辑 .env
# 构建
Mounting /var/run/docker.sock into a container gives that container effective control over the Docker daemon, which commonly enables container breakout, access to other containers, host filesystem mounting, and root-level host compromise. In this deployment guide the intent is legitimate Traefik service discovery, but the capability is still highly dangerous if Traefik or any code execution path in that container is compromised.
- "80:80"
- "443:443"
volumes:
- /var/run/docker.sock:/var/run/docker.sock
- ./letsencrypt:/letsencrypt
app:
Using subprocess.run with shell=True on a command string creates a direct parameter-abuse path. In this script, the psql command is built with an environment/.env-derived DATABASE_URL, so a crafted value containing shell separators could execute arbitrary OS commands under the privileges of the user running the reset tool.
"""运行 shell 命令"""
try:
if capture:
result = subprocess.run(command, shell=True, capture_output=True, text=True)
return result.returncode, result.stdout, result.stderr
else:
subprocess.run(command, shell=True)
This second shell=True usage keeps the same unsafe API available across the script. While present calls may currently be constant strings, the helper normalizes insecure command execution and makes future or indirect parameter abuse likely.
result = subprocess.run(command, shell=True, capture_output=True, text=True)
return result.returncode, result.stdout, result.stderr
else:
subprocess.run(command, shell=True)
return 0, "", ""
except Exception as e:
print_colored(f"Error: {e}", Colors.RED)
Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.
db_url = os.environ.get('DATABASE_URL')
if not db_url:
# 尝试从 .env 读取
if os.path.exists('.env'):
with open('.env', 'r') as f:
for line in f:
if line.startswith('DATABASE_URL='):
Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.
db_url = os.environ.get('DATABASE_URL')
if not db_url:
# 尝试从 .env 读取
if os.path.exists('.env'):
with open('.env', 'r') as f:
for line in f:
if line.startswith('DATABASE_URL='):
The skill clearly instructs the agent/user to perform shell actions, read/write files, and manipulate environment configuration, but it declares no explicit tool scope or permissions. That creates an overbroad execution surface where an agent could invoke capabilities beyond what the skill contract communicates, increasing the chance of unsafe or unintended system changes.
This section tells the operator to start Docker services and even launch dockerd with sudo, but it provides no warning that these commands make system-level changes, create background services, and may require elevated privileges. In an agent context, omitting that warning makes accidental privileged execution more likely and reduces informed consent for impactful operations.
The instruction to run sudo dockerd launches the Docker daemon with root privileges, which is a high-impact system action and expands the attack surface if executed by an agent or unsuspecting user. Because Docker effectively grants root-equivalent control over the host, normalizing this command without safeguards is dangerous.
# 启动 PostgreSQL 和 Browserless(PDF 导出必需)
sudo dockerd &>/var/log/dockerd.log &
sudo docker compose -f compose.dev.yml up -d postgres browserless
Running sudo docker compose ... up starts containers with elevated control over host resources and can change networking, volumes, and local services. In a skill document, presenting privileged commands as routine setup steps without guardrails increases the risk of unintended host modification.
# 启动 PostgreSQL 和 Browserless(PDF 导出必需)
sudo dockerd &>/var/log/dockerd.log &
sudo docker compose -f compose.dev.yml up -d postgres browserless
Commands invoke sudo or root privileges. Verify this elevated access is necessary and justified.
# Printer (Browserless for PDF)
# 获取 Docker bridge IP:
# sudo docker network inspect reactive_resume_default --format '{{range .IPAM.Config}}{{.Gateway}}{{end}}'
PRINTER_APP_URL=http://<GATEWAY_IP>:3000
PRINTER_ENDPOINT=ws://<GATEWAY_IP>:4000?token=1234567890
Commands invoke sudo or root privileges. Verify this elevated access is necessary and justified.
# Printer (Browserless for PDF)
# 获取 Docker bridge IP:
# sudo docker network inspect reactive_resume_default --format '{{range .IPAM.Config}}{{.Gateway}}{{end}}'
PRINTER_APP_URL=http://<GATEWAY_IP>:3000
PRINTER_ENDPOINT=ws://<GATEWAY_IP>:4000?token=1234567890
Commands invoke sudo or root privileges. Verify this elevated access is necessary and justified.
# Printer (Browserless for PDF)
# 获取 Docker bridge IP:
# sudo docker network inspect reactive_resume_default --format '{{range .IPAM.Config}}{{.Gateway}}{{end}}'
PRINTER_APP_URL=http://<GATEWAY_IP>:3000
PRINTER_ENDPOINT=ws://<GATEWAY_IP>:4000?token=1234567890
The self-hosting example includes concrete database credentials and a fixed Browserless token without an explicit warning that these are placeholders only. Users may copy them directly into real deployments, leading to weak default credentials, exposed services, and trivial unauthorized access.
This code hard-codes multiple user-visible section labels in English (for example, "Summary", "Work Experience", "Projects", "Education", "Skills") while the surrounding file comments and metadata are in Chinese. That creates a locale policy concern because the rendered output forces one language for end users without any opt-in or configuration path.
This markdown file uses Chinese throughout, including the title and all instructional content, but does not indicate that the language is optional or that the skill is intended only for a Chinese-speaking audience. Under the language/locale policy, forcing a specific language without user opt-in is a natural-language policy violation.
Docker image references without a specific tag (:latest is implicit) or digest (@sha256:...) can be silently replaced by a malicious image.
Commands invoke sudo or root privileges. Verify this elevated access is necessary and justified.
# 安装 certbot
sudo apt install certbot python3-certbot-nginx
# 获取证书
sudo certbot --nginx -d resume.yourdomain.com
Commands invoke sudo or root privileges. Verify this elevated access is necessary and justified.
# 安装 certbot
sudo apt install certbot python3-certbot-nginx
# 获取证书
sudo certbot --nginx -d resume.yourdomain.com
Commands invoke sudo or root privileges. Verify this elevated access is necessary and justified.
# 安装 certbot
sudo apt install certbot python3-certbot-nginx
# 获取证书
sudo certbot --nginx -d resume.yourdomain.com
This markdown file includes commands that can overwrite database contents during restore and permanently delete old backup files, but the surrounding text does not warn users about data loss or irreversible effects. For markdown files, safety-impacting behaviors that affect user data should be disclosed clearly.