mcpField
I
implementing-cloud-dlp-for-data-protection

implementing-cloud-dlp-for-data-protection

github.com/mukul975セキュリティ35.2k41 回インストール8 週間前に更新
リポジトリ

implementing-cloud-dlp-for-data-protection について

AWS、Google Cloud、Azure でクラウドのデータ損失防止を実装するためのセキュリティスキルです。機密データの発見、分類、匿名化、パイプライン検査、レポート作成を扱い、エンドポイント、メール、ネットワークの対策とは区別します。

主な機能

  1. 01クラウドデータの発見と分類
  2. 02機密コンテンツの検査と匿名化
  3. 03機密度ラベルとポリシーの設定
  4. 04データパイプラインへの DLP 検査追加
  5. 05検出結果の集約とレポート作成

活用シーン

  1. 01S3 データレイク内の個人情報の発見
  2. 02クラウドストレージの機密データ保護
  3. 03本番投入前のパイプライン出力検査
  4. 04クラウド DLP コンプライアンスレポートの作成

インストール

コマンドをコピーしてターミナルで実行します。

$npx skills add https://github.com/mukul975/anthropic-cybersecurity-skills --skill implementing-cloud-dlp-for-data-protection

インストール後、Claude Code で/implementing-cloud-dlp-for-data-protectionを入力して読み込まれたか確認します。

同梱ファイル

SKILL.md と一緒にインストールされる参考資料やスクリプト。

LICENSE
references/
api-reference.md
scripts/
agent.py

詳細

クラウド DLP によるデータ保護の実装

使用するタイミング

  • コンプライアンスフレームワーク(GDPR、HIPAA、PCI DSS)が、機密データの自動検出と保護を求めている場合
  • クラウドストレージ全体でデータを分類しラベル付けするデータガバナンスプログラムを構築する場合
  • クラウドベースのデータパイプラインにデータ損失防止(DLP)の制御を実装する場合
  • 保護されていない機密データ(PII、PHI、金融データ)がないか、クラウド環境を監査する場合
  • 機密データが本番環境に到達しないよう、DLP スキャンを CI/CD パイプラインに統合する場合

使用しないでください エンドポイント DLP(Microsoft Purview または Symantec DLP エージェントを使用)、メール DLP(Microsoft 365 DLP または Google Workspace DLP を使用)、ネットワークレベルのデータ流出防止(VPC エンドポイントポリシーおよびネットワークファイアウォールを使用)の場合。

前提条件

  • 適切な S3 バケット権限で Amazon Macie が有効になっていること
  • Google Cloud DLP API が有効になっていること(gcloud services enable dlp.googleapis.com)
  • Azure Information Protection または Microsoft Purview が構成されていること
  • DLP サービスの管理およびデータアクセスに関する IAM 権限があること
  • 組織に関連するデータの機密性カテゴリ(PII、PHI、PCI、独自情報)に関する知識があること

ワークフロー

ステップ 1: S3 データ検出のための Amazon Macie のデプロイ

Macie を有効にし、S3 バケットに対して機密データの自動検出ジョブを構成します。

# Enable Amazon Macie
aws macie2 enable-macie

# List all S3 buckets Macie can scan
aws macie2 describe-buckets \
  --query 'buckets[*].[bucketName,classifiableSizeInBytes,unclassifiableObjectCount.total]' \
  --output table

# Create a classification job for specific buckets
aws macie2 create-classification-job \
  --job-type SCHEDULED \
  --name "weekly-pii-scan" \
  --schedule-frequency-details '{"weekly":{"dayOfWeek":"MONDAY"}}' \
  --s3-job-definition '{
    "bucketDefinitions": [{
      "accountId": "ACCOUNT_ID",
      "buckets": ["customer-data-bucket", "analytics-data-lake", "backup-bucket"]
    }],
    "scoping": {
      "includes": {
        "and": [{
          "simpleScopeTerm": {
            "key": "OBJECT_EXTENSION",
            "values": ["csv", "json", "parquet", "txt", "xlsx"],
            "comparator": "EQ"
          }
        }]
      }
    }
  }' \
  --managed-data-identifier-ids '["SSN","CREDIT_CARD_NUMBER","EMAIL_ADDRESS","AWS_CREDENTIALS","PHONE_NUMBER"]'

# Create custom data identifier for internal employee IDs
aws macie2 create-custom-data-identifier \
  --name "EmployeeID" \
  --regex "EMP-[0-9]{6}" \
  --description "Internal employee ID format"

