Join our Newsletter — 33% off our NHI Course
Home› Guides› Securing the source control platform itself: protect the…
Guide Software & AI Supply Chain

Securing the source control platform itself: protect the system every build trusts

PDF for newsletter subscribers · free to read online

← All guides
By NHI Mgmt Group, under the editorial direction of Lalit Choda Updated 13 November 2026 14 min read
On this page

Your source control platform decides what code reaches production, so anyone who can push to a protected branch, change a review rule or steal a token from it can ship their code through your own pipeline. The platform holds source code, infrastructure definitions, pipeline configuration and often secrets that should never have been committed. It is also crowded with non-human identities: personal access tokens, deploy keys, integration apps, OAuth apps, webhooks and CI tokens. This guide is for platform engineering, DevSecOps and security teams who run a hosted or self-managed source control platform. It covers the attack surface, organisation and repository admin roles, the tokens and integrations that act on the platform, branch and review protections, logging, hardening and decommissioning. It is vendor-neutral, so confirm exact setting names in your vendor's documentation. For repository-level practice, see the Git Repository Security Guide; for secrets in code, the Git Secret Scanning Guide.

Key takeaways

  • Treat the platform as tier 0 for software delivery. Organisation owners and the identities that can bypass branch protection can change what every pipeline builds.
  • Enforce SSO and phishing-resistant MFA for every human. Then remove long-lived personal tokens wherever a federated or app-based identity can do the job.
  • Inventory every machine identity. Tokens, deploy keys, apps, OAuth apps and webhooks each need an owner, the narrowest scope and an expiry.
  • Make branch protection something admins cannot quietly skip. Require review by someone other than the author on protected branches, apply rules to administrators too, and alert on every rule change.
  • Stream the platform audit log out on day one. Rule changes, token creation, repository visibility changes and bulk clones are what investigations need.

What makes up a source control platform's attack surface

The OWASP Top 10 CI/CD Security Risks puts Insufficient Flow Control Mechanisms (CICD-SEC-1), Inadequate Identity and Access Management (CICD-SEC-2), Insufficient Credential Hygiene (CICD-SEC-6), Insecure System Configuration (CICD-SEC-7), Ungoverned Usage of 3rd Party Services (CICD-SEC-8) and Insufficient Logging and Visibility (CICD-SEC-10) on the list, and all of them land on the source control platform. NIST SP 800-218 (SSDF 1.1) asks producers to protect all forms of code from unauthorised access and tampering. The table reflects a common architecture and is NHI Mgmt Group's view; your platform may name, merge or split these components differently.

ComponentWhat it holds or doesIf an attacker controls itPrimary control
Organisation or instance administrationMembers, SSO, policies, rules, integrations, visibility settingsDisables protections, adds members, makes private code publicFew owners, just-in-time elevation, alerting on policy change
Repositories and branchesSource, infrastructure code, pipeline definitionsPushes malicious code or pipeline changes (T1195.002)Branch protection, required review, signed commits where used
Personal access tokens and SSH keysAct as the user from scripts and laptopsClones every repository the user can read (T1213.003)Fine-grained, expiring tokens; SSO enforcement on tokens; key inventory
Deploy keys and machine usersPer-repository or shared automation accessWrite access that bypasses human controlsRead-only by default, owner and expiry, replace machine users with apps
Installed apps and OAuth appsThird-party and internal integrations with scoped permissionsSteals the app token or abuses broad scopes (T1528, T1199)Admin approval for installs, least scopes, periodic review
WebhooksPush events, sometimes with code content, to external URLsRedirects events to an attacker endpointWebhook secrets, TLS, alert on new or changed webhooks
CI integration and runnersTokens the pipeline uses to read code and publish resultsPoisoned pipeline execution (CICD-SEC-4) and secret theftShort-lived job tokens, protected branch conditions

Administrative roles and separation of duties

  • Organisation owners: keep to a small named group with just-in-time elevation where the platform or your PAM tool supports it. Owners should not use the same account for daily development.
  • Repository administrators: repository admins can often change branch protection for their repository. Grant admin to a platform or security team, and give development teams maintain or write roles.
  • Rules set above the repository: where the platform supports organisation-level rules or rulesets, define branch protection centrally so that a repository admin cannot weaken it for one repository.
  • Bypass lists: any role, team or app allowed to bypass protection is equivalent to an owner for that branch. Keep bypass lists empty by default and review them every quarter (our recommendation).
  • Outside collaborators and contractors: give them repository-level access through named accounts under your SSO where possible, with an end date, and never organisation membership by default.
  • Self-managed instances: separate instance administrators (server, storage, backups) from organisation owners, and administer servers only from privileged access workstations, in line with the NCSC secure system administration principles. See the Privileged Access Workstations Guide.

