This guide is for CTOs, heads of engineering and security leads of software companies whose repositories hold application, cloud and third-party credentials. For an outside review of code, dependencies and pipeline controls, see application security assurance.
In this guide
- Why is deleting the commit not enough?
- Where should secrets scanning run?
- How serious is this leak?
- What should the team do when a secret is found?
- When should you not rewrite history or add another scanner?
- Where AI fits
- What delivery record exists, and what does not
- Built-in platform scanning, an open-source scanner or a managed service: which fits?
- Limits of this guide
- Frequently asked questions
- Next step
Why is deleting the commit not enough?
A secret pushed to a shared repository has already been copied. Every clone, fork, pipeline cache and pull request view may hold it, so deleting the file or even rewriting history does not take the value back. Only revoking the credential at its issuer makes the leaked copy useless.
That is why GitHub's own guide on removing sensitive data says the first step for a password, token or credential is to revoke or rotate it, and notes that rewriting history breaks pull request views, risks old clones pushing the data back and cannot reach forks. History cleanup is housekeeping after containment, not containment itself.
Most leaks are ordinary: a test key in a configuration file, an environment file past the ignore list, a committed debug log. Scanning catches them early; the runbook makes the response the same whoever is on duty.
Where should secrets scanning run?
No single scan point catches everything. Each point trades early warning against coverage, and each needs an owner for its alerts.
| Scan point | What it catches | What it misses | Who owns the alert |
|---|---|---|---|
| Developer machine (editor or pre-commit hook) | A secret before it ever leaves the laptop | Anyone who skips or never installed the hook | The developer, with a team rule that hooks are installed |
| Push protection on the server | Known secret formats at push time, for every contributor | Custom formats without a pattern; bypasses chosen by the pusher | The repository owner, who reviews every bypass |
| Pull request check in CI | Secrets in the change under review, with the reviewer watching | Anything already in history before the check existed | The reviewer and the merge rule |
| Full-history and scheduled scan | Old secrets buried in history and all branches | Nothing new between runs | The security lead, as a dated report |
| Build artefact and container scan | Secrets baked into images, bundles and logs | Secrets that only exist at runtime | The platform or DevOps owner |
Start with push protection and a pull request check, because they cover every contributor without relying on local setup. Add a full-history scan once, before the first audit or customer review, and then on a schedule. GitHub documents that a push protection bypass creates an alert, an audit log entry and an email to owners, so a bypass becomes a reviewed decision, not a silent one. The OWASP Secrets Management Cheat Sheet recommends detection at the developer level and more than one detection tool, with results de-duplicated.
Scanning is only one control. Where secrets should live in the first place, and how pipelines can use short-lived credentials instead of stored keys, is covered in the guide to secrets management in cloud delivery; where the scan sits among the other pipeline checks is in the secure development lifecycle guide.
How serious is this leak?
Severity decides who is woken up and how fast the runbook moves. Two questions set it: who could have seen the secret, and what the secret can do.
-
Private repository, few contributors
- Read-only or test scope
- Low: revoke within the working day
- Write access, production data or cloud admin
- High: revoke now, check use the same day
-
Private repository, many contributors or a partner
- Read-only or test scope
- Medium: revoke today, review access
- Write access, production data or cloud admin
- High: revoke now, check use, review every account with access
-
Public repository, public fork or public log
- Read-only or test scope
- High: revoke now
- Write access, production data or cloud admin
- Critical: revoke now, check use, involve the incident lead and legal owner
A secret in a public repository should be treated as already copied and possibly used, because anyone can read and clone it. A private repository lowers the exposure but not the scope; a production database password in a private repository is still a high-severity leak.
What should the team do when a secret is found?
-
Contain: revoke the credential at its issuer
Disable the key, token or password in the cloud console, payment provider or API dashboard first. Check that the old value now fails; a rotation that leaves the old value valid is not containment.
-
Replace: issue a new credential and move every consumer
Put the new value in the secrets store, not back in code, and redeploy the services that read it. List the consumers from the inventory before revoking, if time allows, so the outage is short.
-
Check use: read the provider's logs for the leak window
Look for calls from unknown addresses, new keys or users created with the leaked credential, and data reads or changes since the first commit that held it. The audit logging design guide lists the events that make this check possible.
-
Decide on history cleanup
Rewrite history only when the value stays sensitive after revocation (a private key, personal data, a customer name) or a customer or auditor asks for it. Coordinate a time window, close open pull requests, rewrite with a dedicated tool and ask every contributor to re-clone.
-
Close with evidence and a fix
Record what leaked, when it was found, when it was revoked, what the logs showed and what changed: a new scan rule, a hook, an ignore entry or a move to short-lived credentials. Add the case to the scanner's allow or deny patterns if it was a false negative.
The order matters more than speed in any single step. Teams that start by rewriting history spend their first hour on Git while the key still works.
When should you not rewrite history or add another scanner?
A revoked test key in a private repository rarely justifies a force-push that breaks every clone, open branch and pull request; the record of the revocation is enough. Rewrite when the leaked content stays harmful after revocation.
A small team also gains more from push protection, one pull request check and a one-page runbook than from three overlapping scanners whose alerts nobody reads. Add tools when an alert has an owner and the false-positive rate is known; until then, more scanning only adds noise.
Scanning is also not a substitute for removing static secrets. When the same type of key leaks twice, the fix is usually short-lived credentials or a software supply chain rule for the build, not a stricter scanner.
Where AI fits
AI helps sort findings, never hold or judge secrets. A model can group scanner alerts, flag likely false positives such as sample values in documentation, draft the incident record from the timeline and suggest which services read a leaked key. An engineer confirms every finding against the real system, revocation stays a human action, and no AI tool receives the secret values. AI is integrated into every Netbase service, and Netbase works with the major commercial and open-source AI tools and models, chosen per project, under human control.
- In delivered work
Recommendation engine
A recommendation engine delivered for 4over4's online store suggests products from browsing history and previous purchases.
- In delivered work
Knowledge assistants and document AI
Retrieval-augmented knowledge assistants and document AI delivered for clients that are not named.
- Available capability
Scan triage assistant
An assistant that groups secret-scan alerts, marks likely false positives and drafts the incident record for an engineer to confirm; not yet tied to a published case.
What delivery record exists, and what does not
Netbase's published security practices include secure code review and version control, TLS in transit and AES at rest, role-based access control, MFA for admin dashboards, vulnerability scanning and penetration testing, and disaster recovery. NDAs, DPAs and SLAs are available on request, and contributors work under NDA. Security by design is part of how Netbase approaches delivery, and Netbase follows GDPR alignment for data privacy in Europe, HIPAA-aligned methodologies for healthcare data handling and CCPA compliance for clients with U.S. customer bases.
Netbase holds ISO 27001 certification and a SOC 2 Type II attestation for its own operations. Neither covers a client's repositories or product; a client's assurance comes from its own controls.
Netbase works as offshore development partner on a multi-tenant cloud ERP for a US client, delivered as SaaS to small and mid-sized businesses, the kind of product with many repositories and integration keys. Netbase has also delivered projects for clients in healthcare and other industries; these clients are not named. Delivery follows a six-step lifecycle with weekly reviews, where an open security item is tracked like any other. Netbase does not publish leak counts, incident timelines or outcomes for any client; this is a method, not a case study.
Built-in platform scanning, an open-source scanner or a managed service: which fits?
| Option | Strength | Risk | Choose it when |
|---|---|---|---|
| Built-in scanning of the code host | Push protection and alerts with no extra setup | Covers that host only; custom formats need patterns | Most code lives on one platform |
| Open-source scanner in hooks and CI | Runs anywhere, rules under your control, history scans | Someone must maintain rules and triage alerts | Several code hosts or self-hosted Git |
| Managed secrets-detection service | Wider detectors, dashboards, history and chat-tool coverage | Licence cost; still needs an owner for each alert | Many repositories and a security team to act on alerts |
Selection criteria: how many code hosts you use, who will triage alerts each week, and whether you need history reports for audits. Many teams combine the code host's push protection with an open-source scanner such as Gitleaks for history and self-hosted repositories. Teams planning a new product can design scanning and short-lived credentials in from the first release through DevOps and platform engineering or the SaaS product accelerator. Most Netbase projects are delivered on fixed-price contracts, and a written runbook makes that security scope easy to agree.
Limits of this guide
- It is not legal advice; whether a leak must be reported to customers or a regulator depends on the data involved and the contracts and laws that apply.
- It does not replace a full incident response plan; the NIST incident response recommendations cover preparation, roles and recovery beyond a single leaked credential.
Plan the next step with a Netbase consultant
Frequently asked questions
Revoke the key at the provider that issued it, then confirm the old value fails. Rewriting history comes later, if at all, because clones, forks and caches already hold the value and only revocation makes it useless.
Not always. If the credential is revoked and the content is harmless without it, the revocation record is usually enough. Rewrite when the value stays sensitive, such as a private key or personal data, or when a customer or auditor asks, and plan it with every contributor.
No. Scanning finds secrets after someone writes them into code. The lasting fix is fewer static secrets: short-lived credentials for pipelines, a secrets store for the rest and a runbook the team has practised.
Next step
If your team has found a secret in a repository, or wants scanning and a runbook in place before it does, send us a short description of your repositories and pipelines and we will reply with a proposal for scan placement, a response runbook and the gaps to close.
Related services and solutions
Application security assurance for web, SaaS and AI features Netbase provides application security testing for product and engineering leaders to find and fix vulnerabilities before release, including in AI features. We review code with AI-assisted triage, scan dependencies and test running applications, then rank findings and retest fixes. Netbase's own alignment with ISO 27001 and SOC 2 Type II covers Netbase's operations, never your application.
Learn More
AI-assisted DevOps and platform engineering for routine releases Netbase provides DevOps and platform engineering for SaaS and commerce teams to make releases routine instead of risky. We set up CI/CD pipelines, repeatable environments and observability on AWS, Google Cloud, DigitalOcean or Cloudflare, with AI assistance for tests, reviews and incident triage, so every change ships the same way and problems surface before customers notice.
Learn More
SaaS product accelerator: launch an AI-ready SaaS on proven Netbase modules A SaaS product accelerator is a set of reusable Netbase modules for accounts, billing, roles and integrations that helps founders and product teams launch subscription software faster, with room for in-product AI from the first release. Reusing these modules can shorten development time, and the approach is proven on Printcart, Netbase's own web-to-print SaaS.
Learn More
Work with Netbase remotely
Every Netbase engagement is delivered remotely, so clients in any country and any industry can work with us; Netbase has worked with clients in 80 countries. Contracts and invoices are issued by Netbase JSC, and payment is made by bank transfer to Netbase JSC's company account or PayPal Business. Talk to the CEO, Huy Nguyen (David), on WhatsApp or by email.
Discuss a project
Netbase JSC helps organizations design, build, modernize, and operate digital products and AI-enabled business systems.project@netbasejsc.com
+84 937 869 689
91 Nguyen Chi Thanh, Dong Da, Hanoi, Vietnam
Get in touch
Tell us what you want to build, modernize, or operate.