> ## Content Index
> Fetch the complete content index at: https://taiwanding.com/llms.txt
> Use this file to discover other available public pages before exploring further.

# GCP CI-CD 01：Scanning GCP CI/CD's Private GitHub Repository writeup (zh-TW)
- URL: https://taiwanding.com/gcp-ci-cd-01-scanning-gcp-ci-cds-private-github-repository-writeup-zh-tw/
- Published: 2026-08-10T04:02:18.000Z
- Updated: 2026-08-10T11:10:00.000Z
- Author: Kevin Chen
- Tags: github, #cyberwarefare labs, ci/cd, #google cloud

📚 系列文章 · CyberWarFare Labs · CI/CD Security

1. [GitHub Enumeration 101 — 用一組 PAT 做完整列舉](https://taiwanding.com/github-enumeration-101-writeup-zh-tw/)
2. ▸ GCP CI/CD 01 — 掃描私有 Repo 找 Cloud Run service （本篇）

## 題目資訊

- 平台: CyberWarFare Labs (CWL)
- 分類: CI/CD Security / GCP CI/CD
- 難度: Easy (10 points)
- 題目給予: 一組 GitHub Personal Access Token
- 目標: 找出用來部署此 repo 產出物的 Cloud Run service 名稱

## 解題過程

題目給一組 GitHub PAT，入口為某私有 repo，要找的不是靜態 secret，而是「部署動作」的目標——Cloud Run service 名稱，它寫在 repo 的 CI/CD 設定檔裡。

### Step 1: 身分與 repo 列舉

```bash
TOKEN="[REDACTED_PAT]"

curl -s -H "Authorization: Bearer $TOKEN" https://api.github.com/user | grep '"login"'
curl -s -H "Authorization: Bearer $TOKEN" \
  "https://api.github.com/user/repos?per_page=100&visibility=all" | grep -E '"full_name"|"private"'

```

擁有者 `Secure-Corp-Pro`，可存取私有 repo `Secure-Corp-Pro/GCP-CI-CD-01`。

### Step 2: clone 後盤點結構

要在整包裡找特定設定，clone 下來本地找最快：

```bash
git clone https://$TOKEN@github.com/Secure-Corp-Pro/GCP-CI-CD-01.git
cd GCP-CI-CD-01
find . -path ./.git -prune -o -type f -print

```

結構中無 `.github/workflows/`，但根目錄有 `cloudbuild.yaml`，這本身即情報：管線走 GCP 原生 Cloud Build，而非 GitHub Actions。

### Step 3: 讀 Cloud Build 設定

```bash
cat cloudbuild.yaml

```

部署步驟（Deploy container image to Cloud Run）：

```yaml
- name: 'gcr.io/google.com/cloudsdktool/cloud-sdk'
  entrypoint: gcloud
  args: ['run', 'deploy', '<SERVICE>', '--image', '$_DOCKER_URI/$_PROJECT_ID/$_ARTIFACT_REGISTRY_URI/$_DOCKER_IMAGE_NAME:latest', '--region', '$_DOCKER_REGION']

```

`gcloud run deploy` 後緊跟的第一個值即為 Cloud Run service 名稱（`--image`、`--region` 為參數，非名稱）。

Flag (service 名稱):

```
Redacted
```

## 學習重點

- 「部署」是 CI/CD 的動作，部署目標（雲端 service 名稱、project、region）寫在 repo 的 CI/CD 設定檔，不會躺在資料檔裡——找對檔案比亂翻整個 repo 有效。
- 「沒有 `.github/workflows/` 卻有 `cloudbuild.yaml`」本身就是一條情報：它告訴你這條管線跑在 GCP Cloud Build，CI/CD 設定的「有無」與「種類」都在洩露基礎設施。
- `gcloud run deploy` 後的第一個值是 service 名稱，別跟後面的 `--image` / `--region` 混淆。
- `cloudbuild.yaml` 通常同時洩出 `_PROJECT_ID`、`_ARTIFACT_REGISTRY_URI`、`_DOCKER_REGION` 等欄位——即後續 GCP 關卡的立足情報，讀時順手記下。
- 本關本質是偵察（測繪雲端環境），不是最終攻擊，你在畫地圖，不是破門。

## 實用技巧

```bash
# 在 repo 裡撈 Cloud Run 部署相關行
grep -rniE "cloud run|run deploy|deploy-cloudrun|service:" \
  --include="*.yml" --include="*.yaml" .

# Cloud Build substitution 變數以 $_ 開頭，真實值不在此檔
# 常藏在 Cloud Build trigger 設定、其他檔或 commit 歷史
grep -rn '\$_' cloudbuild.yaml

```

## 補充：這份設定檔洩出的「藍圖」

`cloudbuild.yaml` 定義了完整三段管線：build（docker 打包）→ push（推 Artifact Registry）→ deploy（部署 Cloud Run），image 路徑由 `$_PROJECT_ID`、`$_ARTIFACT_REGISTRY_URI` 等 substitution 變數組成——管線的「形狀」已知，但填進去的「真實值」尚未現身，這正是 GCP-CI-CD-02 要接著挖的東西。