1. Resources
  2. Detection rules
  3. SSH Certificate Authority or SSH Key Added in GitLab

SSH Certificate Authority or SSH Key Added in GitLab detection rules

An attacker adds an SSH certificate authority they control to a GitLab group or instance, or an SSH key to a user account, and keeps Git access over SSH that does not depend on the account's password.

Platform
GitLab
Severity
High
Log source
GitLab audit events
Last updated
Rule formats
Sigmaand queries for: Splunk
What an attacker needs
The Owner role on a top-level group or administrator access for a certificate authority, or control of the user account for an SSH key.
Impact
Git access over SSH that does not depend on the account's password, in the name of other users when the attacker controls a trusted CA.
Response
Delete the unknown certificate authority, which ends the trust in every certificate it signed, and delete SSH keys nobody can account for.
Mitigation
Keep group Owners and administrators few, compare the trusted certificate authorities with the ones you operate, and review SSH keys regularly.
Audit events
create_ssh_certificatecreate_instance_ssh_certificateenforce_ssh_certificates_updatedadd_ssh_key

How the attack works

GitLab accepts two kinds of user credentials for Git over SSH. A user can add public SSH keys to their account, and one key authenticates that user to every project and group the account can access. An organization can also trust an SSH certificate authority (CA): on GitLab.com the Owner of a top-level group adds a CA certificate to the group, and on GitLab Self-Managed an administrator can add trusted CA keys in the Admin area or with the instance SSH certificates API, a beta feature from GitLab 19.5. Users then connect with certificates that the CA signed. A group certificate names the user by user name or primary email address and works for enterprise users in the projects of that top-level group, while an instance certificate carries the GitLab user name in its key ID and is followed by the standard access checks for that user.

For an attacker with the Owner role or administrator access, a CA of their own is the stronger of the two. Whoever holds the private key of a trusted CA can sign a certificate for a user without touching that user's account, password or keys. The plainer variant needs only the account itself: after taking it over, the attacker adds an SSH key to the profile. GitLab records a group CA certificate as create_ssh_certificate, an instance CA as create_instance_ssh_certificate, a change of the group setting that enforces SSH certificates as enforce_ssh_certificates_updated and a key added to a profile as add_ssh_key.

What an attacker needs

  • For a group CA, the Owner role on a top-level group on GitLab.com (Premium or Ultimate). For an instance CA, administrator access on a GitLab Self-Managed instance that runs gitlab-sshd.
  • For an SSH key, control of the user account it is added to.
  • Log collection: audit event streaming (Ultimate) for the top-level group or the instance, to an HTTP destination, received as JSON. The instance CA event has the Instance scope and needs the instance stream.

Impact

A CA under the attacker's control gives Git access over SSH in the name of the users the attacker puts in certificates, for as long as the CA stays trusted: enterprise users of the top-level group for a group CA, and any user name for an instance CA, each within what that user may access. An added SSH key gives the Git access of the account it belongs to. None of them depends on the password or the second factor of the account, and the expiration date of an SSH key is an optional setting.

Detection rules

GitLab SSH Certificate Authority Added to a Group or the Instance

Detects an SSH certificate being created for a group (create_ssh_certificate, GitLab 16.6 and later) and an instance SSH certificate authority being added (create_instance_ssh_certificate, GitLab 19.5 and later). On GitLab.com the Owner of a top-level group adds a CA certificate so that users can reach the projects of the group with certificates the CA signed. On GitLab Self-Managed an administrator can add trusted CA keys in the Admin area or with the API. Whoever holds the private key of a trusted CA can sign a certificate for a user without touching that user's account. The event type reference lists both events without their fields, so the rule matches on the event type. The instance event has the Instance scope and needs the instance audit event stream.

