Join our Newsletter — 33% off our NHI Course
Home› Guides› Malicious Commit Response Playbook: Contain, Remove and Rebuild…
Template Software & AI Supply Chain

Malicious Commit Response Playbook: Contain, Remove and Rebuild After a Backdoored Change

PDF for newsletter subscribers · free to read online

← All guides
By NHI Mgmt Group, edited by Lalit Choda Updated 19 November 2026 12 min read
On this page

When malicious code is found inside your own repository, the response has to answer three questions fast: whose identity made the change, where the code has already shipped and which credentials it could reach. This playbook is a fill-in template for that incident. It covers a backdoor slipped into a pull request, a rogue merge that bypassed review, a compromised maintainer or bot account pushing code, and the slow, trust-building insider pattern seen in the XZ Utils case, where a contributor built trust and maintainer access over time before malicious code appeared in release versions.

It is written for application security, incident response and platform engineering teams. It assumes Git hosting such as GitHub, a CI/CD pipeline and at least one artefact registry, and it treats every account that can push code, human or machine, as an identity to be investigated. If your concern is code leaving the organisation rather than bad code coming in, use the Source Code Leak Response Playbook instead.

Key takeaways

  • A malicious commit is an identity incident first. The commit author field is just text; establish which authenticated account pushed or merged the change before drawing conclusions.
  • Freeze before you fix. Preserve the repository, audit logs and build records before anyone force-pushes, rewrites history or deletes branches.
  • Scope by artefact, not by commit. Find every build, release, container image and package produced after the change landed, and where each was deployed.
  • Assume the code could read anything the build or runtime could read. Rotate CI secrets, deployment credentials and runtime keys that were in reach.
  • Revert with a new, reviewed commit and rebuild from a known good point. Do not rely on rewriting history to remove the evidence or the risk.
  • Insider cases need HR and legal involvement from the start, a verified evidence trail and a presumption that the person is not yet proven responsible.

How to use this template

Copy the template into your incident management system and fill in the bracketed fields before you need it: owners, contacts, repository list and tooling. Each phase lists actions, an owner role and the evidence to capture. Phases can overlap, but do not skip the preservation steps in Phase 2, because the most common way to lose a malicious commit investigation is to clean up before collecting evidence.

FieldFill in
Incident commander[Name and deputy]
Application security lead[Name]
Source control administrator[Name with organisation owner rights]
CI/CD and release owner[Name]
Secrets and NHI owner[Name]
Legal and HR contacts[Names, for insider scenarios]
Communications lead[Name, for customer or open source notification]
Severity criteria[For example: shipped to production or customers = critical; merged but not released = high; open pull request only = medium]

Scenarios this playbook covers

  • Malicious pull request merged. A contributor's change contained hidden behaviour that reviewers missed, often in test fixtures, build scripts, generated files or binary blobs.
  • Review bypass. Code reached a protected branch through an administrator override, a bypass permission, a direct push or a self-approved pull request.
  • Compromised account or token. A developer's session, a personal access token, a deploy key or a bot account was used to push code. The PHP project's 2021 incident, covered in our PHP Git Server Compromise 2021 analysis, is an example where commits were pushed under trusted names.
  • Long-game insider. A contributor builds trust over months or years and uses earned maintainer rights to insert a backdoor. The XZ Utils Backdoor 2024 (CVE-2024-3094) is the reference case: CISA's alert reported malicious code embedded in XZ Utils versions 5.6.0 and 5.6.1 and advised downgrading to an uncompromised version such as 5.4.6 Stable.
  • Disgruntled employee. A current or departing staff member adds a logic bomb, a hidden account or a data exfiltration path. Where the intent is disruption rather than a backdoor, coordinate with the Insider Sabotage Response Playbook.

In MITRE ATT&CK terms these map mainly to T1195.002 Compromise Software Supply Chain when the code ships to others, and T1195.001 Compromise Software Dependencies and Development Tools when the affected repository is a library or tool.

Phase 1: Triage and confirm

Owner: [Application security lead]. Target: [within 2 hours of report].

  1. Record how the suspicious change was found: code review, scanner, customer report, upstream notification or anomaly in production.
  2. Identify the commit hashes, pull request numbers, branches and tags involved. Capture the diff exactly as it stands.
  3. Have two reviewers independently confirm what the code does. Look for obfuscation, encoded payloads, network calls, changes to build scripts, test files that are executed during builds and binary files without a clear source.
  4. Assign a severity using the criteria in the template header, and open the incident.
  5. Restrict knowledge of the incident to the response team until the actor is understood, particularly if an insider is suspected.

