# 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が作成されます。