GitLab secret push protection

GitLab secret push protection stops credentials at the moment they are pushed, before they enter history. This page explains how it works on a self-managed instance, what to configure, and how to roll it out across existing projects.

On this page

How GitLab secret push protection blocks credentials before they reach the repository

Blocking a credential at push time is cheaper than rotating it later, because a secret committed once stays in Git history even after the file is deleted. Every clone, fork, backup and CI cache that holds the commit must be treated as exposed, so the real cost is rotation, reviewing access logs for the exposed credential and deciding whether history must be rewritten. Push protection checks the content of a push before the commit is accepted and rejects it when it matches a known secret pattern, so the credential never enters the repository. On a self-managed instance, the need is highest when developers push directly to shared projects, when many teams share one instance, or when secret controls must be enforced by the server instead of depending on each developer's habits.

Confirm three things before you plan the rollout. First, the tier requirement: check the GitLab pricing page and the feature documentation for your version, because feature availability can change between releases. Second, the skip path. False positives happen, but skipping a block should be a governed decision: define which roles may bypass a block, require a recorded reason, and review skips on a schedule. Third, the developer experience. A blocked developer needs a clear message and a named route to the security team, or they will look for ways around the control.

Plan the rollout across existing projects separately from new ones. Push protection applies to incoming pushes, so it does not clean up secrets that already sit in history. Scan existing repositories with secret detection and rotate anything found before you enforce the control widely. Test on a non-production group first, and include a sample commit containing a fake key to prove that the block and the skip path both work as designed. On an offline or air-gapped instance, confirm how detection rules and related updates reach the server and whether that transfer needs an approved change, using the GitLab offline environments guidance.

Which push protection settings fit each team situation

New projects give you the most room to choose, because no credentials have been committed yet. Turning on blocking from the start means a push that contains a credential is rejected before it reaches the default branch, so developers learn the expected pattern before a secret ever enters history. The trade-off is that the first weeks often produce more rejected pushes while teams learn the rules and the detection patterns.

  • Set it at group level: Apply the setting to the group that will hold new projects so each new repository inherits it without a per-project step.
  • Block first: Start in blocking mode so the first leaked credential never reaches a shared branch.
  • Publish the bypass path: Tell developers who may skip a block and what justification they must give before they hit one.
  • Point to an approved secret store: Give developers a clear fix for a rejected push, such as moving the value into your secrets manager.
  • Test on a sandbox project: Push a harmless test string to confirm blocking, bypass and messages behave as you expect in your version.

Confirm the exact option names, inheritance behavior and bypass roles in the GitLab documentation for your version, and check the GitLab hardening recommendations before you write the setting into a standard.

Configuration options and when each fits

This table compares the main choices you will make when rolling out secret push protection: where it is switched on, whether it blocks or warns, who may approve an exception, and how revocation is handled. Read each row as a trade-off between developer friction and residual exposure, and confirm the exact setting names in the GitLab documentation for your version before you write policy.

ChoiceWhat it gives youCost in developer time or residual riskWhen it fits
Instance-wide enablementOne setting covers every project on the self-managed instance, so no project can quietly opt out.Teams with legacy repositories may hit blocks on day one, which needs a planned cleanup window.Regulated estates where the control must be provable across all code, and the platform team owns the rollout.
Project-level enablementOwners of selected projects turn protection on, letting you pilot before wider rollout.Unprotected projects remain a gap, and you need a process to find and close them.Phased rollouts, pilot groups and projects where a secret-heavy legacy history needs remediation first.
Blocking modePushes containing detected credentials are rejected before they reach the repository.Developers must remove the secret, rewrite the commit and retry, which adds friction near release deadlines.Repositories holding production credentials, infrastructure code or customer data where a leaked secret is costly to contain.
Warning modeDevelopers see a notice but the push still completes, so work is not interrupted.The secret is already in history and must be treated as exposed, so warnings alone leave residual risk.Early adoption, noisy legacy repositories or a short observation period to tune detection before enforcing.
Exception approval by project maintainersTeams can record a justified false positive quickly without waiting on central staff.A tired or pressured maintainer may approve a real secret, so exceptions need an audit trail.Low-sensitivity repositories with frequent test fixtures or sample keys that look like credentials.
Exception approval by a security roleA separate reviewer confirms each false positive, which strengthens segregation of duties.Each exception waits on a reviewer, which slows pushes and creates a queue to staff.Regulated repositories where an assessor will ask who accepted a detected credential and why.
Automatic revocation where supportedFor some supported secret types, the issuing service can be asked to revoke a leaked credential automatically.Revocation can break running services that use the key, so you need owners ready to rotate.Partner-issued tokens with documented revocation support. Confirm the supported types and any prerequisites in the docs.
Manual rotation without automatic revocationDetected secrets are handled through your own incident and rotation process.Exposure lasts until a person acts, so response time depends on on-call coverage and runbooks.Internal secrets, custom credentials or any type the platform cannot revoke automatically.