Evidence: diff, commit metadata, pull request discussion and review history, reporter details, timeline of first observation.

Phase 2: Freeze and preserve

Owner: [Source control administrator]. Target: [within 4 hours].

  1. Pause releases from the affected repository. Disable automatic deployment pipelines that would ship the change further.
  2. Take a full mirror clone of the repository, including all branches, tags and refs, and store it read-only with a hash recorded.
  3. Export the organisation audit log for the relevant window. On GitHub, organisation owners can review the audit log under Settings, Logs, Audit log, filter with qualifiers such as actor:, action:, repo: and created:, and export as JSON or CSV. The log covers the last 180 days and shows only the past three months by default, so set a created: range explicitly.
  4. Preserve CI/CD run logs, build provenance records and artefact registry metadata for every build since the change landed. Many platforms expire these, so copy them now.
  5. Instruct everyone not to force-push, rewrite history, delete branches or remove the suspected account until evidence is secured.

Evidence: mirror clone hash, audit log exports, pipeline logs, registry metadata, list of who has been told.

Phase 3: Attribute the change to an identity

Owner: [Application security lead with Secrets and NHI owner]. Target: [within 24 hours].

Git author and committer fields are set by the client and can be anything. Attribution must come from the hosting platform's authenticated records and from signatures.

  1. From the audit log, identify which account pushed the commits and which account merged the pull request, including any use of bypass permissions or administrator overrides.
  2. Check whether the commits were signed and whether the signature verified against a key registered to that account. See our Git Commit and Tag Signing Guide for what verification proves.
  3. Determine the credential type used: web session, personal access token, SSH key, deploy key, GitHub App or CI bot token. Note its creation date, scopes and last use.
  4. Compare source IP addresses, locations and times against the account's normal pattern, and look for new tokens, keys or authorised applications created shortly before the push.
  5. Decide the working hypothesis: compromised credential, compromised device, abused bot or deliberate insider. Record the evidence for and against each.

For insider hypotheses, involve HR and legal before any interview or account action, follow your documented investigation procedure and keep findings factual. Do not name or accuse an individual in wider communications until the investigation concludes.

Evidence: push and merge actor records, signature status, credential details, access pattern analysis, hypothesis log.

Phase 4: Contain the identity and the code

Owner: [Source control administrator]. Target: [immediately after Phase 2 evidence is secured].

  1. Suspend or restrict the account that pushed or merged the change, and revoke its tokens, SSH keys and authorised applications. For a bot or app, revoke its credentials and pause the workflows that use it.
  2. Remove bypass permissions from anyone who does not strictly need them while the incident is open.
  3. Tighten branch protection on affected repositories. GitHub's ruleset rules include Require a pull request before merging with required approvals, Dismiss stale pull request approvals when new commits are pushed, Require review from Code Owners and Require approval of the most recent reviewable push, plus Require signed commits, Require status checks to pass before merging and Block force pushes.
  4. Yank, deprecate or quarantine affected package versions and container images in your registries, and block them from deployment.
  5. If affected builds reached production, isolate or roll back those services to the last known good release.

Evidence: list of revoked credentials with times, rule changes, artefacts quarantined, services rolled back.

Phase 5: Scope the blast radius

Owner: [CI/CD and release owner]. Target: [within 48 hours].

  1. List every commit the suspect identity authored, pushed, merged or approved across all repositories, not just the one where the problem was found. Long-game actors usually make many innocent changes first, and some earlier ones may prepare the ground.
  2. List every build, release, image and package produced from a commit at or after the malicious change, using build provenance to link artefacts to source commits. Our SLSA and Build Provenance Guide explains how to use provenance this way.
  3. Map where each artefact went: internal environments, customer downloads, public package registries, mobile app stores, partner integrations.
  4. Analyse what the malicious code could do at build time and at run time. Build-time code can read CI secrets and alter other artefacts; run-time code can read application secrets, cloud metadata and customer data.
  5. Search logs for indicators the code would produce: outbound connections, new files, unexpected processes or authentication from unknown sources.

Evidence: commit inventory, artefact lineage table, deployment map, capability analysis, indicator search results.

Phase 6: Rotate credentials in reach

Owner: [Secrets and NHI owner]. Target: [start within 24 hours, complete within 72 hours for critical].

