MSBA-369 · Lesson 4 of 12 · 21 min
Domain review: Secret Protection
▶ Video coming soon A video version of this lesson is on the way.
Seraphine brought the most complete set of notes to the fourth session, because the second domain was the work she had done with her own hands. She had rolled out secret scanning across Skerry after the migration, watched 1,312 historical alerts appear, written the store gateway token pattern and set up delegated bypass for the store-systems organization. "The trap for me," she said, "is answering from Skerry's settings instead of GitHub's defaults. The exam asks what GitHub does, not what we chose."
The domain Configure and use Secret Protection (formerly secret scanning) carries 15 to 20 percent of the exam. It was taught in Secret scanning and alerts, Push protection, and Custom patterns and validity checks in GitHub Advanced Security: Secret Protection and Supply Chain Security, with the incident response in Case study: removing leaked credentials. The outline asks you to enable and configure secret scanning, understand what it detects and where, use push protection and its bypass controls, define custom patterns and work with alerts from detection to closure.
What secret scanning does when you turn it on
When secret scanning is enabled for a repository, GitHub scans the entire Git history on all branches, not just the latest commit, and then scans every new push. It also scans content outside the code: issue titles, descriptions and comments, pull request titles, bodies and comments, discussions and wiki pages, among other locations listed in the documentation. Skerry found nine active credentials in issue comments, which is exactly why this matters: a secret pasted into an issue is as exposed as one in code.
Secret scanning detects three kinds of secret. Provider patterns are token formats registered by service providers, such as cloud keys and payment tokens. Non-provider patterns are generic structured secrets, such as private keys and connection strings with embedded credentials. Copilot secret scanning uses AI to find unstructured secrets such as generic passwords, and lists them separately because they are less precise. On top of these, an organization can define its own custom patterns.
One alert is raised for each unique secret value, with every location where that value appears listed inside it. If the same key appears in five files and two issue comments, there is one alert with seven locations. Closing the alert closes it for all locations, which is why revoking the secret, not deleting one copy, is the remedy.
Push protection
Push protection checks pushes for supported secrets and blocks the push when it finds one, showing the developer the secret type and location in the terminal or the web editor. It works on the command line, in the web interface and through the API, and also checks file uploads in the web interface. Enabling it at repository level protects that repository for everyone who pushes to it.
Push protection for users is different, and the difference is a favorite exam distinction. It is a personal setting, on by default for accounts on GitHub.com, that protects pushes by that user to any public repository, regardless of whether the repository has push protection enabled. Repository push protection protects a repository from all its contributors; user push protection protects a user from leaking into any public repository.
When blocked, the developer can remove the secret and push again, or bypass the block by choosing a reason. The three reasons have different consequences, and questions often turn on them.
| Bypass reason | What GitHub records | Typical meaning |
|---|---|---|
| It's used in tests | An alert closed as used in tests | The value is a test fixture with no real access |
| It's a false positive | An alert closed as false positive | The match is not a secret at all |
| I'll fix it later | An open alert | A real secret the developer intends to revoke |
Every bypass is recorded and visible to people who review alerts, with the person who bypassed and the reason. Skerry's first month of push protection showed 173 blocks and 22 bypasses: nine used in tests, eight false positives and five fix later. Seraphine reviewed all 22, and two of the used in tests reasons turned out to be real credentials. That is the case for delegated bypass.
Delegated bypass and exemptions
Delegated bypass removes the developer's ability to bypass on their own. Instead the developer submits a bypass request with a comment, and a designated set of reviewers approves or denies it. Reviewers can be teams, roles and, since late 2025, enterprise teams, organization roles and GitHub Apps. While a request is pending the push stays blocked; if approved, the developer can push the commit within the allowed window; requests that are not answered expire. Delegated bypass can be set for a repository, through a security configuration for an organization, or at enterprise level.
Exemptions, added in March 2026, are the opposite tool: named roles, teams or apps whose pushes are not blocked at all. They exist for automation such as a migration app that must push historical content, and for very narrow cases. Exemptions do not create bypass requests. Skerry used one exemption for its migration app and removed it when the migration finished. On the exam, choose delegated bypass when the goal is review and choose an exemption only when the goal is to let a specific trusted actor through without review.
Worked problem
Choosing the control
Skerry's store-systems organization wants three things: developers must never bypass push protection on their own; a security reviewer should decide within hours; and the nightly mirror app that copies vendor code must never be blocked. Which controls meet each need?
Show solution
- No self-bypass, with a reviewer deciding: delegated bypass, with the application security team as reviewers.
- Within hours: a working agreement, not a setting; Skerry set a four-hour target for reviews.
- Never block the mirror app: an exemption for that app, documented with an owner and a review date.
- Check the side effect: the exemption means secrets the app pushes are not blocked, so secret scanning alerts remain the safety net.
Answer: Delegated bypass for people, an exemption for the mirror app, and secret scanning alerts as the safety net.
Custom patterns
Custom patterns detect secrets that GitHub does not know about, such as internal tokens. A pattern is a regular expression for the secret itself, with optional before and after expressions for surrounding context and optional additional match requirements that must or must not match. Patterns use the Hyperscan regular expression syntax, which differs slightly from the syntax many developers know. Patterns can be defined at repository, organization or enterprise level; a pattern defined higher up applies to every repository below with secret scanning enabled.
Before publishing, run a dry run, which tests the pattern against selected repositories and shows sample matches without creating alerts. A noisy pattern published without a dry run can bury real alerts under false positives. After publishing, you can turn on push protection for the pattern, which makes it block pushes the way provider patterns do. Editing a published pattern rescans with the new definition.
| Skerry pattern | Level | Push protection | Why |
|---|---|---|---|
| Store gateway token: sgw_ followed by 32 hexadecimal characters | Enterprise | On | Distinctive prefix gives very few false positives |
| Loyalty partner key, matched with context | Enterprise | Off, alerts only | Needs surrounding words; too noisy to block |
| Warehouse scanner device secret | Organization (store systems) | On | Exists only in that organization |
| Legacy reporting password | Repository | Off | One old repository; retired next year |
Copilot can generate a custom pattern from a plain description and sample strings, which is a fast start, but the dry run is still the test. GitHub cannot check the validity of custom pattern matches, because it has no way to ask an internal system whether a token works.
Validity checks and metadata
For many provider patterns, Secret Protection can check whether a detected secret is still active by asking the provider. Alerts then show active, inactive or unknown. Validity checks can run automatically when enabled and on demand from an alert. Active secrets go first in triage; inactive secrets still need closing, and their presence shows a practice problem. Unknown means GitHub cannot tell, not that the secret is harmless. Some providers also return extended metadata, such as the owner of a key, to speed up revocation.
Alerts, closure and notifications
Secret scanning alerts list the secret type, locations, validity, and who pushed it and when. They can be assigned, and they are closed with one of four reasons: revoked, false positive, used in tests or won't fix. Only revoked means the risk is removed. With delegated alert dismissal, closing an alert becomes a request that a reviewer approves, preventing a developer from quietly dismissing a real secret.
Alerts notify repository administrators and people with access to security alerts, and commit authors are notified about their own secrets. A repository can exclude paths from secret scanning alerts with a configuration file, which is meant for directories of documented fake credentials, not for hiding real ones.
# .github/secret_scanning.yml
paths-ignore:
- "docs/examples/**"
- "test/fixtures/fake-keys/**"Remediation always starts with revoking or rotating the secret at its source. Removing it from history is optional and disruptive: the secret was exposed from the moment it was pushed, and anyone who cloned the repository has it. Skerry's November 17 incident followed this order: the service-account key was revoked 49 minutes after the alert, logs were checked for misuse, and the alert was closed as revoked. History was not rewritten.
Worked problem
Reading an alert under time pressure
A question shows an alert: type cloud storage key; validity active; locations: one file on a feature branch and one issue comment; pushed by a contractor eight days ago; open. The team deleted the file on the branch yesterday. What is the next action?
Show solution
- The secret is still active, and it remains in history and in the issue comment.
- Deleting one copy does not remove the exposure; the alert covers every location of the value.
- Revoke or rotate the key with the provider, then check access logs for misuse.
- Edit the issue comment to remove the value, then close the alert as revoked.
Answer: Revoke the key first; then clean up the comment and close the alert as revoked.
Priya's index cards from this session read: "history plus issues and PRs; one alert per value; user protection is for public repos; fix later stays open; delegated bypass equals review; exemption equals no block; dry run before publish; revoke before rewrite."
Secret Protection across an organization
Several Secret Protection features only make sense above a single repository, and they appear in questions about scale. Security overview has a secret scanning view that lists alerts across all repositories, filterable by provider, validity, bypass status and custom properties; Seraphine used the validity filter to cut Skerry's 1,312 historical alerts to the 214 active ones in the first hour. Security overview also reports push protection metrics: how many pushes were blocked, how many were bypassed and with which reasons, and which repositories bypass most. Those metrics are how a security team finds the repositories that need delegated bypass.
Custom patterns defined at enterprise level apply to every organization, which is why Skerry put its store gateway token pattern there. Delegated bypass can be configured through an enterprise configuration, with reviewers who are enterprise teams. Alert access can be granted to teams across repositories through roles rather than one repository at a time. And the audit log records bypasses, dismissals and changes to patterns, so an auditor can reconstruct who allowed what.
| Question about | Look first at |
|---|---|
| Which secrets are still dangerous | Validity filter in security overview |
| Which teams bypass most | Push protection metrics in security overview |
| Who approved a bypass | The bypass request and the audit log |
| Which repositories lack secret scanning | The coverage view in security overview |
Priya asked the question every newcomer asks: if push protection works, why does secret scanning still matter? Seraphine gave three reasons. Push protection supports a subset of patterns, chosen for low false positives; secret scanning alerts on more. Push protection can be bypassed or exempted. And push protection cannot see secrets that were in history before it was turned on. The exam treats the two as layers, not alternatives.
Common mistakes
MistakeThinking secret scanning scans only new commits.
InsteadIt scans the full history when enabled, then every push, plus issues, pull requests, discussions and wikis.
MistakeConfusing push protection for users with repository push protection.
InsteadUser protection covers a person's pushes to any public repository; repository protection covers everyone pushing to that repository.
MistakeBelieving a bypass with used in tests creates no record.
InsteadEvery bypass creates an alert; only fix later leaves it open.
MistakeUsing an exemption to add review.
InsteadDelegated bypass adds review; an exemption removes blocking for a named actor.
MistakeRewriting history as the first response.
InsteadRevoke or rotate the secret first; history rewriting is optional.
Summary and key terms
- Secret Protection is 15 to 20 percent and covers detection, prevention, custom patterns and alert handling.
- Secret scanning covers full history and content such as issues, pull requests, discussions and wikis; one alert per secret value.
- Push protection blocks supported secrets; bypass reasons decide whether the resulting alert is open or closed.
- Delegated bypass requires reviewer approval; exemptions let named actors push without blocks.
- Custom patterns use Hyperscan syntax, are tested with a dry run and can have push protection turned on.
- Validity checks show active, inactive or unknown; revoked is the only closure that removes the risk.
- Push protection
- A Secret Protection feature that blocks pushes containing supported secrets.
- Push protection for users
- A personal setting, on by default, that blocks a user's secret pushes to any public repository.
- Delegated bypass
- A control that replaces self-bypass with bypass requests approved by designated reviewers.
- Exemption
- A named role, team or app whose pushes push protection does not block.
- Dry run
- A test of a custom pattern that shows sample matches without creating alerts.
- Validity check
- A check with the provider that reports a detected secret as active, inactive or unknown.
Practice problems
Work each problem on paper first, then reveal the answer to check.
Which bypass reason leaves the resulting alert open?
Show answer
I'll fix it later.
Which regular expression syntax do custom patterns use?
Show answer
Hyperscan.
What is the first remediation step for an active leaked secret?
Show answer
Revoke or rotate it at the source.
Lesson quiz · 5 questions
Score 60% or more to complete this lesson.
Create a free account to save your progress, take quizzes and earn a certificate.