シークレットスキャンとは — 漏れた鍵は誰が止めるか
5 分で読む
API キーをうっかり GitHub に公開してしまったとき、誰かが気づいて止めてくれるのでしょうか。GitHub の仕組みと、使っているシステムの鍵がその仕組みに入っているか、自分で設定が要るかを確かめました。
まず、言葉をそろえる
| 言葉 | 意味 |
|---|---|
| API キー | システムどうしをつなぐための合言葉の文字列。持っている人は、鍵の持ち主と同じ操作ができる(API キーとは何か) |
| 提供元 | 鍵を発行した会社。freee や Google など |
| GitHub | プログラムの文章(コード)を保管・共有するサービス |
| リポジトリ | GitHub の上の、開発ごとのコードの置き場所。公開にすると、世界中の誰でも読める |
| コミット | コードの変更を、1 回分の記録として手元に残すこと。後で消した行も、前の記録には残る |
| プッシュ | 手元の記録を GitHub に送ること。公開リポジトリなら、送った時点で誰でも見られる |
シークレットスキャンの仕組み
シークレットスキャンは、GitHub に置かれたコードの中から、API キーやパスワードの形をした文字列を探す仕組みです。過去の記録まですべて調べ、 出典を開く確認 2026-10-04GitHub Docs(About secret scanning)原文
Secret scanning scans your entire Git history on all branches of your repository for hardcoded credentials, including API keys, passwords, tokens, and other known secret types.
「形」は、提供元が自分の鍵の文字の並び方を決まりとして書き、GitHub に届けたものです。 出典を開く確認 2026-10-04 出典を開く確認 2026-10-04 出典を開く確認 2026-10-04GitHub Docs(Secret scanning partner program)原文
Identify the relevant secrets you want to scan for and create regular expressions to capture them.
GitHub Docs(About push protection)原文
Rather than alerting you to credential leaks after the fact, push protection blocks pushes that contain secrets before they reach your repository.
GitHub Docs(About secret scanning)原文
When a partner secret is detected, we notify the provider so they can take action, such as revoking the credential.
漏れた鍵は、数分で使われ、長く残る
研究者がわざと AWS(Amazon のクラウド)の鍵を GitHub に置いた実験では、鍵は 1 分 出典を開く確認 2026-10-04 出典を開く確認 2026-10-04Clutch Security(2024-12-03)原文
Just 1 minute. That's how long it took for an attacker to exploit an exposed AWS Access Key on GitHub
Unit 42(Palo Alto Networks・2023-10-30)原文
We found that the actor was able to detect and use the exposed IAM credentials within five minutes of their initial exposure on GitHub.
しかも、漏れた鍵はなかなか取り消されません。GitHub に漏れた鍵の 74% は、31 日後もまだ使えました。 出典を開く確認 2026-10-04 出典を開く確認 2026-10-04Truffle Security(2024-01-10)原文
74% of all leaked keys were still live/valid 31 days after being leaked.
Truffle Security(2026-10-01)原文
Deleting a repository, overwriting a file, or rewriting Git history can remove a secret from where it was found without revoking the underlying credential.
見つけた後に止めるのは、鍵を発行した提供元
| 誰が | 鍵が見つかった後にすること |
|---|---|
| GitHub | 提供元に知らせるだけ。どう扱うかは提供元に任せている GitHub Docs(Secret scanning partner program)原文How you implement this in your secret alert service is up to you, but we recommend considering any secrets that GitHub sends you messages about as public and compromised.出典を開く確認 2026-10-04 |
| Anthropic(Claude) | 公開リポジトリで見つかった鍵を、自動で無効にする Anthropic(Claude Help Center・API key best practices)原文To prevent potential abuse, Anthropic automatically deactivates the exposed API key.出典を開く確認 2026-10-04 |
| AWS | 一部の操作を拒む設定を自動で付ける。AWS(AWS managed policy・AWSCompromisedKeyQuarantineV3)原文Denies access to certain actions, applied by AWS in the event that an IAM user's credentials have been compromised or exposed publicly.出典を開く確認 2026-10-04 Unit 42(Palo Alto Networks・2023-10-30)原文the actor started their operations within four minutes after AWS applied the quarantine policy.出典を開く確認 2026-10-04 |
鍵を取り消す(使えなくする)には、鍵を発行したサービスに入れる必要があります。 出典を開く確認 2026-10-04Truffle Security(2026-10-01)原文
Revocation requires access to the service that issued the credential.
使っているシステムの鍵は、大丈夫か
| 使っているシステム | 公開リポジトリに鍵が漏れたら |
|---|---|
| Google・Microsoft・HubSpot・Notion・Shopify・Slack | GitHub が見つけて、提供元に知らせる。取り消すかは提供元が決める |
| Salesforce | 見つけるが、提供元には知らせない。リポジトリの持ち主にだけ伝わる |
| freee・マネーフォワード・SmartHR・kintone・ジョブカン・Chatwork など、日本の民間 SaaS 41 件 | GitHub は名前で見分けられない。提供元に知らせは届かず、プッシュ保護でも止まらない |
| e-Gov・e-Tax など行政の 9 件、FileMaker・Jotform・Zoho CRM | 同じく、GitHub の対応表に名前が無い |
IT連携マップで API があると確かめた業務システム 65 件を、GitHub が公開している対応表 出典を開く確認 2026-10-04GitHub Docs(Supported secret scanning patterns)原文
Partner alerts: Reported directly to secret providers that are part of secret scanning's partner program.
自分で設定が要るか
| リポジトリ | 何もしなくても動くもの | 自分で設定が要るもの |
|---|---|---|
| 公開リポジトリ | 鍵を探して、提供元に知らせる(無料)。自分が鍵を含むプッシュをしようとすると止まる GitHub Docs(Managing push protection for users)原文Push protection for users is on by default for public repositories出典を開く確認 2026-10-04 |
リポジトリ全体のプッシュ保護は初めは無効で、管理者が有効にする GitHub Docs(About push protection)原文Is disabled by default, and can be enabled by a repository administrator, organization owner, security manager, or enterprise owner出典を開く確認 2026-10-04 |
| 会社(組織)の非公開リポジトリ | シークレットスキャンは動かない | GitHub Team 以上の契約で、有料の GitHub Secret Protection を有効にする GitHub Docs(About secret scanning)原文Organization-owned private and internal repositories: Available with GitHub Secret Protection enabled on GitHub Team or GitHub Enterprise Cloud.出典を開く確認 2026-10-04 GitHub Docs(About GitHub Advanced Security)原文You must be on a GitHub Team or GitHub Enterprise plan in order to purchase GitHub Code Security or GitHub Secret Protection.出典を開く確認 2026-10-04 |
| 個人の非公開リポジトリ | シークレットスキャンは動かない | 使えるのは、企業向けの Enterprise Managed Users の形のときだけ GitHub Docs(About secret scanning)原文User-owned repositories: Available on GitHub Enterprise Cloud with Enterprise Managed Users.出典を開く確認 2026-10-04 |
非公開リポジトリで見つかった鍵は、提供元ではなく、リポジトリの管理者とコミットした人に知らされます。 出典を開く確認 2026-10-04 出典を開く確認 2026-10-04GitHub Docs(Secret scanning partner program)原文
When a match of your secret format is found in a private repository configured for secret scanning, then repository admins and the committer are alerted
GitHub Docs(About push protection)原文
Organizations can define custom patterns for detecting secrets unique to their environment.
GitHub 以外では
GitLab で送る前に止められるのは最上位の Ultimate だけで、提供元に知らせるのも公開・Ultimate のプロジェクトだけです。 出典を開く確認 2026-10-04 出典を開く確認 2026-10-04 出典を開く確認 2026-10-04 出典を開く確認 2026-10-04GitLab Docs(Automatic response to leaked secrets)原文
In public projects, because publicly exposed credentials pose an increased threat.
GitLab Docs(Automatic response to leaked secrets)原文
In projects with GitLab Ultimate, for technical reasons.
Microsoft Learn(Azure DevOps・Secret scanning)原文
You need either GitHub Advanced Security for Azure DevOps or, if you're using the standalone experience, GitHub Secret Protection for Azure DevOps enabled.
Atlassian Support(Bitbucket Cloud・git-secrets-scan pipe)原文
The git-secrets-scan pipe allows you to scan any repository for secrets that might have been inadvertently committed.
手元の PC で動かす道具(Gitleaks・TruffleHog)は、コミットする前に止められます。 出典を開く確認 2026-10-04 出典を開く確認 2026-10-04Gitleaks(GitHub の README)原文
Gitleaks can be implemented as a pre-commit hook directly in your repo
TruffleHog(GitHub の README)原文
TruffleHog can be used in a pre-commit hook to prevent credentials from leaking before they ever leave your computer.
漏れる前に、漏れたときに
| 順 | すること |
|---|---|
| 1 | 使っているシステムの鍵が GitHub の対応表に載っているかを確かめる。載っていなければ、漏れても誰も知らせてくれない前提で扱う |
| 2 | 会社の非公開リポジトリでは、シークレットスキャンとプッシュ保護が有効かを確かめる |
| 3 | 鍵を取り消す画面と、取り消すと止まる連携を、漏れる前に書き出しておく |
| 4 | 漏れたら、まず鍵を取り消して作り直す。コードの過去の記録から消すのは、その後でよい GitHub Docs(About secret scanning)原文While you can also remove secrets from your Git history, this is time-intensive and often unnecessary if you've already revoked the credential.出典を開く確認 2026-10-04 |
| 5 | 権限を絞った鍵や期限のある鍵を選べる製品では、そちらを使う |
- 鍵がどこから漏れるかは API キーはどこから漏れるのか にまとめてあります
- 日本の業務 SaaS で鍵の期限や取り消し方がどこまで文書にあるかは API トークンはいつ切れ、どう取り消すか にあります
- 権限をどこまで絞れるかは 読み取りと書き込み — API 連携のスコープを絞れるか にあります
- AI エージェントに鍵を渡すときの注意は AI エージェントに鍵を渡しても大丈夫か にあります
ここから先は調査の詳細です(約 5 分)。上のカードだけで決められます。調べた 1 件ずつの記録は IT連携マップ に、出典 URL と調査日つきで公開しています。
調査の詳細
GitHub の対応表は、2026 年 10 月 4 日に GitHub Docs の対応表のページ(Supported secret scanning patterns)から取りました。対応表には 204 の提供元の 527 種類の鍵が並び、そのうち 154 の提供元が、鍵を見つけたら知らせを受けるパートナーです。調べた範囲は、IT連携マップで製品のページを公開している業務システムのうち、API があると確かめた 65 件です。製品名と提供元名に、対応表の提供元名が含まれるかで照らし、Microsoft の製品は、Microsoft 365 の API が使う Azure の鍵の種類で数えました。
API がある業務システムの内訳
| 区分 | 件数 | システム |
|---|---|---|
| 対応表に名前がある | 12 件 | Google Classroom・Google フォーム・Google スプレッドシート・Google Workspace・HubSpot・Microsoft Excel・Microsoft Forms・Notion・Salesforce Platform・Salesforce Sales Cloud・Shopify・Slack |
| 名前が無い(日本の民間 SaaS) | 41 件 | ANDPAD・バクラク・BASE・board・BowNow・Buildee 労務安全・ケア樹・Chatwork・ダンドリワーク・どっと原価・formrun・freee人事労務・freee会計・freee申告・Garoon・現場Plus・invox・ジンジャー・ジョブカン会計・ジョブカン勤怠管理・ジョブカン給与計算・カオナビ・KING OF TIME・kintone・LINE WORKS・Misoca・マネーフォワード クラウド会計・マネーフォワード クラウド経費・マネーフォワード クラウド給与・マネーフォワード クラウド請求書・マネーフォワード クラウド社会保険・MOVO Berth・オフィスステーション・Photoruction・楽楽精算・楽天RMS・SmartHR・TKC FX2クラウド・TOKIUM・Yahoo!ショッピング ストアクリエイターPro・弥生(会計/青色申告 オンライン/Next) |
| 名前が無い(行政) | 9 件 | CCUS・e-Gov電子申請・e-Tax・eLTAX / PCdesk・jGrants・自動車OSS・ぴったりサービス・登記ねっと・在留申請オンライン |
| 名前が無い(海外の製品) | 3 件 | FileMaker・Jotform・Zoho CRM |
名前がある 7 社の扱いの違い
| 提供元 | 種類 | 提供元に知らせる種類 | プッシュ保護で止まる種類 |
|---|---|---|---|
| 9 | 8 | 7 | |
| Microsoft(Azure の鍵を含む) | 75 | 67 | 71 |
| Salesforce | 4 | 0 | 4 |
| HubSpot | 4 | 4 | 3 |
| Notion | 3 | 1 | 3 |
| Shopify | 9 | 9 | 9 |
| Slack | 4 | 3 | 3 |
Salesforce の鍵は、対応表に載っていても提供元に知らせる種類が無く、見つかったことはリポジトリの持ち主にしか伝わりません。
漏れた鍵が使えるまま残る期間
| 調べた対象 | 分かったこと |
|---|---|
| AI の学習に使われる公開リポジトリ | 54 万 3,699 件の鍵がまだ使えた。Truffle Security(2026-10-01)原文we found 543,699 credentials that still authenticated.出典を開く確認 2026-10-04 Truffle Security(2026-09-29)原文The median one had been sitting in a public default branch for 784 days.出典を開く確認 2026-10-04 |
| GitHub に漏れた鍵 | 31 日後も 74% が使えた。Truffle Security(2024-01-10)原文74% of all leaked keys were still live/valid 31 days after being leaked.出典を開く確認 2026-10-04 Truffle Security(2024-01-10)原文If a key was revoked, the developer most likely revoked it in the first 3 days.出典を開く確認 2026-10-04 |
鍵が使われるまでの時間(実験)
| 置いた場所 | 使われるまで | 調べた人 |
|---|---|---|
| GitHub | 5 分以内 Unit 42(Palo Alto Networks・2023-10-30)原文We found that the actor was able to detect and use the exposed IAM credentials within five minutes of their initial exposure on GitHub.出典を開く確認 2026-10-04 |
Unit 42(Palo Alto Networks) |
| GitHub | 1 分 Clutch Security(2024-12-03)原文Just 1 minute. That's how long it took for an attacker to exploit an exposed AWS Access Key on GitHub出典を開く確認 2026-10-04 |
Clutch Security |
| PyPI(Python の部品の置き場) | 40 秒 Clutch Security(2024-12-04)原文Forty seconds. That's how quickly an exposed AWS key on PyPI was exploited.出典を開く確認 2026-10-04 |
Clutch Security |
| Docker Hub(アプリの部品一式の置き場) | 170 時間 Cybenari(2024-08-08)原文For DockerHub, it took 170 hours (~7 Days), until the first access attempt出典を開く確認 2026-10-04 |
Cybenari |
どれも、研究者がわざと AWS の鍵を置いて確かめた実験です。
GitHub 以外のサービス
| サービス | 鍵を探す | 送る前に止める | 提供元に知らせる |
|---|---|---|---|
| GitLab | 全プランで使えるが、GitLab Docs(Pipeline secret detection)原文You can run scans and view pipeline secret detection JSON report artifacts in any GitLab tier.出典を開く確認 2026-10-04 GitLab Docs(Pipeline secret detection)原文Copy and paste the following to the bottom of the .gitlab-ci.yml file:出典を開く確認 2026-10-04 |
仕組みはある。GitLab Docs(Secret detection)原文Secret push protection scans commits for secrets when you push changes to GitLab.出典を開く確認 2026-10-04 GitLab Docs(Secret push protection)原文On GitLab Dedicated and GitLab Self-Managed instances, you must allow secret push protection before you can enable it in a project.出典を開く確認 2026-10-04 |
公開・Ultimate のプロジェクトで、GitLab・AWS・Google Cloud・Postman の鍵 GitLab Docs(Automatic response to leaked secrets)原文Notify the partner that issued the secret. The partner can then revoke the secret, notify its owner, or otherwise protect against abuse.出典を開く確認 2026-10-04 |
| Bitbucket(クラウド版) | 組み込みは見つからない。CI に部品を足す | 見つからない | 見つからない |
| Bitbucket Data Center(自社のサーバーに置く版) | 初めから有効 Bitbucket Data Center Docs(Secret scanning)原文Secret scanning is enabled by default in your Bitbucket instance出典を開く確認 2026-10-04 |
— | 自社の利用者にだけ知らせる Bitbucket Data Center Docs(Secret scanning)原文Note that Bitbucket doesn't send email notifications externally.出典を開く確認 2026-10-04 |
| Azure DevOps | 有料の追加機能。使う人の数で課金 Microsoft Learn(Azure DevOps・Advanced Security billing)原文Each active committer to at least one repository with Advanced Security enabled consumes one license.出典を開く確認 2026-10-04 |
同じ有料の機能に入っている | 鍵がまだ使えるかを提供元に問い合わせる Microsoft Learn(Azure DevOps・Secret scanning)原文For supported secret types, GitHub Advanced Security for Azure DevOps automatically asks the issuing provider whether the credential is active出典を開く確認 2026-10-04 |
| npm(JavaScript の部品の置き場) | 公開された部品を GitHub が調べる | — | 対応表の提供元に知らせる GitHub Docs(Secret scanning partner program)原文A similar process sends service providers tokens exposed in public packages on the npm registry.出典を開く確認 2026-10-04 |
| PyPI(Python の部品の置き場) | GitHub などから知らせを受ける | — | PyPI 自身の鍵を取り消す PyPI Docs(Secrets)原文Third parties integrate with PyPI to find, identify and revoke API tokens that are accidentally made public.出典を開く確認 2026-10-04 |
Docker Hub については、公開されたイメージから鍵を探す仕組みの公式な説明は見つかりませんでした。GitLab・Bitbucket・Azure DevOps・npm・PyPI・Docker Hub は、各社の公式文書を 2026 年 10 月 4 日に読んで確かめました。
言えないこと
対応表に名前が無いことは、どんな方法でも見つからないという意味ではありません。GitHub には、提供元を特定しない一般的な鍵や、AI で見つける種類もあり、組織が自分で探す形を足すこともできます。GitHub 以外にも、鍵を探す製品やサービスはあります。日本の業務 SaaS の鍵に、形で見分けられる決まった並びがあるかは確かめていません。ここで言えるのは、日本の民間 SaaS の鍵は、GitHub が名前で見分けて提供元に知らせる仕組みに入っていない、というところまでです。
鍵が使われるまでの時間は、研究者が AWS の鍵で確かめた実験の結果で、実験ごとに置き方も期間も違います。日本の業務 SaaS の鍵で同じことが起きるかは確かめていません。
この記事に登場するシステム(65)
ANDPADBASEBowNowBuildee 労務安全CCUSChatworkFileMakerGaroonGoogle ClassroomGoogle WorkspaceGoogle スプレッドシートGoogle フォームHubSpotJotformKING OF TIMELINE WORKSMOVO BerthMicrosoft ExcelMicrosoft FormsMisocaNotionPhotoructionSalesforce PlatformSalesforce Sales CloudShopifySlackSmartHRTKC FX2クラウドTOKIUMYahoo!ショッピングZoho CRMboarde-Gov電子申請e-TaxeLTAX / PCdeskformrunfreee人事労務freee会計freee申告invoxjGrantskintoneどっと原価ぴったりサービスオフィスステーションカオナビケア樹ジョブカン会計ジョブカン勤怠管理ジョブカン給与計算ジンジャーダンドリワークバクラクマネーフォワード クラウド会計マネーフォワード クラウド社会保険マネーフォワード クラウド経費マネーフォワード クラウド給与マネーフォワード クラウド請求書在留申請オンライン弥生(会計/青色申告 オンライン/Next)楽天RMS楽楽精算現場Plus登記ねっと自動車OSS