# Check job status and results
aws macie2 list-classification-jobs \
  --query 'items[*].[name,jobStatus,statistics.approximateNumberOfObjectsToProcess]' \
  --output table
ステップ 2: データ検査のための Google Cloud DLP API の構成

Google Cloud DLP を使用して、GCP リソース全体の機密データを検査し、非識別化します。

# Inspect a Cloud Storage bucket for sensitive data
gcloud dlp inspect-content \
  --content-type=TEXT_PLAIN \
  --min-likelihood=LIKELY \
  --info-types=PHONE_NUMBER,EMAIL_ADDRESS,CREDIT_CARD_NUMBER,US_SOCIAL_SECURITY_NUMBER \
  --storage-type=CLOUD_STORAGE \
  --gcs-uri="gs://sensitive-data-bucket/data/*.csv"

# Create an inspection job for BigQuery
cat > dlp-job.json << 'EOF'
{
  "inspectJob": {
    "storageConfig": {
      "bigQueryOptions": {
        "tableReference": {
          "projectId": "PROJECT_ID",
          "datasetId": "customer_data",
          "tableId": "transactions"
        },
        "sampleMethod": "RANDOM_START",
        "rowsLimit": 10000
      }
    },
    "inspectConfig": {
      "infoTypes": [
        {"name": "CREDIT_CARD_NUMBER"},
        {"name": "US_SOCIAL_SECURITY_NUMBER"},
        {"name": "EMAIL_ADDRESS"},
        {"name": "PHONE_NUMBER"},
        {"name": "PERSON_NAME"}
      ],
      "minLikelihood": "LIKELY",
      "limits": {"maxFindingsPerRequest": 1000}
    },
    "actions": [{
      "saveFindings": {
        "outputConfig": {
          "table": {
            "projectId": "PROJECT_ID",
            "datasetId": "dlp_results",
            "tableId": "findings"
          }
        }
      }
    }]
  }
}
EOF

gcloud dlp jobs create --project=PROJECT_ID --body-from-file=dlp-job.json
ステップ 3: Cloud DLP によるデータの非識別化の実装

非識別化変換を構成し、機密データをマスキング、トークン化、またはリダクションします。

# deidentify_pipeline.py - De-identify sensitive data using Google Cloud DLP
from google.cloud import dlp_v2

def deidentify_data(project_id, text):
    """De-identify PII in text using Cloud DLP."""
    client = dlp_v2.DlpServiceClient()

    inspect_config = {
        "info_types": [
            {"name": "EMAIL_ADDRESS"},
            {"name": "PHONE_NUMBER"},
            {"name": "CREDIT_CARD_NUMBER"},
            {"name": "US_SOCIAL_SECURITY_NUMBER"},
        ],
        "min_likelihood": dlp_v2.Likelihood.LIKELY,
    }

    deidentify_config = {
        "info_type_transformations": {
            "transformations": [
                {
                    "info_types": [{"name": "EMAIL_ADDRESS"}],
                    "primitive_transformation": {
                        "character_mask_config": {
                            "masking_character": "*",
                            "number_to_mask": 0,
                            "characters_to_ignore": [
                                {"common_characters_to_ignore": "PUNCTUATION"}
                            ],
                        }
                    },
                },
                {
                    "info_types": [{"name": "CREDIT_CARD_NUMBER"}],
                    "primitive_transformation": {
                        "crypto_replace_ffx_fpe_config": {
                            "crypto_key": {
                                "kms_wrapped": {
                                    "wrapped_key": "WRAPPED_KEY_BASE64",
                                    "crypto_key_name": "projects/PROJECT/locations/global/keyRings/dlp/cryptoKeys/tokenization",
                                }
                            },
                            "common_alphabet": "NUMERIC",
                        }
                    },
                },
                {
                    "info_types": [{"name": "US_SOCIAL_SECURITY_NUMBER"}],
                    "primitive_transformation": {
                        "redact_config": {}
                    },
                },
            ]
        }
    }

    item = {"value": text}
    parent = f"projects/{project_id}/locations/global"

    response = client.deidentify_content(
        request={
            "parent": parent,
            "deidentify_config": deidentify_config,
            "inspect_config": inspect_config,
            "item": item,
        }
    )
    return response.item.value
ステップ 4: Azure Information Protection の構成

Microsoft Purview で、Azure リソース向けの機密ラベルと DLP ポリシーを設定します。

# Connect to Microsoft Purview compliance
Connect-IPPSSession

# Create sensitivity labels
New-Label -DisplayName "Confidential - PII" \
  -Name "Confidential-PII" \
  -Tooltip "Contains personally identifiable information" \
  -ContentType "File, Email"

