Signed commits in 30 minutes, and why your AI agent needs its own key
BlogIncident Response

Signed commits in 30 minutes, and why your AI agent needs its own key

Here is a fun fact to share at your next standup: Git will happily let you commit as anyone. Set user.name and user.email to your CTO’s, push, and GitHub or GitLab will show the commit with their name, their avatar and a link to their profile. Nobody checks.

Commit signing is the fix, and it takes about 30 minutes to set up. This post walks through what signing proves, a quick SSH setup, how to enforce it, and the new wrinkle that AI coding agents bring to all of this.

Why we care

When we investigate an incident that touches source code, one of the first questions is simple: who made this change? In an unsigned history, the author field is a claim anyone could have typed. We then fall back on audit logs, token records and laptop forensics. That works, but it is slow, and the logs are not always there.

Attackers like the same gap. A stolen token or a compromised CI runner can push a commit dressed up as a trusted maintainer or a familiar bot. In code review and in git log, it looks like a Tuesday.

What a signature actually tells you

A valid signature says one thing: whoever held this private key signed this commit, and the commit has not changed since. When the platform knows the key belongs to an account, the commit gets the Verified badge.

It does not tell you that the person meant to make the change, that anyone reviewed it, or that their laptop was clean. Signing sits next to branch protection, required reviews and short-lived tokens. It does not replace any of them.

The 30-minute setup

We like SSH signing. Git has supported it since version 2.34, GitHub and GitLab both verify it, and your developers already know how to manage SSH keys. Make a separate key for signing, so you can rotate it without touching the key you use to push.

# Create a dedicated signing key
ssh-keygen -t ed25519 -C "you@example.com" -f ~/.ssh/id_ed25519_signing

# Sign every commit and tag with it
git config --global gpg.format ssh
git config --global user.signingkey ~/.ssh/id_ed25519_signing.pub
git config --global commit.gpgsign true
git config --global tag.gpgsign true

Then tell the platform about the key. On GitHub, add it under SSH and GPG keys and set the key type to Signing Key. On GitLab, add it under SSH Keys with the usage type Signing, or Authentication & Signing.

Want extra credit? Use a hardware-backed key (ssh-keygen -t ed25519-sk). Every signature then needs a tap on your security key, so nothing signs in your name while you are at lunch. One gotcha from Git’s release notes: SSH signing is broken with OpenSSH 8.7, so use 8.8 or later.

If SSH is not your thing, GPG, X.509 (S/MIME) and Sigstore’s gitsign all work too. GPG adds expiry and a trust model in exchange for more key wrangling. X.509 suits teams that already run a PKI. gitsign skips long-lived keys and signs with short-lived certificates tied to your OIDC login.

Make it stick

Optional signing tends to stay optional. Here is how we would roll it out:

  1. GitHub: turn on “Require signed commits” in a ruleset or branch protection rule for your default and release branches. Then ask everyone to enable vigilant mode. GitHub will flag any unsigned commit that carries their name as Unverified, including ones someone else wrote pretending to be them.
  2. GitLab: turn on the “Reject unsigned commits” push rule (Premium and Ultimate). It skips commits made in the GitLab UI or through the API, so keep protected branches and required approvals in place too.
  3. Your pipeline: check every new commit against a list of keys you trust. More on that below.
  4. Bots and CI: give each automation its own identity and key, or let the platform sign the commits it makes. GitHub signs web commits with its web-flow key, and GitLab does the same where UI commit signing is on.
  5. Offboarding: remove a person’s signing key on their last day. On GitLab, delete the key rather than revoking it, unless it was compromised. Revoking marks every earlier commit signed with that key as Unverified.

The pipeline check is short. Keep an allowed signers file with one person and key per line:

alice@example.com namespaces="git" ssh-ed25519 AAAAC3Nza...

Then fail the job on anything unsigned or signed by a key you do not know:

git config gpg.ssh.allowedSignersFile "$ALLOWED_SIGNERS"
for c in $(git rev-list origin/main..HEAD); do
  git verify-commit "$c" >/dev/null 2>&1 || { echo "Unsigned or untrusted: $c"; exit 1; }
done

One detail matters here: load $ALLOWED_SIGNERS from a protected CI variable or from the target branch, never from the branch being checked. Otherwise a merge request can simply add its own key to the guest list.

Things that will trip you up

Merge buttons rewrite commits. GitHub signs the squash and merge commits it creates, but unsigned commits on the branch can still block a squash merge into a protected branch. GitLab drops signatures when you rebase a merge request from the UI, so rebase locally and push.

Old history stays unsigned. Enforcement starts the day you switch it on. Do not rewrite history to backfill signatures. Write down the cutover date instead, so the next investigator knows where verified history begins. And sign your release tags, since a tag can point at any commit.

Keys the platform does not know look like no signature at all. A commit signed with a key that is not on the developer’s account shows as Unverified. Check that everyone has registered their key before you turn on enforcement, or day one will be a long line of rejected pushes.

Your agent signs as you

AI coding agents now write and commit a lot of code. That changes what a Verified badge means.

Heads up: by default, the agent is you

Most coding agents run in your terminal with your Git config and your SSH agent. Unless you change that, the agent commits under your name and signs with your key. The result is a commit that carries your name and a valid signature, Verified on GitHub or GitLab, that you never saw, never approved and may not know exists.

From an investigator’s chair, that is the worst of both worlds. The signature says you made the change, and nothing in the commit says an agent did. A Co-Authored-By trailer does not help much: it is plain text in the commit message, and anyone can write it.

The fix is to treat the agent as a teammate with its own badge:

  • Give the agent its own Git identity and signing key, registered to a machine account, so its commits show as the agent’s.
  • Keep your key out of its reach. Run the agent without access to your SSH agent socket, or use a hardware-backed key, which needs your physical tap for every signature.
  • Scope the agent’s token to the repositories and branches it works on, and keep it off protected branches.
  • Have a human sign the merge. Anything an agent wrote reaches the main branch through a merge signed by a person or by the platform after review.

Your 30 minutes, in order

  1. Create a dedicated SSH signing key and turn on commit.gpgsign and tag.gpgsign.
  2. Register the key as a signing key on GitHub or GitLab.
  3. Turn on “Require signed commits” (GitHub) or “Reject unsigned commits” (GitLab) for your default and release branches.
  4. Add the git verify-commit check to your pipeline, with the allowed signers list loaded from outside the branch under test.
  5. Give every bot and AI agent its own identity and key.

Our incident response team investigates source code and CI/CD compromises, and our compromise assessments check whether your repositories can tell you who changed what. Get in touch before you need that answer in the middle of an incident.