Authentication for people

  • SSO everywhere: enforce SSO through your identity provider so leavers lose access when their identity is disabled. The CISA and FBI Secure by Demand guide asks whether standards-based SSO is supported at no additional cost.
  • Phishing-resistant MFA: require it at the identity provider and, where the platform supports it, require MFA for platform-local accounts too. Keep one documented break-glass owner account. See the Break-Glass Account Guide.
  • Git over SSH and HTTPS: Git operations often bypass the web sign-in. Require tokens and SSH keys to be authorised for SSO, prefer SSH certificates or hardware-backed keys where supported, and expire keys. See the SSH Key Management Guide.
  • IP and device conditions: where offered, restrict platform access for the organisation to corporate networks or compliant devices, and apply the same to tokens.

Tokens, keys, apps and other machine identities

Most incidents involving source control start with a credential, not an exploit. The SLSA v1.2 Source track (status Approved, checked November 2026) lists stronger authentication, including phishing-resistant factors and forbidding bearer tokens such as personal access tokens, as a future consideration rather than a current requirement, so you have to set the bar yourself.

IdentityUse it forAvoidPattern
Personal access tokenA developer's own scripted workProduction automation; tokens with no expiry; organisation-wide write scopesFine-grained, single-repository where possible, maximum lifetime set by policy, admin approval for organisation access
Deploy keyOne server reading one repositoryWrite access; one key reused across repositoriesRead-only, one per repository and consumer, owner recorded
Machine user (bot account)Legacy automation onlyShared passwords; membership of owner groupsReplace with an app identity; until then, SSO, MFA where possible and a named owner
Installed appIntegrations and internal automationInstalling on all repositories; administration or member-management permissionsSelected repositories, least permissions, short-lived installation tokens
OAuth appThird-party tools acting as a userBroad scopes granted by any user without reviewOrganisation approval required, review scopes, revoke unused
CI job tokenThe running pipeline reading code and writing resultsDefault write permissions to the repositoryRead-only by default, write only in named jobs, federation to clouds instead of stored keys

Branch protection, review and integrity

SLSA v1.2 Source Level 2 requires that branch history be continuous, immutable and retained; Level 3 requires the platform to enforce the organisation's technical controls on named references; Level 4 requires that changes to protected branches be agreed by two or more trusted persons before submission. Use those levels as a maturity path.

  1. Protect default and release branches: block force pushes and deletion, require pull or merge requests, and require status checks to pass.
  2. Require independent review: at least one approval from someone other than the author, dismiss stale approvals when new commits are pushed, and require code owner review for sensitive paths such as pipeline definitions, infrastructure code and access configuration. See the Secure Code Review Guide.
  3. Include administrators: apply rules to owners and admins, and route emergency bypasses through break-glass with an alert.
  4. Protect tags: restrict who can create or move release tags, because many pipelines release on tag.
  5. Commit signing where it adds value: require signed commits on protected branches if your verifiers will check them, and manage signing keys like any other credential. See the Sigstore Guide.
  6. Pipeline definitions are code: changes to pipeline files and to who can trigger workflows from forks need the same review as application code. See the CI/CD Security Guide.

Logging and detection

Stream the platform audit log, and Git event logs where available, to your SIEM and to storage outside the platform admins' control. Check how long the platform keeps logs; Secure by Demand asks that cloud services keep security logs for at least six months at no extra charge. NIST SP 800-53 AU-9(2) covers storing audit records on a separate system.

EventWhy it mattersAlert
Branch protection or ruleset changed or deleted; bypass list changedOpens the path to unreviewed code (CICD-SEC-1)Always
Repository made public, transferred or archivedCode or secret exposure; disruptionAlways
New owner, new outside collaborator, SSO setting changedPersistence (T1098)Always
Token, deploy key or SSH key created; app installed or scopes increasedNew credential or integration (T1098.001)Outside a change, or with write or admin scopes
Bulk clone or archive download by one identityCode theft (T1213.003)Above a per-identity baseline
Token used from a new network or countryStolen token (T1528)For machine identities, any change of origin
Webhook created or its URL changedEvent and code redirectionAlways
Audit log streaming disabledBlind spot (T1685)Always, from a separate channel

Hardening an existing platform: a phased approach

  1. Turn on audit log streaming and the alerts above before changing access, so you can see breakage and misuse.
  2. Inventory: owners, admins, outside collaborators, tokens, keys, apps, OAuth apps, webhooks and bypass lists. Flag tokens without expiry and apps installed on all repositories.
  3. Enforce SSO and MFA for the organisation, with a grace period and a list of accounts that will fail.
  4. Apply branch rules in evaluate or audit mode where the platform offers it, review what would have been blocked for two weeks, then enforce, starting with a pilot group of repositories.
  5. Set token policy: maximum lifetime, approval for organisation access, then expire legacy tokens in waves with owner notice.
  6. Roll back safely: keep previous rules exported as code. If a release is blocked, grant a time-boxed bypass through break-glass and fix the rule, rather than deleting protection.

Decision guidance

DecisionOption A fits whenOption B fits when
Hosted service (A) or self-managed instance (B)You want the vendor to patch and run the platform; confirm SSO, audit log streaming and data residencyNetwork isolation or data residency rules need it; you can patch promptly and protect the server, storage and backups
Personal tokens (A) or app identities (B) for automationShort-lived, single-developer scriptsAnything shared, long-running or production; app identities survive staff departures
One review (A) or two-party review plus code owners (B)Low-risk repositories with strong CI checksRepositories that build production, infrastructure or pipeline code

