Upgrade to Pro — share decks privately, control downloads, hide ads and more …

検索システムにおけるセキュリティ

Avatar for SatohJohn SatohJohn
September 26, 2025

 検索システムにおけるセキュリティ

2025/09/25 SRETT #13 クラウドセキュリティ
で発表した資料になります

Avatar for SatohJohn

SatohJohn

September 26, 2025
Tweet

More Decks by SatohJohn

Other Decks in Technology

Transcript

  1. 自己紹介 佐藤 慧太@SatohJohn • 2023/1 株式会社スリーシェイク入社 • Google Cloud Partner

    Top Engineer ’24、’25 選出 • お客様の労苦 <Toil>を減らす • 娘のお世話を精一杯やっています
  2. About US 会社名 株式会社スリーシェイク 設立日 2015/1/15 Mission: インフラをシンプルにして イノベーションが起こりやすい世界を作る Vision:

    労苦〈Toil〉を無くすサービスを適正な価格で提供し続ける Value: エンジニアリングレイヤーに横たわる人、手法、ツールが サイロ化されて労苦が発生しているプロセスをシンプルにし サービス機能開発に集中できるソリューション (SRE、DevSecOps、DataOps、HROps)を提供する 2015 2016 2017 2018 2019 2020 2021 2022 0 50 100 従業員: 200名over Engineer 60% 所在地 東京都新宿区大京町22-1 グランファースト新宿御苑3F・4F  代表者 代表取締役社長 吉田 拓真 沿革 2021年1月 JAFCOから総額5億円の資金調達 2022年8月 自動脆弱性診断ツール「Securify Scan」をリ リース。JAFCO、MUCAPから総額8.48億円の資金調達 Googleクラウド・AWSの両方のエンジニアリングに強みを持つ (2025年9月に、GoogleCloudのAppDevスペシャライゼーションを取得)
  3. SREを主軸にクラウドネイティブ化/エンジニアリング内製化を支援 SRE/DevOps SecOps BizOps HR ・SRE総合支援からセキュリティ対 策を全方位支援 ・Geminiを用いた生成AIの活用支援 ・ワンストップで脆弱性診断を行う セキュリティ対策SaaS

    ・クラウド型ETL/データパイプ ラインSaaSの決定版 ・あらゆるSaaSをノーコードで連携 ・ハイスキルフリーランスエンジニ ア紹介エージェント IT内製化 / 高度化 クラウドネイティブ化 モダナイゼーション ITアジリティ向上
  4. SREを主軸にクラウドネイティブ化/エンジニアリング内製化を支援 SRE/DevOps SecOps BizOps HR ・SRE総合支援からセキュリティ対 策を全方位支援 ・Geminiを用いた生成AIの活用支援 ・ワンストップで脆弱性診断を行う セキュリティ対策SaaS

    ・クラウド型ETL/データパイプ ラインSaaSの決定版 ・あらゆるSaaSをノーコードで連携 ・ハイスキルフリーランスエンジニ ア紹介エージェント IT内製化 / 高度化 クラウドネイティブ化 モダナイゼーション ITアジリティ向上
  5. 目次 1. Google Cloud での社内検索システムについて 2. ユーザが検索する機能 ◦ AI Application

    + Workforce Identity を使った閲覧 権限の仕組み 3. 検索用データをためる機能 ◦ ドキュメントの機微情報を検査、マスキングの仕組み 4. まとめ
  6. 今回紹介するセキュリティに関する機能 1. ユーザが検索する機能 ◦ AI Application + Workforce identity 2.

    検索用データを貯める機能 ◦ Data Loss Prevention 3. 検索結果を評価する機能 ◦ BigQuery + Looker studio
  7. AI Application(Vertex AI Search) http://cloud.google.com/products/agent-builder?hl=ja • ファイルのセマンティック検索を実現できるマネージドサービス ◦ 非構造化、構造化、画像など ◦

    BigQuery や GCS などをデータソースとして利用できる • 内部でファイルのチャンクごとに embedding して index データが作られる • Boost 機能などがあり、特定の文字で検索順序を変える、なども できる • AI Applications なのか、Agent Builderなのかよくわかんなくなる
  8. Workforce Identity 外部 IdP の情報で Google Cloud へ SSO を行うためのサービス

    他社製品で言えば • AWS IAM Identity Center • Microsoft Entra ID https://cloud.google.com/iam/docs/workforce-identity-federation https://learn.microsoft.com/ja-jp/education/windows/configure-aad-google-trust https://docs.aws.amazon.com/ja_jp/singlesignon/latest/userguide/what-is.html
  9. Workforce Identity • Pool と Provider が存在しており、 Pool : Provider

    = 1 : 多 となる • Pool に対して IAM を設定することで Google Cloud が利用可能 ◦ 利用できないサービスもあるので注意 ▪ Cloud Run サービス エンドポイントへのアクセス ▪ GCS への個別 ACL ▪ Gemini for Google Cloud のライセンスでの利用 ▪ Vertex AI エージェントの作成とプレビュー ▪ Firestore の セキュリティ ルールでの利用 etc https://cloud.google.com/iam/docs/federated-identity-supported-services?hl=ja
  10. Workforce Identity Workforce Identity と似ているものに Workload Identity がある Workforce =

    従業員 Workload = アプリケーション • サービスアカウントキーの代わりに フェデレーション ID を使用する これにより、セキュリティリスクを軽減し ID 管理を簡素化にする • Kubernetes や Compute Engine などの Google Cloud サービスで実行されている アプリケーションに適用できる • オンプレミス や マルチクラウド 環境の ワークロードにも使用できる • Cloud Identity の Google Cloud Directory Sync (GCDS) とは異なり、 既存の IdP から Google Cloud ID に ユーザー ID を同期する必要がない • 属性マッピング と 属性条件 による きめ細かなアクセス制御が可能 • シングルサインオン (SSO) を実現し、 ユーザーエクスペリエンスを向上させ ることができる
  11. 1. 基本 ◦ jsonl の import するドキュメントに ACL を設定する ◦

    Workforce Identity のマッピングを行う ◦ Workforce Identity のログイン情報で検索する 2. 特殊な権限管理 ◦ jsonl の meta tag に Groups をつける ◦ ユーザに紐づく Group を取得する ◦ filter を付けて検索する 閲覧権限実装方法
  12. 1. 基本 ◦ jsonl の import するドキュメントに ACL を設定する ◦

    Workforce Identity のマッピングを行う ◦ Workforce Identity のログイン情報で検索する 2. 特殊な権限管理 ◦ jsonl の meta tag に Groups をつける ◦ ユーザに紐づく Group を取得する ◦ filter を付けて検索する 閲覧権限実装方法
  13. 実装例 - jsonl ファイル - • acl_info に入れる ◦ principals

    は 250件まで可能 { "id": "id", "structData": "<JSON string>", "content": { "mimeType": "<application/pdf or text/html>", "uri": "gs://<your-gcs-bucket>/directory/filename.pdf" }, "acl_info": { "readers": [ { "principals": [ { "group_id": "group_1" }, { "user_id": "user_1" } ] } ] } }
  14. 実装例 - Workforce Identity - Workforce Identity の subject と

    groups に紐付ける OIDC と SAML があるが アプリケーションで API として 利用するためデータ量の少ない OIDC をお勧め
  15. 実装例 - Workforce Identity 情報の取得 - from google.auth import identity_pool

    class AuthSubjectTokenSupplier(identity_pool.SubjectTokenSupplier): def get_subject_token(self, context, re): return id_token credentials = identity_pool.Credentials( audience=AUTH_AUDIENCE, token_url="https://sts.googleapis.com/v1/token", subject_token_type="urn:ietf:params:oauth:token-type:jwt", subject_token_supplier=AuthSubjectTokenSupplier(), ) client = discoveryengine.SearchServiceClient( client_options=ClientOptions( api_endpoint=f"{LOCATION}-discoveryengine.googleapis.com" ), credentials=credentials, ) response: pagers.SearchPager = client.search(request)
  16. from google.auth import identity_pool class AuthSubjectTokenSupplier(identity_pool.SubjectTokenSupplier): def get_subject_token(self, context, re):

    return id_token credentials = identity_pool.Credentials( audience=AUTH_AUDIENCE, token_url="https://sts.googleapis.com/v1/token", subject_token_type="urn:ietf:params:oauth:token-type:jwt", subject_token_supplier=AuthSubjectTokenSupplier(), ) client = discoveryengine.SearchServiceClient( client_options=ClientOptions( api_endpoint=f"{LOCATION}-discoveryengine.googleapis.com" ), credentials=credentials, ) response: pagers.SearchPager = client.search(request) 実装例 - Workforce Identity 情報の取得 - 認証後に作られた idp から 得られた id_token を使って sts.googleapis と交換する クライアント作成時に認証結果を入れる
  17. 基本閲覧権限のメリデメ 1. メリット ◦ Autocomplete でも権限がきく ◦ マネージドなデフォルト UI で使える

    2. デメリット ◦ IdP の設定がどうなっているか次第でこの手法が取れない ▪ 例えば Group のマッピングができない、Group がメールアドレス 形式ではないなど https://cloud.google.com/generative-ai-app-builder/docs/data-source-access-control?hl=ja
  18. 1. 基本 ◦ jsonl の import するドキュメントに ACL を設定する ◦

    Workforce Identity のマッピングを行う ◦ Workforce Identity のログイン情報で検索する 2. 特殊な権限管理 ◦ jsonl の meta tag に groups をつける ◦ ユーザに紐づく group を取得する ◦ filter を付けて検索する 閲覧権限実装方法
  19. 実装例 - jsonl ファイル - { "id": "id", "structData": {

    "description": "説明", "title": "filename.pdf", "filename": "filename.pdf", "groups": ["group 02","group 04"] }, "content": { "mimeType": "<application/pdf or text/html>", "uri": "gs://<your-gcs-bucket>/directory/filename.pdf" }, } • structData or jsonData に入れる ◦ Groups を勝手に作る。別の名前でも問題ないです。
  20. 実装例 - filter条件について - filter_str = f'groups : ANY(\"{"\",\"".join(groups)}\")' request

    = discoveryengine.SearchRequest( serving_config=client.serving_config_path( project=PROJECT_ID, location=LOCATION, data_store=DATASTORE_ID, serving_config="default_search:search", ), query_expansion_spec=discoveryengine.SearchRequest.QueryExpansionSpec( condition=discoveryengine.SearchRequest.QueryExpansionSpec.Condition.AUTO ), spell_correction_spec=discoveryengine.SearchRequest.SpellCorrectionSpec( mode=discoveryengine.SearchRequest.SpellCorrectionSpec.Mode.AUTO ), query=query, filter=filter_str, )
  21. filter_str = f'groups : ANY(\"{"\",\"".join(groups)}\")' request = discoveryengine.SearchRequest( serving_config=client.serving_config_path( project=PROJECT_ID,

    location=LOCATION, data_store=DATASTORE_ID, serving_config="default_search:search", ), query_expansion_spec=discoveryengine.SearchRequest.QueryExpansionSpec( condition=discoveryengine.SearchRequest.QueryExpansionSpec.Condition.AUTO ), spell_correction_spec=discoveryengine.SearchRequest.SpellCorrectionSpec( mode=discoveryengine.SearchRequest.SpellCorrectionSpec.Mode.AUTO ), query=query, filter=filter_str, ) 実装例 - filter条件について - meta tag の組み立てを行う
  22. 特殊な権限管理のメリデメ 1. メリット a. 自分たちでデータベースを持って権限管理ができる i. 認可部分を負担するイメージ 2. デメリット a.

    Autocomplete で filter が使えないそのままでてきてしまう b. Vertex AI Search の管理者はドキュメントを参照ができてしまう
  23. 方法 1. GCS にファイルを配置時にチェック処理を実施 ◦ ただし、ディレクトリごとに、チェック強めなどの設定をおこなう ◦ Template を作成してマッピングする 2.

    チェックして、問題があれば、ファイルを移動する 3. 問題があるファイルなら、マスク処理を実施する ◦ 問題があるファイルはそのまま残るため、後に確認ができる
  24. Cloud Data Loss Prevention 今回使うのは検査と、マスキングの2つ • もともと Sensitive Data Protection

    という機能 • BigQuery のレコードや Google Cloud Storage のファイルに対して 検査、検出、分類、マスキングなどのタスクを実施することができる • 検出するパターンは InfoType で定義されており、ないものはカスタムとして 作成することもできる • Google Cloud の Security 試験では頻出のサービス
  25. Cloud Data Loss Prevention - 検査 - • どういうところがだめなのかをチェックする ◦

    信頼度などで誤検知、すり抜けを調整する • 検査結果をほかサービスへ通知する ◦ BigQuery、PubSub、Security Command Center、 Dataplex、メール 通知、Cloud Monitoringへの公開 ◦ ただし複数へは送れないため、複数へ送る場合は PubSub に送るなどが 必要になる
  26. Cloud Data Loss Prevention - マスキング - • だめなところをマスクする ◦

    マスクの仕方は特定の文字列で埋める、文字をずらすなど様々 ◦ テキスト、構造化データ、画像が対象 • 検査の構成を利用することができる ◦ 検査結果引っかかったものをマスクするイメージ ◦ Infotype を使った exclude の Ruleset を使うとうまく行かないので注意 • マスク処理結果については、通知は送れない
  27. Cloud Data Loss Prevention - InfoType - • 電話番号などの Google

    Cloud で用意されているものが多い ◦ 条件はテスト(Google Cloud のコンソールで可能)してみてわかる ◦ 例えば 09000010001 のような数値は引っかからないが、 TEL: 09000010001 のようにプレフィックスがあると引っかかったり 090-0001-0001 でも引っかかるようになる • 格納される type として custom ◦ 辞書、正規表現などで定義することができる • テスト自体は、マスキングではなくても使えるようにしてほしい
  28. 実装例 - 検査 - inspect_job = { 'storage_config': { 'cloud_storage_options':

    { 'file_set': { 'url': f"gs://{input_storage_bucket}/{file_name}" } } }, 'inspect_template_name': f"projects/{project}/locations/global/inspectTemplates/{inspect_template_id}", 'actions': [{ 'pub_sub': { 'topic': f'projects/{project}/topics/{pub_sub_topic}' } }] }
  29. 実装例 - マスキング - storage_config = { "cloud_storage_options": {"file_set": {"url":

    f"gs://{input_gcs_bucket}/{file_name}"}} } transformation_config = { "deidentify_template": f"{parent}/deidentifyTemplates/{deid_template_id}", "image_redact_template": f"{parent}/deidentifyTemplates/{image_redact_template_id}", } actions = [ { "deidentify": { "cloud_storage_output": f"gs://{output_gcs_bucket}", "transformation_config": transformation_config, "transformation_details_storage_config": {"table": big_query_table}, "file_types_to_transform": ["IMAGE", "TEXT_FILE"], } } ] inspect_job = { 'inspect_template_name': f"projects/{project}/locations/global/inspectTemplates/{inspect_template_id}", "storage_config": storage_config, "actions": actions, } BigQuery に結果を保存する テキスト、画像のデータを対象にする
  30. 実装例 dlp = google.cloud.dlp_v2.DlpServiceClient() response = dlp.create_dlp_job( request={ "parent": parent,

    "inspect_job": inspect_job, } ) logger.info(f"Inspection Job started: {response.name}")
  31. まとめ 1. Google Cloud での検索システムは Vertex AI Search を使うと良い 2.

    上記システムのセキュリティには以下がある ◦ ユーザが検索する機能 - ACL ◦ 検索用データをためる機能 - DLP 3. これ以外にも GCS のセキュリティなどもあるが今回は割愛 ◦ 懇親会や Slido などで聞いて下さい