In a nutshell
Secret Scanning is GitHub's detection feature that automatically finds API keys, tokens, and connection strings lurking in your repository.
Secrets already committed get an alert; secrets about to be pushed are blocked at git push time by Push protection. Stopping leaks before they happen is the core strategy.
Why secrets matter in private / internal repos
Private does not mean the breach stays contained. An attacker who compromises one developer account or runner can use internally exposed secrets to expand the attack. Keep secrets in a secret manager and block leaks with Push protection. Here are 8 reasons why.
Main capabilities
-
PUSH PROTECTION
In
ghas-test-1, push a generated secret../demo/secret-scanning/01-push-protection.shThe push is blocked and the terminal prints an unblock URL.
Show which patterns are push-protected, enterprise-wide: octodemo โ Pattern configurations โ. Flip a pattern in the Enterprise setting column; the Alert total, False positives, and Bypass rate columns back the noise-vs-risk call with real data.
Same page is revisited on the What gets detected slide, to dig out the generic patterns.
-
BYPASS PUSH PROTECTION
Open the
unblock-secretURL from the block message in your browser, pick a reason and bypass.You get โsecret can now be pushedโ.
Push the same branch again.
git push origin HEADOpen the closed alert under Security โ Secret scanning and show who bypassed it and why.
To keep bypasses under control:
Settings โ Advanced Security โ Push protection, set Who can bypass push protection to Specific roles or teams (= Delegated bypass). -
VALIDITY CHECK
In the default view under Security โ Secret scanning, use the Validity filter.
Triage by real risk: start with the secrets that are still live.
Secret Scanning is made up of five capabilities. Push protection closes the door and comes first; the rest cover detection, triage, and provider-side revocation.
What gets detected
-
WHERE THE GENERIC PATTERNS HIDE
Open octodemo โ Pattern configurations โ and scroll the default patterns tab.
It is one flat list: no category column, no provider / generic split, no filter. The generic patterns are in there, just never labelled as generic.
Point them out by name โ these ten are the entire set:
rsa_private_keyopenssh_private_keyec_private_keypgp_private_keygeneric_private_keymongodb_connection_stringmysql_connection_urlpostgres_connection_stringhttp_basic_authentication_headerhttp_bearer_authentication_headerEvery one reads Disabled under GitHub default: detection is on, push protection is not. Flip one in the Enterprise setting column to opt it in.
-
CUSTOM PATTERN + DRY RUN
Settings โ Advanced Security โ Custom patterns โ New patternMatching secrets are already planted in the demo repo, so you only need to create the pattern:
Pattern name โ
Octodemo internal service tokenSecret format โ
octodemo_(live|test)_[A-Za-z0-9]{32}Test string โ
octodemo_live_L1QNGy4DLxQJ8C85kfwP0lmvCHLDuVxJThe test string has to go green before the form will save. Then use Save and dry run.
The dry run reports the planted secrets without creating alerts. Review the hits, then Publish pattern and optionally turn push protection on for it.
Four detection engines, layered from exact partner formats to unstructured secrets that only AI can catch.
How to manage exposed secrets
-
THE CAMPAIGNS TAB
Open theomonfort-org โ Campaigns โ.
The tracking view: each campaign with its due date, manager, and a burn-down of open vs closed alerts. The point to land: alerts get an owner and a deadline here, not in a spreadsheet.
-
CREATE ONE FROM SECRET SCANNING FILTERS
Create campaign โ From secret scanning filtersBuild the filter live so they see the triage logic. Start from
is:open, narrow to the repos that matter, then set Validity to Active and Unknown.Watch the alert count drop with each filter. That is the whole argument: a finishable list instead of a backlog. Must be 1000 alerts or fewer to save.
-
NAME IT, DATE IT, SHIP IT
Save as โ Draft campaign, then fill in the name, description, due date, and campaign manager.
Note the manager picker only offers org owners and security managers.
Review and publish notifies everyone who can see the alerts, and the campaign shows up in each repo's Security tab. Mention secret campaigns are in public preview.
When a secret is found, remediation matters more than detection. At scale, donโt work the raw alert list, run it as a security campaign.
Getting started (fastest path)
Settings โ Advanced Security
โธ STEP 1 ยท PUSH PROTECTION
Blocks new secrets at push time.
Security โ Secret scanning
โธ STEP 2 ยท EXISTING LEAKS
Scans past history too. Rotate down the list.
โฆ โ Custom patterns
โธ STEP 3 ยท CUSTOM PATTERNS
Your own token formats, by regex.
Org โ โฆ โ Configurations
โธ STEP 4 ยท ROLL OUT
One config applies all of it, org-wide.
โ ๏ธ Legacy org REST API fields were removed 2026-04-21. Use the security configurations API.
Availability by product
| Feature | Public repo | Private / internal without product |
Secret Protection / GHAS |
|---|---|---|---|
| Secret scanning alerts | โ Free | โ | โ Included |
| Push protection (repo / org) | โ Free | โ | โ Included |
| Partner program alerts (sent to the provider) | โ Free, always on | โ | โ Public repos only |
| Validity checks | โ | โ | โ Supported providers |
| Generic patterns | โ | โ | โ Included |
| Custom patterns | โ | โ | โ Included |
| AI-detected secrets | โ | โ | โ Included |
| Public monitoring | โ | โ | โ GHEC Enterprise |
๐ User push protection is free and enabled by default on all plans, but only covers pushes to public repositories. Partner alerts also notify providers only about leaks in public repositories and public npm packages โ always on, and not configurable.
๐ค User-owned repositories are a special case: alerts require GHEC with Enterprise Managed Users, or GHES with Secret Protection enabled on the enterprise. Org-owned private / internal repos only need Secret Protection on Team or GHEC.
๐ฐ Generic, custom, and AI detection, validity checks, and private / internal repository coverage require Secret Protection or a legacy GHAS license. Public monitoring is an enterprise-wide feature for GHEC Enterprise.
๐ Details: Advanced Security products โ / Partner program โ / Public monitoring โ
Public monitoring (NEW) ๐ Docs
- ๐ Public only โ git, PR comments, issues, discussions. Never your private repos.
- โก Real time. Needs Secret Protection or GHAS. Public preview, no extra cost.
- ๐งฉ No setup โ enable it and existing findings appear straight away.
| Attributed by | What it checks | Catches |
|---|---|---|
| ๐ค Member | Committer is a member | Managed and known accounts |
| ๐ Verified domain | Email on your domain | Personal account, work email |
โ๏ธ Turned on under Security and quality, by an enterprise owner or security manager.
Secret Risk Assessment ๐ Docs
Scans every org repo to show what secrets sit where. Free for Team and Enterprise orgs.
- ๐ Scope โ every repo, any visibility, archived included
- ๐ Output โ secret types and counts per repo. Values are never stored or shown.
- ๐ Frequency โ point-in-time, rerunnable every 90 days. Not continuous monitoring.
- ๐ Run it โ
Org โ Security and quality โ Assessments โ Scan your organization. The first run also starts the free code security assessment.
๐ Answers โhow many secrets are leaking?โ and gives you the numbers for a budget case.