Small teams should at least enforce SSO and MFA, protect default branches including for admins, set token expiry and stream the audit log. Large organisations add central rulesets, code owners, app-only automation and per-identity clone baselines.

Lifecycle of the platform

  • Buy: ask the Secure by Demand questions (SSO at no extra cost, MFA by default, logging in the base product, at least six months of log retention for cloud services, a vulnerability disclosure policy, an SBOM) and whether rules can be enforced for administrators.
  • Run: apply vendor security updates promptly for self-managed instances and subscribe to the vendor's security advisories page; review owners, bypass lists, tokens and apps every quarter; track the Source control platform health check metrics.
  • Back up: back up repositories, including metadata such as issues and rules, to storage the platform admins cannot delete, and test a restore. See the Backup Security and Immutable Backup Guide.
  • Migrate or retire: reissue every token, deploy key, app credential and webhook secret on the new platform rather than copying them, re-create rules before importing code, then revoke all credentials on the old platform and confirm data deletion. See the Source control platform migration playbook.

Detection and measurement

  1. Percentage of human members signing in through SSO with phishing-resistant MFA (target: 100%).
  2. Number of organisation owners (target: five or fewer, our suggestion) and number of identities on any bypass list.
  3. Percentage of production repositories with protected default branches that include administrators and require independent review.
  4. Personal access tokens without expiry or older than policy (target: zero).
  5. Apps and OAuth apps with write or admin scopes and no review in the last quarter (target: zero).
  6. Median time to revoke a leaked token after a secret scanning alert.

Framework mapping

Control areaNIST SP 800-53 Rev. 5NIST CSF 2.0ATT&CK threat addressed
Admin roles and bypass controlAC-5, AC-6, AC-6(5), CM-5PR.AA-05T1098 Account Manipulation
Human and token authenticationIA-5, AC-2PR.AA-01T1078 Valid Accounts, T1528 Steal Application Access Token
Branch protection and reviewCM-3, SR-3PR.PS-06T1195.002 Compromise Software Supply Chain
Third-party appsSA-9GV.SC-07T1199 Trusted Relationship
Code and secret protectionAC-6, SC-28PR.DS-01T1213.003 Code Repositories, T1552.001 Credentials In Files
Audit loggingAU-6, AU-9(2), AC-6(9)PR.PS-04T1685 Disable or Modify Tools
BackupsCP-9PR.DS-11T1485 Data Destruction

In ISO/IEC 27001:2022 Annex A, see 8.4 Access to source code, 8.32 Change management, 8.2 Privileged access rights and 8.15 Logging. In NIST SP 800-218, the main practice is PS.1, protecting all forms of code from unauthorised access and tampering.

Common failure patterns

  • Rules that exempt admins: branch protection is on, but owners and repository admins can push directly, so one stolen admin token skips review.
  • Tokens that never expire: a personal token created years ago for a build script still has organisation-wide write access after its owner has left.
  • Apps installed on everything: an integration needed for three repositories is installed on all of them with write permissions.
  • Machine users in owner groups: a bot account added as owner to fix a permissions error, with a shared password and no MFA.
  • Pipeline files outside review: application code needs code owner approval but pipeline definitions do not, so an attacker edits the pipeline instead.
  • Audit log kept only in the platform: default retention expires before an investigation starts.

Practitioner checklist

  • Classify organisation owners, rule bypass identities and the platform's admin plane as tier 0.
  • Enforce SSO with phishing-resistant MFA for all members and keep one tested break-glass owner.
  • Define branch protection centrally, include administrators, and keep bypass lists empty by default.
  • Require independent review and code owner approval for pipeline, infrastructure and access configuration files.
  • Set a maximum token lifetime, require approval for organisation access and expire legacy tokens.
  • Replace machine users and shared tokens with app identities scoped to selected repositories.
  • Use federation for CI access to clouds instead of stored keys.
  • Require admin approval for app and OAuth app installs and review them quarterly.
  • Stream the audit log to your SIEM and to immutable storage, and alert on rule, visibility and token changes.
  • Back up repositories and metadata outside the platform and test a restore.

Standards and references

Related NHI Mgmt Group resources: Git Repository Security Guide · Git Secret Scanning Guide · Source control platform health check · Software Supply Chain Security Guide · CI/CD Pipeline Identity Security Guide

PDF for subscribers

Take this guide with you

Every section, table and checklist in one PDF, with links to the sources and related guides. Subscribe to our weekly NHI & AI Identity Journal and we’ll email you a download link.

Free weekly newsletter

Subscribe to the NHI & AI Identity Journal

The latest on NHI and Agentic AI security – articles, research, breaches, news and events every week.

Bonus 33% off our NHI Course when you subscribe.

PDF Downloads for Newsletter Subscribers

Get the guide

Enter your details and we’ll email you a download link.

The full guide is free to read online. The PDF is a thank you for subscribing.

Fill in all fields marked * and tick both boxes to continue.