LevelHighStatusExperimentalLog sourceGitLab audit events
title: GitLab SSH Certificate Authority Added to a Group or the Instance
id: 18ed66a5-2309-4e4a-8edb-8de4b938a4d6
status: experimental
description: >-
  Detects an SSH certificate being created for a group
  (create_ssh_certificate, GitLab 16.6 and later) and an instance SSH
  certificate authority being added (create_instance_ssh_certificate,
  GitLab 19.5 and later). On GitLab.com the Owner of a top-level group
  adds a CA certificate so that users can reach the projects of the group
  with certificates the CA signed. On GitLab Self-Managed an administrator
  can add trusted CA keys in the Admin area or with the API. Whoever holds
  the private key of a trusted CA can sign a certificate for a user
  without touching that user's account. The event type reference lists
  both events without their fields, so the rule matches on the event
  type. The instance event has the Instance scope and needs the instance
  audit event stream.
references:
  - https://docs.gitlab.com/user/compliance/audit_event_types/
  - https://docs.gitlab.com/user/group/ssh_certificates/
  - https://docs.gitlab.com/administration/operations/gitlab_sshd_ssh_certificates/
  - https://attack.mitre.org/techniques/T1098/004/
author: Forestall
date: 2026-11-18
tags:
  - attack.persistence
  - attack.privilege-escalation
  - attack.t1098.004
logsource:
  product: gitlab
  service: audit
detection:
  selection:
    event_type:
      - create_ssh_certificate
      - create_instance_ssh_certificate
  condition: selection
falsepositives:
  - The planned rollout or rotation of your own certificate authority. A CA is added rarely, so confirm each event against a change request.
level: high

False positives

  • The planned rollout or rotation of your own certificate authority. A CA is added rarely, so confirm each event against a change request.

GitLab Enforce SSH Certificates Setting Changed

Detects a change of the group setting Enforce SSH Certificates (enforce_ssh_certificates_updated, GitLab 17.4 and later). With the setting on, GitLab restricts users from authenticating with SSH keys and access tokens, only certificates of CAs that Owners added to the group give repository access, and HTTPS access is disabled for regular users. Turning it off reopens SSH keys, access tokens and HTTPS for credentials an attacker may already hold. The event type reference does not document the field that holds the old and the new value, so the rule matches on the event type and fires in both directions.

LevelLowStatusExperimentalLog sourceGitLab audit events
title: GitLab Enforce SSH Certificates Setting Changed
id: 0acfed5a-1ef6-4f2a-ac33-04d61a1f693b
status: experimental
description: >-
  Detects a change of the group setting Enforce SSH Certificates
  (enforce_ssh_certificates_updated, GitLab 17.4 and later). With the
  setting on, GitLab restricts users from authenticating with SSH keys and
  access tokens, only certificates of CAs that Owners added to the group
  give repository access, and HTTPS access is disabled for regular users.
  Turning it off reopens SSH keys, access tokens and HTTPS for credentials
  an attacker may already hold. The event type reference does not document
  the field that holds the old and the new value, so the rule matches on
  the event type and fires in both directions.
references:
  - https://docs.gitlab.com/user/compliance/audit_event_types/
  - https://docs.gitlab.com/user/group/ssh_certificates/
  - https://attack.mitre.org/techniques/T1098/004/
author: Forestall
date: 2026-11-18
tags:
  - attack.persistence
  - attack.privilege-escalation
  - attack.t1098.004
logsource:
  product: gitlab
  service: audit
detection:
  selection:
    event_type: enforce_ssh_certificates_updated
  condition: selection
falsepositives:
  - A group Owner who turns enforcement on writes the same event. Read the details of the event, or the Permissions and group features section of the group settings, for the value now in force.
level: low

False positives

  • A group Owner who turns enforcement on writes the same event. Read the details of the event, or the Permissions and group features section of the group settings, for the value now in force.

GitLab SSH Key Added to a User Profile

Detects an SSH key being added to a user's profile (audit event type add_ssh_key, GitLab 18.2 and later). One SSH key authenticates the user to every project and group the account can access, and it does not depend on the password of the account. An attacker who has taken over an account adds a key to keep Git access after the password is reset. Developers add keys as part of normal work, and the event type reference lists the event without fields for the key, so this is a low-level signal. GitLab notes that the Group scope of the event is available for enterprise users only, so a top-level group stream can carry the event for its enterprise users at most.

