Cloud Load BalancingのSSL/TLSセキュリティ強化について

このブログシリーズ 「クラウドセキュリティ 実践集」 では、一般的なセキュリティ課題を取り上げ、「なぜ危険なのか?」 というリスクの解説から、 「どうやって直すのか?」 という具体的な修復手順(コンソール、Google Cloud CLI、Terraformなど)まで、分かりやすく解説します。
この記事では、Cloud Load Balancingの安全なSSLポリシー設定について、リスクと対策を解説します。

ポリシーの説明
ロードバランサーで安全なSSLポリシーを強制し、暗号化通信の強度を確保します。
重要: Google CloudではTLS 1.0およびTLS 1.1のサポートは段階的に終了しています。早急に最新のセキュリティスタンダードへのアップグレードが必要です。
修復方法
コンソールでの修復手順
Google Cloud コンソールを使用して、ロードバランサーに安全なSSLポリシーを適用します。
- Load Balancingコンソールへアクセス
- Google Cloud Consoleにログイン
- ナビゲーションメニューから「ネットワーキング」→「ネットワークサービス」→「ロードバランシング」を選択
- SSL ポリシーの作成
- 左側のメニューから「詳細メニュー」→「SSL ポリシー」を選択
- 「SSL ポリシーを作成」をクリック
- 安全なSSLポリシーの設定
- 名前:
modern-ssl-policy
など、識別しやすい名前を入力 - 最小TLSバージョン:
TLS 1.2
を選択(最新のセキュリティとパフォーマンス向上のため「最小TLSバージョン」を「TLS 1.2」に設定することを推奨) - プロファイル:
制限付き(推奨)
またはモダン
を選択 - プロファイルの詳細:
- 制限付き(RESTRICTED): Google管理の制限付きプロファイル(最も安全、TLS 1.2以上のみをサポート、NIST準拠)
- モダン(MODERN): セキュリティと互換性のバランスを重視(TLS 1.0~1.3をサポート)
- 互換性(COMPATIBLE): レガシーシステムにも対応(デフォルト、セキュリティは低下、TLS 1.0~1.3をサポート)
- 「作成」をクリック
- 名前:
- ロードバランサーへのSSLポリシーの適用
- ロードバランシングのメインページに戻る
- 対象のHTTPS/SSL ロードバランサーをクリック
- 「編集」をクリック
- 「フロントエンドの構成」セクションを展開
- 各HTTPSフロントエンドに対して:
- 「SSL ポリシー」ドロップダウンから作成した安全なポリシーを選択
- 「更新」をクリック
- 既存の非推奨ポリシーの削除
- SSL ポリシーページに戻る
- 非推奨または低セキュリティのポリシーを選択
- 使用中でないことを確認後、「削除」をクリック
Terraformでの修復手順
Cloud Load Balancingに安全なSSLポリシーを適用するTerraformコードと、主要な修正ポイントを説明します。
# 安全なSSLポリシーの作成
resource "google_compute_ssl_policy" "modern_ssl_policy" {
name = "modern-ssl-policy"
description = "Modern SSL policy with TLS 1.2+ and secure cipher suites"
min_tls_version = "TLS_1_2" # 最小TLSバージョンを1.2に設定
profile = "RESTRICTED" # 最も安全なプロファイルを使用
# カスタムプロファイルを使用する場合の例
# profile = "CUSTOM"
# custom_features = [
# "TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256",
# "TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384",
# "TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256"
# ]
}
# HTTPS ロードバランサーの設定
resource "google_compute_global_forwarding_rule" "https" {
name = "https-forwarding-rule"
target = google_compute_target_https_proxy.default.id
port_range = "443"
ip_protocol = "TCP"
load_balancing_scheme = "EXTERNAL"
ip_address = google_compute_global_address.default.id
}
# HTTPS プロキシの設定(SSLポリシーを適用)
resource "google_compute_target_https_proxy" "default" {
name = "https-proxy"
url_map = google_compute_url_map.default.id
ssl_certificates = [google_compute_ssl_certificate.default.id]
# 安全なSSLポリシーを適用
ssl_policy = google_compute_ssl_policy.modern_ssl_policy.id
}
# SSL証明書の設定(マネージド証明書の例)
resource "google_compute_managed_ssl_certificate" "default" {
name = "managed-cert"
managed {
domains = ["example.com", "www.example.com"]
}
}
# URLマップの設定
resource "google_compute_url_map" "default" {
name = "url-map"
default_service = google_compute_backend_service.default.id
}
# バックエンドサービスの設定
resource "google_compute_backend_service" "default" {
name = "backend-service"
protocol = "HTTPS" # バックエンドもHTTPSを使用
port_name = "https"
timeout_sec = 10
enable_cdn = true
# ヘルスチェックの設定
health_checks = [google_compute_health_check.default.id]
# バックエンドグループ
backend {
group = google_compute_instance_group_manager.default.instance_group
balancing_mode = "UTILIZATION"
capacity_scaler = 1.0
}
# セキュリティポリシーの適用(オプション)
security_policy = google_compute_security_policy.default.id
}
# セキュリティポリシー(追加のセキュリティ対策)
resource "google_compute_security_policy" "default" {
name = "security-policy"
# OWASP Top 10対策
rule {
action = "deny(403)"
priority = 1000
match {
expr {
expression = "origin.region_code == 'XX'" # 特定地域からのアクセスをブロック
}
}
}
# レート制限
rule {
action = "rate_based_ban"
priority = 2000
match {
versioned_expr = "SRC_IPS_V1"
config {
src_ip_ranges = ["*"]
}
}
rate_limit_options {
conform_action = "allow"
exceed_action = "deny(429)"
enforce_on_key = "IP"
rate_limit_threshold {
count = 100
interval_sec = 60
}
}
}
}
# 既存のロードバランサーを更新する場合
# data sourceを使用して既存のリソースを参照
data "google_compute_target_https_proxy" "existing" {
name = "existing-https-proxy"
}
# 既存のHTTPSプロキシにSSLポリシーを適用
resource "null_resource" "update_ssl_policy" {
provisioner "local-exec" {
command = <<-EOT
gcloud compute target-https-proxies update ${data.google_compute_target_https_proxy.existing.name} \
--ssl-policy=${google_compute_ssl_policy.modern_ssl_policy.name} \
--global
EOT
}
}
# モニタリング用のアラート設定
resource "google_monitoring_alert_policy" "ssl_handshake_failures" {
display_name = "SSL Handshake Failures Alert"
combiner = "OR"
conditions {
display_name = "SSL handshake failure rate"
condition_threshold {
filter = "metric.type=\"loadbalancing.googleapis.com/https/ssl_handshake_count\" AND metric.label.ssl_handshake_result!=\"SUCCESS\""
duration = "60s"
comparison = "COMPARISON_GT"
threshold_value = 10
aggregations {
alignment_period = "60s"
per_series_aligner = "ALIGN_RATE"
}
}
}
notification_channels = [google_monitoring_notification_channel.email.id]
}
まとめ
この記事では、Cloud Load Balancingの安全なSSLポリシー設定について、リスクと対策を解説しました。
Cloud Load BalancingのSSLポリシーを適切に設定することは、ウェブアプリケーションのセキュリティを確保する上で重要な要素です。RESTRICTEDプロファイルの使用により、最新のセキュリティ基準を満たしつつ、高いパフォーマンスを実現できます。クライアントの互換性を考慮しながら、段階的にポリシーを移行することで、スムーズなセキュリティ強化が可能です。
この問題の検出は弊社が提供するSecurifyのCSPM機能で簡単に検出及び管理する事が可能です。 運用が非常に楽に出来る製品になっていますので、ぜひ興味がある方はお問い合わせお待ちしております。 最後までお読みいただきありがとうございました。この記事が皆さんの役に立てば幸いです。