New-Label -DisplayName "Highly Confidential - Financial" \
  -Name "HighlyConfidential-Financial" \
  -Tooltip "Contains financial data subject to PCI DSS" \
  -ContentType "File, Email"

# Create auto-labeling policy for Azure Storage
New-AutoSensitivityLabelPolicy -Name "Auto-Label-PII" \
  -ExchangeLocation All \
  -SharePointLocation All \
  -OneDriveLocation All \
  -Mode Enable

New-AutoSensitivityLabelRule -Policy "Auto-Label-PII" \
  -Name "Detect-SSN" \
  -ContentContainsSensitiveInformation @{
    Name = "U.S. Social Security Number (SSN)";
    MinCount = 1;
    MinConfidence = 85
  } \
  -ApplySensitivityLabel "Confidential-PII"
# Azure: Configure DLP policy for Storage accounts
az security assessment create \
  --name "storage-sensitive-data" \
  --assessed-resource-type "Microsoft.Storage/storageAccounts"

# Enable Microsoft Defender for Storage with sensitive data threat detection
az security pricing create --name StorageAccounts --tier standard \
  --subplan DefenderForStorageV2 \
  --extensions '[{"name":"SensitiveDataDiscovery","isEnabled":"True"}]'
ステップ 5: データパイプラインへの DLP の統合

ETL およびデータパイプラインのワークフローに DLP スキャンを追加し、機密データの漏えいを防止します。

# pipeline_dlp_gate.py - DLP gate for data pipelines
import boto3
import json

macie_client = boto3.client('macie2')
s3_client = boto3.client('s3')

def scan_pipeline_output(bucket, prefix):
    """Scan pipeline output data for sensitive content before promotion."""
    job_response = macie_client.create_classification_job(
        jobType='ONE_TIME',
        name=f'pipeline-scan-{prefix}',
        s3JobDefinition={
            'bucketDefinitions': [{
                'accountId': boto3.client('sts').get_caller_identity()['Account'],
                'buckets': [bucket]
            }],
            'scoping': {
                'includes': {
                    'and': [{
                        'simpleScopeTerm': {
                            'key': 'OBJECT_KEY',
                            'comparator': 'STARTS_WITH',
                            'values': [prefix]
                        }
                    }]
                }
            }
        },
        managedDataIdentifierSelector='ALL'
    )

    return job_response['jobId']

def check_scan_results(job_id):
    """Check if DLP scan found sensitive data."""
    response = macie_client.list_findings(
        findingCriteria={
            'criterion': {
                'classificationDetails.jobId': {'eq': [job_id]},
                'severity.description': {'eq': ['High', 'Critical']}
            }
        }
    )
    return len(response.get('findingIds', [])) > 0

def gate_decision(bucket, prefix):
    """DLP gate: block pipeline if sensitive data found."""
    job_id = scan_pipeline_output(bucket, prefix)
    has_sensitive_data = check_scan_results(job_id)

    if has_sensitive_data:
        return {
            'decision': 'BLOCK',
            'reason': 'Sensitive data detected in pipeline output',
            'action': 'Apply de-identification before promoting to production'
        }
    return {'decision': 'ALLOW', 'reason': 'No sensitive data detected'}
ステップ 6: DLP の検出結果の監視とレポートの生成

複数のクラウドプロバイダーにわたる DLP の検出結果を集約し、コンプライアンスレポートを生成します。

# Macie: Get finding statistics
aws macie2 get-finding-statistics \
  --group-by "severity.description" \
  --finding-criteria '{"criterion":{"category":{"eq":["CLASSIFICATION"]}}}'

# Macie: List findings by sensitivity type
aws macie2 list-findings \
  --finding-criteria '{
    "criterion": {
      "classificationDetails.result.sensitiveData.category": {"eq": ["PERSONAL_INFORMATION"]},
      "severity.description": {"eq": ["High"]}
    }
  }' \
  --sort-criteria '{"attributeName": "updatedAt", "orderBy": "DESC"}'

# GCP DLP: List job results
gcloud dlp jobs list --project=PROJECT_ID --filter="state=DONE" \
  --format="table(name, createTime, inspectDetails.result.processedBytes, inspectDetails.result.totalEstimatedTransformations)"

# Export Macie findings to S3 for compliance reporting
aws macie2 create-findings-report \
  --finding-criteria '{"criterion":{"category":{"eq":["CLASSIFICATION"]}}}' \
  --sort-criteria '{"attributeName":"severity.score","orderBy":"DESC"}'

主要な概念