Treat every non-human credential the malicious code could have read as exposed. That usually includes:

  • CI/CD secrets and variables available to workflows that ran the affected code.
  • Cloud deployment roles and federated identity trust used by those pipelines.
  • Package registry publishing tokens and code signing keys.
  • Runtime secrets, API keys and database credentials in environments where the code was deployed.
  • Tokens and keys belonging to the suspect account, plus any service accounts it created or administered.

Rotate in order of impact, publishing and signing credentials first, and confirm that old credentials are revoked rather than merely replaced. Check usage logs for each credential during the exposure window to see whether it was used from unexpected locations.

Evidence: credential list with rotation time, revocation confirmation and usage review outcome.

Phase 7: Remove, rebuild and recover

Owner: [CI/CD and release owner]. Target: [per severity].

  1. Remove the malicious code with a new, reviewed revert commit rather than rewriting history, so the record remains intact and downstream clones can follow.
  2. Review the suspect identity's earlier changes identified in Phase 5 and revert or re-review any that cannot be fully explained.
  3. Rebuild affected artefacts from the cleaned source on a clean build environment, using freshly rotated credentials, and generate new provenance.
  4. Publish fixed versions, and mark the affected versions clearly in registries and release notes.
  5. Restore normal release flow only after the incident commander signs off that scope, rotation and rebuild are complete.

Evidence: revert commit hashes, rebuild provenance, published versions, sign-off record.

Phase 8: Communicate

Owner: [Communications lead with legal]. Target: [per contractual and regulatory obligations].

  • Internal: engineering leadership, product owners of affected services, and the security operations team.
  • Customers and downstream users: affected versions, what the code could do, fixed versions, recommended actions and indicators to check.
  • Open source: if the project is public, publish a security advisory, request a CVE where appropriate and notify downstream distributors.
  • Regulators and partners: assess notification duties with legal, especially if personal data or regulated systems were in reach.

Keep communications factual and avoid naming individuals. For insider cases, legal should approve all wording.

Phase 9: Harden and review

Owner: [Incident commander]. Target: [within 2 weeks of closure].

  1. Run a blameless review covering how the change got in, why review missed it, how long it took to detect and what slowed the response.
  2. Enforce two-party review on protected branches, with approval of the most recent push by someone other than the pusher.
  3. Require signed commits and restrict bypass permissions to a small, monitored group.
  4. Give build scripts, CI configuration, test fixtures and binary files code owners and stricter review, since these are favoured hiding places.
  5. Generate and verify build provenance so artefacts can be traced to reviewed source quickly next time.
  6. Reduce CI secret exposure with short-lived, federated credentials scoped per workflow.
  7. Review maintainer onboarding and privilege growth for long-standing contributors, especially on critical libraries.

Common failure patterns

  • Trusting the author field. Teams attribute the change to the name in the commit, which an attacker can set to anyone.
  • Cleaning up first. History is rewritten or branches deleted before evidence is captured, destroying the trail.
  • Scoping by repository. Only the repository where the code was found is examined, while the same identity touched others.
  • Forgetting build time. Responders analyse runtime behaviour but miss that build-time code could read CI secrets.
  • Replacing without revoking. New credentials are issued but old ones stay valid.
  • Accusing too early. An individual is named before investigation shows whether their account was compromised.
  • Bypass permissions left in place. The override that let the change in remains available after the incident.

Practitioner checklist

  • Fill in owners, contacts and severity criteria in this template before an incident.
  • Confirm you can export the source control audit log and know its retention period.
  • Copy CI logs and build provenance to long-term storage so they survive platform expiry.
  • Require pull requests, code owner review and approval of the most recent push on protected branches.
  • Require signed commits and limit who holds bypass permissions.
  • Maintain an inventory of CI secrets, publishing tokens and signing keys per repository so rotation scope is known.
  • Rehearse this playbook once a year with a simulated malicious pull request.
  • Agree the HR and legal handover process for insider scenarios in advance.

Standards and references

Related NHI Mgmt Group resources: Source Code Leak Response Playbook · Insider Sabotage Response Playbook · Git Commit and Tag Signing Guide · SLSA and Build Provenance 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.

NHIMG Editorial Note
Researched and written by the NHI Mgmt Group editorial team using AI tools, under the editorial direction of Lalit Choda. Facts are drawn from the sources listed on this page and checked by our automated quality process. Last updated 19 November 2026. Spotted an error? Use our contact page.
NHI Mgmt Group, the independent authority on Non-Human Identity, IAM and Agentic AI security. nhimg.org

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 the PDF box to continue.