Setting up push protection on a self-managed instance

This sequence moves push protection from a documented feature to a tested control on your instance. Each step leaves a written record, a pilot result or an audit trail that shows the control works before it reaches every group.

  1. Confirm tier, version and upgrade position

    The platform owner confirms the instance's installed version against the maintenance policy and the required upgrade stops, then checks on the pricing page which tier includes the secret detection features your version documents for push protection. Record the version, tier and any licensing limits in the change record. Confirm the exact settings path for your version in the GitLab documentation before the pilot, because menu locations and configuration keys change between releases. The step is done when the change record names the version, the tier and the documentation version you followed.

  2. Enable push protection on a pilot group

    Choose one group with a small number of active projects and an owner who will report problems quickly. An administrator turns on push protection for that group, or for selected projects, using the method your version documents. Confirm that the setting is visible in the group or project configuration and that inherited settings are as expected. The step is done when the owner can see the setting enabled and the administrator has recorded who made the change and when.

  3. Test with a known fake credential

    Create a test project in the pilot group and commit a fake credential that matches a token format GitLab documents for detection. Use a value that cannot authenticate anywhere, and never a live key. Push the commit from a developer workstation and confirm that GitLab rejects the push with a message naming the detected secret type. Then check the remote branch head to confirm the object did not land. The step is done when the rejection, the unchanged branch and the test record are all saved with the pilot results.

  4. Configure the exception process

    Decide who may bypass a block, how a false positive is justified, and who reviews each bypass. Write these rules into a short runbook that names the approving roles. Then test the process on the pilot: trigger a block on a known false positive pattern, follow the runbook to bypass it, and confirm the bypass requires the justification you defined. The step is done when a second person has reviewed the test bypass and the runbook lists the roles, the justification fields and the review steps.

  5. Enable push protection on remaining groups

    Roll out to the remaining groups in waves, starting with groups that have the fewest CI-driven pushes from automation accounts. Notify each group owner before their wave and tell them where the exception runbook lives. Watch for blocked pushes from bots, mirrors and pipelines that write back to repositories, since those often need an agreed exception path. The step is done for each wave when the group owners have confirmed that their pushes work or that their exceptions are in the runbook.

  6. Verify with audit logs and existing projects

    Review the audit events your version records for push protection blocks and bypasses, and confirm they match the pilot tests and rollout waves. Check that these events reach your log pipeline or SIEM if your policy requires it. Push protection only inspects new pushes, so also schedule a secret detection scan of existing projects and handle any findings through rotation and history cleanup. The step is done when audit events for the test cases appear in your log store and the scan of existing projects has an owner and a ticket for each finding.

Rolling out push protection across existing projects

Push protection only inspects new pushes. Every credential already sitting in a repository's history stays there, and a blocked future commit does nothing about it. Before you enable enforcement broadly, run secret detection across existing projects to build an inventory of what is already exposed, including values that were removed in later commits but still live in history. Treat each finding as a potential compromise: confirm whether the value is still valid, identify the owner, and rotate it at the issuing service before you spend time on history rewriting. Rewriting history does not invalidate a leaked key, and it disrupts every clone and fork, so decide case by case whether a rewrite is worth the cost. Confirm with GitLab which detection scanners and rule sets your tier includes, since the scope of what you can inventory depends on the edition and deployment you run.

