1. Resources
  2. Detection rules
  3. Administrator Impersonated a User in GitLab

Administrator Impersonated a User in GitLab detection rules

A GitLab administrator account starts an impersonation session and acts as another user. Whoever holds the administrator account works under the other user's name, with that user's memberships and settings.

Platform
GitLab
Severity
Medium
Log source
GitLab audit events
Last updated
Rule formats
Sigmaand queries for: Splunk
What an attacker needs
Control of an administrator account on an instance where impersonation is enabled, which is the default.
Impact
The attacker acts under another user's name, and a credential added to that account during the session gives access that outlasts it.
Response
Block the administrator account until its owner confirms the session, and revoke tokens and SSH keys added to the impersonated account.
Mitigation
Disable impersonation where it is not needed, and keep administrator access to few dedicated accounts with two-factor authentication.
Audit event
user_impersonation
Threat groups
None listed in MITRE ATT&CK for this technique

How the attack works

On GitLab Self-Managed and GitLab Dedicated, an administrator can impersonate any other user, including other administrators. GitLab describes the feature as a way to see what the user sees and to take actions on behalf of the user. It is started from the user's page in the Admin area, and impersonation is enabled by default. The API has two related mechanisms: impersonation tokens, a kind of personal access token that only an administrator can create and that authenticates as a specific user, and the sudo parameter for administrator tokens with the sudo scope.

For an attacker who has taken over an administrator account, impersonation is a way to act under someone else's name. Changes made in the session appear as that user's work in merge requests, pipelines and settings, and a credential that is added to the user's account during the session keeps working after it ends. GitLab records the start and the end of an impersonation session as the audit event type user_impersonation, and states that the actions of an impersonated user are logged as audit events that include information about the impersonating administrator.

What an attacker needs

  • Control of an account with administrator access on a GitLab Self-Managed or GitLab Dedicated instance, with Admin Mode entered where the instance uses it.
  • Impersonation left enabled, which is the default.
  • Log collection: audit event streaming (Ultimate) for the instance or the top-level group, to an HTTP destination, received as JSON. The event has the User and Group scopes.

Impact

The attacker acts as the impersonated user inside the web interface, and whatever that user may do there is done in the user's name, for example approving a merge request or changing a project the user owns. Where that includes adding an access token or an SSH key to the account, the credential gives access that outlasts the session and no longer shows as impersonation. People who review activity later see the user's name first and have to read the audit events to find the administrator behind it.

Detection rules

GitLab Administrator Started or Stopped Impersonating a User

Detects the audit event type user_impersonation, which GitLab writes when an instance administrator starts or stops impersonating a user. During the session the administrator acts as that user and can take actions on the user's behalf. The event type reference gives the event the User and Group scopes and lists it without its fields, so the rule matches on the event type and fires at the start and at the end of a session. In the GitLab source the administrator is the author and the impersonated user is the target, and the same event is also written for groups of the impersonated user, so one session produces several events. That shape is not part of a documented schema: validate it on your version.

LevelMediumStatusExperimentalLog sourceGitLab audit events
title: GitLab Administrator Started or Stopped Impersonating a User
id: 205f0253-0537-4324-8991-1ddbe101d6c2
status: experimental
description: >-
  Detects the audit event type user_impersonation, which GitLab writes when
  an instance administrator starts or stops impersonating a user. During
  the session the administrator acts as that user and can take actions on
  the user's behalf. The event type reference gives the event the User and
  Group scopes and lists it without its fields, so the rule matches on the
  event type and fires at the start and at the end of a session. In the
  GitLab source the administrator is the author and the impersonated user
  is the target, and the same event is also written for groups of the
  impersonated user, so one session produces several events. That shape is
  not part of a documented schema: validate it on your version.
references:
  - https://docs.gitlab.com/user/compliance/audit_event_types/
  - https://docs.gitlab.com/administration/admin_area/
  - https://docs.gitlab.com/administration/compliance/audit_event_reports/
  - https://attack.mitre.org/techniques/T1548/005/
author: Forestall
date: 2026-11-18
tags:
  - attack.privilege-escalation
  - attack.t1548.005
logsource:
  product: gitlab
  service: audit
