Skip to content

feat: add subdomain takeover defense runbook and automated monitor#690

Merged
takaokouji merged 2 commits into
developfrom
feature/security-monitor-subdomain-takeover
May 19, 2026
Merged

feat: add subdomain takeover defense runbook and automated monitor#690
takaokouji merged 2 commits into
developfrom
feature/security-monitor-subdomain-takeover

Conversation

@takaokouji
Copy link
Copy Markdown

Summary

GitHub Pages サブドメイン乗っ取り (stretch3 で 2026-05-18 に発生した事例) に対する Smalruby 側の防御を整備する。

  • 適用済みの 6 層防御を Runbook として記録 (docs/security/github-pages-subdomain-takeover.md)
  • 毎日 04:00 JST に自動チェックする GitHub Actions を追加 (.github/workflows/security-monitor.yml)

Changes Made

docs/security/github-pages-subdomain-takeover.md (新規, 257 行)

  • Threat model — 攻撃ベクトルと影響
  • 6 つの防御レイヤー — Org domain verification / HTTPS 強制 / no wildcard DNS / 2FA enforcement / fork archive / CAA records
  • ドメイン・リポジトリ棚卸し — 現状スナップショット
  • 平常時運用ルール — 立ち上げ / 廃止 / archive / メンバー管理
  • 定期チェック — 自動化されている項目と月次の手動項目
  • 緊急時プレイブック — 検知シグナル → DNS 一時切離し → 復旧

.github/workflows/security-monitor.yml (新規, 216 行)

毎日 19:00 UTC (= 04:00 JST) cron + workflow_dispatch。13 自動チェック:

種別 チェック内容
DNS verification TXT _github-pages-challenge-smalruby.smalruby.{app,jp} の存在
CAA レコード smalruby.app の 6 entry、smalruby.jp の 2 entry すべて
Pages 設定 5 repo (smalruby.app / smalruby.github.com / smalruby3-editor / smalruby3-gui / dxruby_sdl) の https_enforcedprotected_domain_state
コンテンツ改竄検知 https://smalruby.app/ / https://smalruby.jp/ が HTTP 200 で smalruby 文字列を含むか

異常検知時 (cron 実行のみ):

  • security ラベル付き Issue を自動起票
  • 同タイトルの既存 open issue があれば新規作成せずコメント追記 (重複防止)
  • default GITHUB_TOKEN のみ使用、新規 secret は不要

Already applied (PR 範囲外で実施済み、本 PR は記録と監視のみ)

項目 状態
Org level domain verification (smalruby.app / smalruby.jp) protected_domain_state: "verified"
Org 2FA enforcement policy two_factor_requirement_enabled: true
全 Pages リポジトリで HTTPS 強制 ✅ 5/5
不要 fork archive (smalruby3-gui, scratch-vm)
CAA レコード (Let's Encrypt + AWS ACM, wildcard 禁止) ✅ 両ドメインに propagation 済
ACM 未使用証明書 6 件削除

Test Coverage

  • Runbook の Markdown 構造を目視確認
  • security-monitor.yml の checks ロジックをローカルで dry-run → 13 check すべて green
  • YAML syntax 確認 (ruby YAML parser で load 可能)
  • (merge 後) GitHub Actions UI から workflow_dispatch で手動実行し、cron 起動を待たずに緑確認

Related

  • stretch3 の乗っ取り事例 (2026-05-18、数時間で復旧)
  • GitHub Pages の verified custom domain 機構
  • AWS ACM の CAA 対応 (amazon.com / amazontrust.com / awstrust.com / amazonaws.com)

stretch3 が 2026-05-18 に GitHub Pages サブドメイン乗っ取りを受けた事例を
受けて、smalruby 組織が管理する smalruby.app / smalruby.jp の防御を
ドキュメント化し、自動監視を追加。

防御施策自体 (Org level domain verification / 2FA enforcement / HTTPS 強制 /
不要 fork archive / CAA records / ACM 未使用証明書削除) はこの PR の範囲外で
適用済み。本 PR は記録 (Runbook) と継続監視 (自動チェック workflow) を加える。

New files:
- docs/security/github-pages-subdomain-takeover.md
  Threat model、6 層の防御、ドメイン/リポジトリ棚卸し、平常時運用ルール、
  定期チェック、緊急時プレイブック。
- .github/workflows/security-monitor.yml
  毎日 04:00 JST + workflow_dispatch。13 自動チェック (DNS verification
  TXT × 2、CAA × 8 entries、Pages 設定 × 5 repo、コンテンツ改竄 × 2 URL)
  を実行し、異常検知時に security-labeled Issue を自動起票 (重複防止)。
  default GITHUB_TOKEN のみ使用 (新規 secret 不要)。

ローカル dry-run で 13 check すべて green を確認済み。

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@github-actions
Copy link
Copy Markdown

…r.sh

レビュー指摘 (PR #690) に対応。インライン bash を独立 script に切り出し、
ローカル実行と CI 実行で完全に同じスクリプトが動くようにする。

変更:
- scripts/security-monitor.sh (新規, 実行可能): 13 check ロジック。純 bash、
  preflight 依存チェック (gh / dig / curl / jq) と CI/local 両対応の
  ERROR_FILE 機構を持つ。Local: `./scripts/security-monitor.sh`、
  CI: workflow から ERROR_FILE 付きで呼ばれる。
- .github/workflows/security-monitor.yml: 138 行削減。
  checkout → dig インストール → script 実行 → 失敗時 Issue 起票、
  という薄いオーケストレーションだけを担う。Issue 作成は CI 固有の
  関心事として workflow 側に残す。Issue 本文にローカル再現コマンド
  `./scripts/security-monitor.sh` を含める。
- docs/security/github-pages-subdomain-takeover.md: ローカル手動チェックの
  手順と GitHub UI からのオンデマンド実行を「自動化されているチェック」
  セクションに追記。

ローカルで `./scripts/security-monitor.sh` 実行 → 13 check すべて green、
exit 0 を確認。ERROR_FILE 機構の動作も確認 (成功時は未書き込み)。

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@takaokouji takaokouji merged commit 6b4e285 into develop May 19, 2026
9 checks passed
@takaokouji takaokouji deleted the feature/security-monitor-subdomain-takeover branch May 19, 2026 01:51
github-actions Bot pushed a commit that referenced this pull request May 19, 2026
…ity-monitor-subdomain-takeover

feat: add subdomain takeover defense runbook and automated monitor
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant