A number of years in the past, GitHub Safety launched an initiative to evaluate and enhance our total secrets and techniques hygiene. As a part of that effort, we piloted the Secret Scanning functionality that was beneath improvement on the time. That’s after we discovered greater than 20,000 secrets and techniques unfold throughout our 15,000+ repositories.
The quantity was considerably increased than we anticipated, nevertheless it rapidly turned clear that success would rely upon figuring out which alerts represented actual danger, assigning possession, and remediating them safely. 9 months later, we reached zero open alerts.
New secret scanning clients usually ask us: “How do you handle this internally? How did you really clear up your current secrets and techniques?”
Like many long-running software program corporations, GitHub’s strategy to secrets and techniques administration developed over time. GitHub was based in 2008, earlier than at the moment’s centralized vaults, automated secret scanning, and devoted secrets-management platforms had been frequent throughout the trade. As engineering practices matured and GitHub grew, we continued investing in stronger controls, higher tooling, and systematic danger discount for legacy patterns. This work displays our ongoing dedication to enhancing safety, decreasing publicity, and making certain our inside practices meet the identical excessive requirements we anticipate throughout the trade.
This weblog publish shares what labored for us throughout this effort, and highlights methods you possibly can apply to higher shield your individual secrets and techniques.
Reducing out the noise
The very first thing we found was that the alert depend was a bit deceptive—i.e., 20,000 alerts didn’t imply 20,000 equally dangerous issues.
After we dug into the information, we found that simply 5 repositories accounted for roughly 18,000 of these alerts, and each a type of secrets and techniques was inactive: check fixtures, deactivated credentials, and fake-but-valid-looking secrets and techniques used for testing. (We construct secret scanning, so naturally we’ve got repositories stuffed with legitimate-looking secrets and techniques in assessments.)
That left over 2,000 alerts that wanted consideration: potential reside credentials and hundreds of choices about danger, rotation, and remediation.
Secrets and techniques don’t simply reside in code
Secret remediation touched greater than supply code. We discovered secrets and techniques in assist tickets (clients often embrace tokens), bug bounty stories (researchers disclose what they discovered with full reproductions, together with API requests with tokens used), incident notes, and wiki pages.
We partnered with buyer assist, safety incident response, and our bug bounty program to develop shared playbooks. Throughout all these workflows, we had to make sure we weren’t creating new issues, like opening points or pushing commits containing the very secrets and techniques we had been making an attempt to remediate.
Our phased strategy
We weren’t going to shut 20,000 alerts by asking a number of safety engineers to grind by way of them one after the other. We handled it like every other operational backlog: cease new debt, then work down what already exists with a workflow that’s repeatable, measurable, and never depending on one individual’s institutional data.
Part 1: Allow in every single place, cease the buildup
Earlier than cleansing up current secrets and techniques, we needed to cease new ones from piling up.
We enabled secret scanning and push safety throughout all of our enterprises and organizations. Due to GitHub Superior Safety’s organization-level settings, this wasn’t a repository-by-repository slog throughout 15,000 repositories. We enforced the setting so particular person repositories and groups couldn’t quietly decide out.
Push safety blocked new secrets and techniques on the supply. That stored the backlog from rising sooner than we may burn it down.
Part 2: Perceive and triage
We broke down the 20,000+ alerts by repository, secret sort, and age so we may separate noise from work.
After we dug in, we found that simply 5 repositories accounted for roughly 18,000 of these alerts, and each a type of secrets and techniques was inactive: check fixtures, deactivated credentials, and fake-but-valid-looking secrets and techniques used for testing. (We construct secret scanning, so naturally we’ve got repositories stuffed with legitimate-looking secrets and techniques in assessments.)
For top-volume, low-risk alerts, we developed standards for bulk closure. If a secret was in a devoted check repository, had by no means been lively, and matched a recognized check sample, we may confidently mark it resolved. In a matter of days, we closed out roughly 18,000 alerts.
The laborious questions
We needed to make strategic selections about learn how to remediate secrets and techniques. When a secret lives in a problem, do you edit the physique (and doubtlessly take away revision historical past), or protect the audit path? When a secret is dedicated to a repository, do you rewrite git historical past? Anybody who’s tried rewriting git historical past at scale is aware of what occurs subsequent: force-pushes break open pull requests, invalidate commit SHAs, and customarily interrupt builders.
A standard query was: “Can we simply delete the repository if it’s not in use?” Our reply was typically no. A deleted repository takes its audit path with it. If a secret in that repository was ever leaked or the repository was ever compromised, you lose the forensic document you’d want throughout incident response. Rotate the key, archive the repository if acceptable, however preserve the historical past.
At any time when attainable, we rotate or revoke the uncovered secret first. The more durable query is whether or not the residual danger warrants rewriting git historical past, or whether or not a revoked secret in historical past can safely be left in place. These are the sorts of questions and selections current with every alert that product safety groups wrestle with.
Part 3: Validate what’s really reside
A credential sitting in a repository might need been rotated years in the past, or it would nonetheless unlock manufacturing programs. You possibly can’t prioritize with out understanding the distinction.
On the time, secret scanning didn’t have native validity checking, so we constructed our personal strategy. The objective was slim: decide whether or not a credential nonetheless labored and, when acceptable, acquire sufficient metadata to route the alert or notify the proper proprietor.
For instance, for a GitHub token, a consultant test may make a single authenticated request to a low-impact endpoint like GET /consumer:
curl -sS -w ‘n%{http_code}’
-H “Authorization: Bearer $TOKEN”
-H “Settle for: utility/vnd.github+json”
-H “X-GitHub-Api-Model: 2022-11-28″
https://api.github.com/consumer
)”
standing=”${response##*$’n’}”
physique=”${response%$’n’*}”
case “$standing” in
200)
login=”$(jq -r ‘.login // empty’ <<< “$physique”)”
echo “token seems lively for GitHub consumer: $login”
;;
401)
echo “token seems invalid or revoked”
;;
403|429)
echo “unable to find out validity; rate-limited or blocked”
;;
*)
echo “unable to find out validity: HTTP $standing”
;;
esac
Bear in mind, our objective was to reply the smallest helpful set of questions: does this credential nonetheless work, and who must find out about it? We handled ambiguous responses as inconclusive, and we averted follow-on requests to repositories, organizations, or different personal sources.
This required shut partnership with our privateness and authorized groups. Even a “read-only” validity test can have implications if you’re touching a credential you could not personal.
As we labored by way of this manually, our product crew constructed the answer natively, which made the remaining work a lot sooner. Validity checking is now constructed into GitHub secret scanning.
Part 4: Determine who owns what
That cross-functional work additionally uncovered an possession downside: even after we knew a credential was lively, we nonetheless had to determine who may rotate it.
We partnered with buyer assist, safety incident response, and our bug bounty program to develop shared playbooks for secrets and techniques reported outdoors of code. That included redacting secret values earlier than routing work to groups, figuring out whether or not a credential belonged to GitHub or a buyer, and notifying affected clients or researchers so they may rotate tokens beneath their management. Throughout all these workflows, we had to make sure we weren’t creating new issues, like opening points or pushing commits containing the very secrets and techniques we had been making an attempt to remediate.
For GitHub-issued credentials like private entry tokens, we labored with our product crew to floor secret metadata instantly within the alert: who created the token, when, and what scopes it had. That meant we didn’t want to make use of the token itself to determine who it belonged to.
For all the things else, possession was more durable, and this uncovered a deeper downside: not all repositories had clear house owners.
Our inside engineering requirements (the Engineering Fundamentals program) implement sturdy possession on companies, and we keep a mapping between companies and repositories, however not all repositories map cleanly to a service. The ache we skilled led to a broader repository possession initiative (utilizing GitHub’s Customized Properties), plus a parallel effort to make sure all secrets and techniques in our credential supervisor have sturdy house owners. You possibly can’t rotate a secret when you can’t discover the proprietor.
Part 5: Handbook triage for the lengthy tail
Even with validation and metadata, an extended tail of alerts required human judgment. For each: what does this grant entry to, has it been rotated, who owns the related system, and what’s the remediation path?
For each alert we dismissed, we ensured an correct disposition (e.g., revoked, utilized in check, false constructive) was recorded, together with a remark containing related context, similar to a hyperlink to a remediation subject or an accepted safety exception.
This section required shut collaboration throughout groups to determine system house owners, validate remediation standing, and assess residual danger the place automated indicators alone had been inadequate.
Part 6: Systematize and drive accountability
As patterns emerged, we made the work scalable:
We routed alerts into our inside vulnerability administration platform for centralized monitoring and reporting.
Totally different credentials want completely different remediation steps. We documented playbooks by secret sort so groups may self-serve.
We automated notifications, routing alerts to the proper groups primarily based on repository possession.
The ultimate piece was accountability. We tied secret remediation to GitHub’s Engineering Fundamentals program, making it a safety elementary that groups had been measured towards. We set clear expectations and gave groups visibility into standing. When secret hygiene is a part of how engineering well being is measured, it turns into a shared duty throughout the group.
9 months after we began, we hit inbox zero.
Classes realized
Don’t panic on the quantity. Our preliminary depend was 20,000+ alerts, however 90% weren’t legitimate. The uncooked depend is nearly by no means the true scope of labor.
Allow and implement in every single place, no exceptions. Partial rollouts create blind spots. We enabled and enforced secret scanning and push safety on the enterprise stage, with out permitting anybody to decide out.
Validate earlier than you escalate. Not each detected secret is reside. Validation helps you create a prioritized to-do listing.
Metadata saves hours. For GitHub credentials, secret metadata lower down the mandatory detective work. When you’re working with third-party suppliers, push them to floor related metadata, or construct your individual enrichment layer.
You possibly can’t remediate with out possession. Put money into sturdy possession infrastructure early.
Automate the workflow after detection. Detection will get you began, however the operational problem was routing alerts, monitoring house owners, and shutting the loop. Put money into the workflow layer.
Make it everybody’s downside. Safety groups can’t remediate hundreds of alerts alone. We tied secret hygiene to our Engineering Fundamentals program. When management watches the dashboards, groups discover time to make things better.
Doc your resolution framework. You’ll encounter secrets and techniques with out clear remediation paths. Doc the way you determine: When is rotation adequate? When do you rewrite historical past? When do you settle for residual danger?
What this implies for you
You don’t must reinvent most of what we constructed. A lot of our handbook workarounds, together with validity checking, possession identification, and bulk triage, at the moment are native options in secret scanning.
When you’re beginning at the moment:
Allow and implement secret scanning and push safety in every single place.
Triage the backlog by repository and secret sort; bulk-close what you possibly can show is noise.
Validate what’s reside earlier than you escalate.
Route alerts to house owners, and monitor remediation like every other engineering work.
Able to get began? Discover ways to allow secret scanning and push safety with GitHub Superior Safety.
Coming quickly: How we tackled repository possession at scale, and why sturdy possession of repositories and secrets and techniques is the inspiration all the things else is determined by.