detection:
  selection:
    event_type: user_impersonation
  condition: selection
falsepositives:
  - Administrators who impersonate a user to reproduce a problem the user reported. Each session should match a support ticket, and the impersonated user should know about it.
level: medium

False positives

  • Administrators who impersonate a user to reproduce a problem the user reported. Each session should match a support ticket, and the impersonated user should know about it.

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.

Credentials or permissions changed by a user while an administrator impersonates them

Detection hypothesisSequence of eventsJoins two logs

An impersonation session that is used for support looks at pages and ends. A session in which the impersonated account receives a new access token or SSH key, adds members or changes pipeline settings is an administrator account building access under another name. Joining the session to the audit events of the impersonated user shows it.

  1. A session starts: the audit event type user_impersonation. Keep the administrator from author_id, the impersonated user from target_id and the time.
  2. The session ends: the next user_impersonation event with the same author_id and target_id. Without an end event, use a window of 60 minutes as a starting point.
  3. Collect the audit events between both times whose author_id is the impersonated user.
  4. Alert when they include personal_access_token_created, add_ssh_key, member_created, ci_variable_updated or other changes to credentials and access.

Eventsuser_impersonationpersonal_access_token_createdadd_ssh_keymember_createdci_variable_updated

LimitsThe user may be working in a session of their own at the same time, and those events look the same. GitLab says the events of an impersonated user carry information about the administrator but does not document the field, so confirm on one test session where it appears. Start and end are told apart only by the message text.

Triage

  • Identify the administrator (author_name, author_id, ip_address) and the impersonated user (target_details, target_id). In the GitLab source the administrator is the author and the impersonated user is the target of the event.
  • Read details.custom_message to tell the start of a session from its end. Expect several events for one session, because GitLab also writes the event for groups of the impersonated user.
  • Ask the administrator for the reason and the ticket, through a channel other than GitLab.
  • Check how the administrator signed in before the session, and whether the address and the time fit that person.
  • List the audit events of the impersonated user between the start and the end of the session, and look for new access tokens, SSH keys, members, approvals and changed CI/CD variables.

Response

Once the attack is confirmed:

  1. End the session and block the administrator account, or remove its administrator access, until its owner has confirmed or denied the impersonation.
  2. Reset the password and second factor of the administrator account and revoke its access tokens and sessions.
  3. Revoke every access token and delete every SSH key that was added to the impersonated account during the session, and tell the user what was done in their name.
  4. Revert the changes made in the session, such as merged or approved merge requests, changed variables and new members.
  5. Disable impersonation on the instance until the investigation is finished, if your operations allow it.

Mitigation

  • Disable impersonation where it is not needed. GitLab documents the setting impersonation_enabled, which is set to false in the instance configuration.
  • Keep administrator access to few dedicated accounts with two-factor authentication, and turn on Admin Mode so that administrative actions need a fresh authentication.
  • Require a ticket for every impersonation, so that a session without one can be treated as an incident.
  • Stream audit events to your SIEM and alert on every user_impersonation event.

Frequently asked questions

Does GitLab record what was done during an impersonation session?

Yes, to the extent that the actions are audited at all. GitLab states that when a user is impersonated, their actions are logged as audit events that include information about the impersonating administrator, and that extra audit events are recorded for the start and the end of the session. Actions that produce no audit event, such as reading a project, are not listed.

Can impersonation be turned off?

Yes. Impersonation is enabled by default, and GitLab documents how to disable it with the `impersonation_enabled` setting in the instance configuration, followed by a reconfigure or a restart. The instructions are given for Linux package and self-compiled installations, so this is a change on the server of a GitLab Self-Managed instance.

Does this rule see impersonation tokens and the sudo parameter of the API?

No. The rule reads `user_impersonation`, which GitLab describes as an instance administrator starting or stopping to impersonate a user. The event type reference lists no separate type for a request made with the `sudo` parameter or for the use of an impersonation token, so these two API mechanisms are outside this rule.

Has this been reported in a real attack?

No public incident report describes administrator impersonation in GitLab at the audit event level. The page is built on what GitLab documents about the feature. Impersonation by administrators is also a normal support tool, so the value of the alert depends on your rule that every session has a reason on record.

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.