用語定義
データ損失防止(Data Loss Prevention)クラウド環境から機密データが不正に開示されることを検出し防止するセキュリティ制御および技術
Amazon Macie機械学習を使用して、S3 バケットに保存された機密データを検出、分類、保護する AWS サービス
Google Cloud DLPCloud Storage、BigQuery、Datastore 全体の機密データを検査、分類、非識別化するための GCP API
データの非識別化(Data De-identification)マスキング、トークン化、暗号化、またはリダクションを用いて機密データを変換し、有用性を保ちつつ識別可能な特性を取り除くこと
機密ラベル(Sensitivity Label)データに付与される分類タグ(Confidential、Highly Confidential)で、DLP ポリシーの適用やアクセス制御をトリガーする
カスタムデータ識別子(Custom Data Identifier)独自の機密データ形式を検出するために DLP サービスに追加する、組織固有のパターン(正規表現またはキーワード)

ツールとシステム

  • Amazon Macie: 自動化された検出結果の生成を伴う、S3 向けの ML ベースの機密データ検出および分類
  • Google Cloud DLP API: 機密データを検査、分類、非識別化、およびリダクションするためのプログラマブル API
  • Microsoft Purview: 機密ラベル付け、自動分類、DLP ポリシーの適用を備えたデータガバナンスプラットフォーム
  • Azure Information Protection: Microsoft 365 および Azure ストレージと統合されたデータ分類およびラベル付けサービス
  • Nightfall AI: SaaS アプリケーションとクラウドインフラストラクチャ全体のスキャンに対応するサードパーティ製クラウド DLP ツール

一般的なシナリオ

シナリオ:保護されていない S3 データレイクでの PII の検出

背景: コンプライアンス監査により、分析チームの S3 データレイクに、暗号化もアクセス制御もされていない CSV ファイルの形で顧客の PII(氏名、メールアドレス、SSN)が含まれていることが判明しました。組織はすべてのデータを分類し、DLP 制御を実装する必要があります。

アプローチ:

  1. Macie を有効にし、データレイクのバケットに対して 1 回限りの分類ジョブを作成する
  2. Macie の検出結果を確認し、どのオブジェクトにどの種類の PII が含まれているかを特定する
  3. 組織固有の形式(従業員 ID、口座番号など)向けにカスタムデータ識別子を作成する
  4. 継続的な検出のために、週次のスケジュール済み Macie ジョブを実装する
  5. データレイクへ昇格させる前に新しいデータをスキャンするデータパイプラインのゲートを構築する
  6. 分析ユースケース向けに非識別化変換(SSN のマスキング、メールアドレスのトークン化)を適用する
  7. 分類済みデータへのアクセスを認可されたロールのみに制限するよう、S3 バケットポリシーを設定する

注意点: Macie は、スキャンされた GB 数に応じて課金されます。大規模なデータレイクでは、コストが大きくなる可能性があります。スコープルールを使用して、リスクの高いオブジェクトタイプ(CSV、JSON、Parquet)に焦点を絞り、既知の安全な形式(圧縮アーカイブ、バイナリファイル)は除外してください。非識別化では、分析に必要なデータの有用性を維持しつつ、再識別のリスクを取り除く必要があります。

出力形式

Cloud DLP Compliance Report
==============================
Organization: Acme Corp
Scan Period: 2026-02-01 to 2026-02-23
Environments: AWS (12 buckets), GCP (3 datasets), Azure (5 storage accounts)

DATA DISCOVERY SUMMARY:
  Total objects/records scanned:    2,847,000
  Objects with sensitive data:        45,200 (1.6%)
  Unique sensitivity categories:      8

SENSITIVE DATA FINDINGS:
  PII (names, emails, phone):       23,400 objects
  Financial (credit cards, bank):     8,700 objects
  Health (PHI, medical records):      3,200 objects
  Credentials (API keys, tokens):     1,400 objects
  Government ID (SSN, passport):      5,800 objects
  Custom (employee ID, account):      2,700 objects

FINDINGS BY SEVERITY:
  Critical:    1,400 (exposed credentials)
  High:       14,200 (unprotected PII/PHI)
  Medium:     18,600 (standard PII)
  Low:        11,000 (non-sensitive patterns)

PROTECTION STATUS:
  Data with encryption at rest:       78%
  Data with access controls:          65%
  Data with sensitivity labels:       12%
  Pipeline data with DLP gates:       30%

REMEDIATION ACTIONS:
  Objects quarantined:                1,400
  De-identification applied:          8,200
  Access controls tightened:         14,200
  Sensitivity labels applied:        45,200

コメント