LevelLowStatusExperimentalLog sourceGitLab audit events
title: GitLab SSH Key Added to a User Profile
id: c0aad7b3-c545-4a42-bbaa-675288720a26
status: experimental
description: >-
  Detects an SSH key being added to a user's profile (audit event type
  add_ssh_key, GitLab 18.2 and later). One SSH key authenticates the user
  to every project and group the account can access, and it does not
  depend on the password of the account. An attacker who has taken over an
  account adds a key to keep Git access after the password is reset.
  Developers add keys as part of normal work, and the event type reference
  lists the event without fields for the key, so this is a low-level
  signal. GitLab notes that the Group scope of the event is available for
  enterprise users only, so a top-level group stream can carry the event
  for its enterprise users at most.
references:
  - https://docs.gitlab.com/user/compliance/audit_event_types/
  - https://docs.gitlab.com/user/ssh/
  - https://attack.mitre.org/techniques/T1098/004/
author: Forestall
date: 2026-11-18
tags:
  - attack.persistence
  - attack.privilege-escalation
  - attack.t1098.004
logsource:
  product: gitlab
  service: audit
detection:
  selection:
    event_type: add_ssh_key
  condition: selection
falsepositives:
  - Developers who set up a new machine or rotate a key, which is the usual cause. Use the rule as context for other alerts on the same account, or keep it for administrators and group Owners.
level: low

False positives

  • Developers who set up a new machine or rotate a key, which is the usual cause. Use the rule as context for other alerts on the same account, or keep it for administrators and group Owners.

Detection logic

Patterns that need more than one event, a baseline or knowledge of your own environment. Each is a hypothesis to build and tune in your SIEM, not a ready rule.

Git operation authenticated by a certificate authority that is not on your list

Detection hypothesisJoins two logsNeeds your own lists

The event that adds a CA shows that trust was extended, but not what the CA went on to sign. From GitLab 19.6 a Git operation that was authenticated with an SSH certificate through gitlab-sshd names the CA that signed the certificate. A fingerprint that is not one of your own CAs shows a foreign CA in use.

  1. Keep a list of the SHA256 fingerprints of the certificate authorities your organization operates.
  2. Collect streamed repository_git_operation events whose details.custom_message carries ca_fingerprint. The field certificate_trust_source says whether the CA is trusted through a file, a group or the instance, and certificate_identity holds the key ID of the certificate.
  3. Alert when ca_fingerprint is not on your list, and name the user (author_id), the project (entity_path) and the address (ip_address).
  4. Look back for create_ssh_certificate or create_instance_ssh_certificate to find who added that CA.

Eventsrepository_git_operationcreate_ssh_certificatecreate_instance_ssh_certificate

LimitsThe fields exist only from GitLab 19.6 and only for certificates handled by gitlab-sshd, not for an SSH certificate through OpenSSH. The Git operation event is not saved to the database and reaches streaming destinations only. Several certificates can share one key ID, so the identity does not name one certificate.

New SSH key used for Git from an address the account has not used

Detection hypothesisSequence of eventsNeeds a baseline

After taking over an account, an attacker adds an SSH key and uses it from their own network. GitLab's event types report sign-ins and personal access tokens from unseen addresses, but not Git access with an SSH key. The streamed Git operation event says when a user SSH key authenticated it and carries the address, so a new key that is followed by Git access over SSH from an address the account has not used shows the key in use elsewhere.

  1. A key is added: add_ssh_key. Keep the account (author_id) and the time.
  2. In the following 24 hours, collect streamed repository_git_operation events with the same author_id whose details.custom_message has gl_key_type key, a user SSH key. Keep ip_address, entity_path and gl_key_id.
  3. Compare ip_address with the addresses of the account's repository_git_operation and authenticated_with_* events over the previous 30 days, and alert on a Git operation from an address it has not used.
  4. Raise the priority when the operations from the new address reach many projects, or when gl_key_id is a key the account had not used before.

