[ { "id": "devsecops-real2-001", "scenario": "GitHub Actions Security - Hardening Guide", "instruction": "Analyze GitHub Actions security best practices.", "input": "Platform: GitHub Actions\nPurpose: CI/CD Security\n\nSecurity Issues:\n\n1. Third-party Actions:\n - Using tags instead of commit SHAs\n - No integrity verification\n - Supply chain risk\n\n2. Secret Exposure:\n - Secrets in logs\n - Secrets in artifacts\n - Secrets in environment\n\n3. Permissions:\n - Overly permissive\n - No least privilege\n - Write access when read-only needed\n\n4. Self-hosted Runners:\n - No isolation\n - Shared environments\n - Persistence risk\n\nSecure Configuration:\n\n```yaml\n# Secure workflow\nname: Secure CI\non: [push, pull_request]\n\npermissions:\n contents: read\n packages: write\n\njobs:\n build:\n runs-on: ubuntu-latest\n steps:\n # Pin action to commit SHA\n - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea1465b # v4.1.0\n \n # Use environment secrets\n - name: Build\n env:\n API_KEY: ${{ secrets.API_KEY }}\n run: ./build.sh\n \n # Scan for secrets\n - name: Secret Scan\n uses: trufflesecurity/trufflehog@main\n```\n\nBest Practices:\n1. Pin actions to commit SHA\n2. Use least privilege permissions\n3. Scan for secrets\n4. Use environment protection\n5. Audit workflow runs", "output": "## GitHub Actions Security Guide\n\n### Security Issues\n\n#### 1. Third-party Actions\n```\nUsing tags instead of commit SHAs\nNo integrity verification\nSupply chain risk\n```\n\n#### 2. Secret Exposure\n```\nSecrets in logs\nSecrets in artifacts\nSecrets in environment\n```\n\n#### 3. Permissions\n```\nOverly permissive\nNo least privilege\nWrite access when read-only needed\n```\n\n### Secure Configuration\n\n```yaml\npermissions:\n contents: read\n packages: write\n\njobs:\n build:\n steps:\n # Pin to commit SHA\n - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea1465b\n \n # Use environment secrets\n - name: Build\n env:\n API_KEY: ${{ secrets.API_KEY }}\n run: ./build.sh\n```\n\n### Best Practices\n1. Pin actions to commit SHA\n2. Use least privilege permissions\n3. Scan for secrets\n4. Use environment protection\n5. Audit workflow runs", "metadata": { "platform": "GitHub Actions", "purpose": "CI/CD Security", "category": "devsecops-real" } } ]