Sequence the rollout by project criticality rather than by project count. Start with repositories that deploy to production, hold infrastructure code, or belong to teams that already handle shared service accounts, because a single leaked credential there carries the widest blast radius. Pilot enforcement on one or two of these projects, record which findings developers push back on, and tune exceptions before expanding. Archived projects and low-risk sandboxes can follow later. Decide who is allowed to skip push protection for a false positive and require a written reason for each skip, so the audit trail shows why a blocked value was accepted. Confirm with your GitLab administrators how project-level and group-level settings interact on your instance before you change them in bulk.

Repositories that many developers push to need the most planning, because a single rule change affects a large number of people at once and false positives become daily friction. Announce the change with a clear explanation of what is blocked and how to request a skip, and assign a named owner to review skip requests and tuning issues during the first weeks. Watch for patterns such as placeholder values in test fixtures or example configuration, which are good candidates for documented exceptions rather than repeated overrides. Plan for the operational load in advance, since the team triaging findings and rotating credentials is usually the constraint, not the GitLab setting itself. Ask your implementation partner to estimate that effort against your actual repository count and secret volume before committing to a date.

Security and operational risks of push protection

Push protection stops new secrets at the door, but it does not clean history, cover every credential type, or protect the runners and pipelines that handle secrets after a push. Each card names one gap and the control to apply before relying on it.

Bypass through exceptions

Developers can skip push protection for a flagged commit when they judge it a false positive. Any project that allows skips without review turns the control into a suggestion. Check which roles can bypass, whether bypasses are logged, and whether a second person must confirm the exception before the push completes. Review the bypass log on a schedule, not only after an incident.

Secrets already in history

Push protection only inspects new commits. A credential committed before rollout, or pushed before a project was covered, remains readable in branch and tag history, forks and clones. Treat each finding as a compromised credential: rotate or revoke it, then decide whether history rewriting is worth the disruption to collaborators. Confirm with your team that rotation, not deletion, is the step that closes the exposure.

Unsupported secret types

Detection covers the patterns GitLab recognizes, and custom internal tokens or less common provider formats may pass unflagged. Automatic revocation also applies only to some secret types. Inventory the credential formats your organization issues, test a sample of each against a non-production push, and add custom detection rules where a gap exists. Ask GitLab which types are covered in your version before assuming coverage.

Runner and pipeline credentials

Push protection checks what developers commit, not what happens after a push. Variables defined in CI/CD settings, runner tokens, deploy keys and cloud credentials used during jobs sit outside its scope. A pipeline can still print a secret to job logs or write it into an artifact. Pair push protection with secret detection in pipelines, masked and protected variables, and runner isolation for jobs that handle production credentials.

Alert fatigue

If every push produces noisy findings, teams start skipping reviews or ignoring alerts, and real exposures get lost in the queue. Tune rules on a sample project first, assign an owner for triage, and set a target for how quickly findings are resolved. Track the ratio of false positives to confirmed findings per project, because a rising ratio signals that the rules or the exception process need work.

Questions teams ask before rolling out push protection

What drives the cost of rolling out secret push protection?

The cost is mostly labor, and it scales with how many projects you have, how much history those projects carry, how many exceptions your teams raise and who has to review them. Cost has two parts: the one-time work of enabling protection, triaging the existing findings and writing the exception process, and the recurring work of reviewing new exceptions and rotating any credential that was exposed. Ask any partner for a quote that breaks out these items separately, names who performs each one, and states which assumptions about project count and history size it depends on. No figure for these inputs is given here, so confirm them against your own GitLab inventory before comparing options.

Can our own team roll out push protection without a partner?

Yes, if you have an administrator who can change instance or group settings, someone who can work through findings with development teams, and time to pilot the change before enforcing it broadly. Teams that already run self-managed GitLab and maintain their own CI/CD usually have the access and skills needed. A partner is most useful when the rollout spans many groups, when the instance is air-gapped or heavily customized, or when your staff are already committed to other platform work. Check which of these apply to you before deciding.