Eventsadd_ssh_keyrepository_git_operationauthenticated_with_passwordauthenticated_with_two_factor

LimitsA developer who sets up a laptop on a new network adds a key and fetches from that network on the same day. The documented fields of add_ssh_key do not include the key ID, so the join is by account and time. An administrator who adds a key to another user's profile is not matched by the author. The Git operation event reaches streaming destinations only, and the 24 hours and 30 days are starting points.

Triage

  • For a new certificate authority, identify who added it (author_name, author_id, ip_address) and where (entity_path for a group, the instance for an instance CA), and compare the CA in the group or Admin area with the CAs you operate.
  • Delete an unknown CA first and investigate second. GitLab states that deleting a trusted instance CA revokes trust immediately and that the certificates it signed stop working.
  • For a change of the enforcement setting, read the value now in force in the group settings, because the event is written in both directions.
  • For add_ssh_key, identify the account and ask its owner whether the key is theirs. A key added shortly after an unusual sign-in or a password reset deserves a closer look.
  • Look for other changes by the same author around the same time, such as new Owners, access tokens or weakened protected branches.
  • Review Git operations that used a certificate. From GitLab 19.6 the streamed repository_git_operation event carries ca_fingerprint, certificate_identity and certificate_trust_source in its custom message.

Response

Once the attack is confirmed:

  1. Delete the unknown certificate authority from the group or the instance, which ends the trust in every certificate it signed.
  2. Delete the SSH keys that nobody can account for on the affected accounts. A password reset does not remove them.
  3. Secure the Owner, administrator or user account that made the change, including its password, second factor, sessions and access tokens.
  4. Treat the projects the credential could reach as copied, and rotate the secrets stored in those repositories.
  5. Review the pushes made over SSH in the period for unreviewed changes, and return the enforcement setting to its approved value.

Mitigation

  • Keep top-level group Owners and administrators few, on dedicated accounts with two-factor authentication, and compare the trusted certificate authorities with the CAs your organization operates.
  • Issue short-lived certificates, as GitLab recommends for instance certificates, which have no built-in revocation.
  • Keep the instance SSH certificates feature off where you do not use it, and watch the gitlab-sshd configuration file with your infrastructure monitoring, because GitLab writes no audit event for CA keys configured there.
  • Have users set an expiration date when they add an SSH key, and review the keys of privileged accounts regularly.
  • After an account takeover, delete unknown SSH keys and access tokens in addition to resetting the password.

Frequently asked questions

Can a single certificate signed by an unknown CA be revoked?

Not on its own. For instance certificates GitLab states that `gitlab-sshd` has no built-in certificate revocation mechanism and recommends short-lived certificates. Deleting the CA is the control that works: GitLab revokes trust immediately and the certificates the CA signed stop working. That is why an unknown CA should be deleted first and investigated second.

Whom can a certificate from a group CA act as?

A user certificate for a group CA names a GitLab user by user name or primary email address, and GitLab requires that user to be an enterprise user. The certificate can only be used to access the projects of the top-level group and its subgroups. An instance CA is wider: the key ID of the certificate is used as the GitLab user name, followed by the standard access checks for that user.

Is a CA that is configured in the gitlab-sshd configuration file audited?

No. GitLab states that it does not record changes to `trusted_user_ca_keys` in the configuration file as audit events and tells administrators to monitor that file with their infrastructure monitoring tools. The audit event `create_instance_ssh_certificate` covers CA keys added in the Admin area or with the API, on GitLab Premium and Ultimate.

Does add_ssh_key also report deploy keys?

No. GitLab describes `add_ssh_key` as an SSH key being added to a user's profile. A deploy key added to a project is its own event type, `deploy_key_added`, which the access token page of this library reads. The profile event exists from GitLab 18.2, and its Group scope is available for enterprise users only.

References

We respect your privacy

We use cookies to keep this site secure and working properly. With your permission, we also use optional cookies to understand usage and improve the experience. Cookie Policy

You can change your choice at any time.