What do we need to provide before the work starts?

You need administrator access to the GitLab instance and the groups in scope, a named secrets owner who makes decisions about exceptions and revocations, and a pilot group of projects with engineers willing to test the change. You also need a list of the secret types your teams use and the systems behind them, so revocation steps can be agreed in advance. Access to your backup and change-approval process matters too, because policy and settings changes should be recorded. Agree these inputs in the written scope so nothing blocks the pilot.

What makes the timeline longer or shorter?

The biggest time drivers are the number of groups and projects, how much existing history contains credentials that need triage, and how quickly exception requests get a decision. Automatic revocation for some secret types depends on coordination with the owners of those services, which can take longer than the GitLab configuration itself. A small pilot before broad enforcement adds time up front but usually reduces rework. Ask for a timeline that lists these dependencies separately, rather than a single number with no assumptions attached.

How do we stop false positives from slowing developers down?

Define who may approve an exception, what evidence they need (for example, a documented test value or a placeholder that is not a live credential), and how long an exception stays valid. Review exception volume during the pilot, because a high rate usually points to detection rules that need tuning or to test fixtures that teams should move out of committed files. Keep the approval path short enough that engineers do not route around it, and log every exception so the decision is traceable later.

Does push protection cover secrets already in our repositories?

Push protection checks new pushes, so it does not by itself remove credentials that were committed before it was enabled. You need a separate scan of existing history, a triage process for the findings, and rotation of any live credential that was exposed. Rotation is the step that actually removes risk, because removing a value from a later commit does not make it safe. Plan this cleanup as its own workstream, and confirm with your security team how they want exposed credentials recorded.

Do we need Ultimate or a higher GitLab tier for this?

Confirm the current feature tier for secret push protection directly in GitLab's documentation and pricing pages before you buy, because tier placement can change between releases. The pricing page lists application security testing under Ultimate, while the sibling guidance on secret detection in Free vs Ultimate covers what is available without Ultimate. Your licensing cost will depend on which tier you need and how many users you have, so ask any partner to show the tier assumption in the quote.

How DeployOpen scopes and delivers push protection

DeployOpen agrees the scope in writing before any configuration changes are made to your GitLab instance. For secret push protection, that scope names which groups and projects are covered, which push rules are enabled at the instance, group and project level, how exceptions for false positives will be requested and approved, and which secret types are in scope for automatic revocation. It also records what the client provides: administrator access to the self-managed instance, a list of repositories with their owners, a test project for validation, and a named contact who can approve policy changes. Most engagements are fixed-scope, so deliverables and timelines are set in that document. Ask any partner, including DeployOpen, to show how each push rule and revocation setting maps to a deliverable, and to state which items are excluded.

The work itself happens on your instance, inside your network, using your administrators' accounts and your change process. DeployOpen configures the settings, tests them against a pilot group using deliberately fake credentials, and documents the rollout in waves so that teams with the largest repository footprint are not all switched on at once. The rollout plan should name a rollback path for each wave, a communication owner for developers who will be blocked, and a review point after the first wave to tune exceptions. Expect the recurring part of the effort to be exception handling and periodic review of blocked pushes, not the initial setup. Confirm with your own security team who owns that queue after handover.

DeployOpen prepares the controls, configuration records and test evidence that your internal or external assessors can review, including the settings export, pilot results and change records for each rollout wave. DeployOpen does not issue audit reports, attestations or certifications. Independent auditors and certification bodies make those determinations, so ask your assessor early which evidence format they expect. Ongoing tuning, version alignment with GitLab upgrades and periodic review of exceptions can be covered by a retainer rather than a one-time engagement. Ask for the retainer's included activities and response expectations in writing, and confirm how the retainer interacts with your GitLab upgrade schedule.

Talk to our team.

Tell us what you're working on, whether it's a deployment, an audit, a security test or a cyber range. You'll speak with an engineer who can help you scope it.

  • 30-minute call: free, with no obligation.
  • NDA on request: we can sign before you share details.
  • Clear next steps: a scope and plan after the call.