How the attack works
GitLab can act as an OAuth 2.0 identity provider. An OAuth application is registered with a name, a redirect URI and a set of scopes, and GitLab gives it a client ID and a secret. There are three kinds, which differ only by permission level: a user-owned application that a user creates in their profile, a group-owned application, and an instance-wide application that an administrator creates on GitLab Self-Managed. When a user authorizes an application, GitLab issues it an access token that acts for that user. The scopes decide how far the token reaches. GitLab describes the api scope as complete read and write access to the API, including all groups and projects, the container registry, the dependency proxy and the package registry.
An application is therefore a way to hold access without a password. An attacker can register an application and lead a user to authorize it, or use a stolen session to authorize an application of their own. Access tokens expire after two hours by default, but GitLab notes that the refresh token can be used even after the access token itself expires. An attacker who can edit an existing application can also change where it sends users after authorization. GitLab records these steps as oauth_application_created and oauth_application_updated, as user_authorized_oauth_application when a user authorizes an application, and from GitLab 19.6 as oauth_consent_grant_created and oauth_consent_grant_amended for applications that declare granular scopes.
What an attacker needs
- An account on the instance to register a user-owned application, access to the application settings of a group for a group-owned one, or administrator access for an instance-wide application.
- A user who authorizes the application, or a session of that user in the attacker's hands. An instance-wide application that an administrator marked as trusted skips the user authorization step.
- Log collection: audit event streaming (Ultimate) to an HTTP destination, received as JSON. The application events have the User and Group scopes and the authorization events the User scope, so read them from the instance stream.
Impact
The application holds tokens that act as the user within the scopes that were granted. With api that is every group and project the user can reach, with read_repository or write_repository the code of private projects, and for an administrator the sudo and admin_mode scopes extend to actions as any user or as an administrator. The access does not depend on the user's password, and it continues through refresh tokens until the authorization is revoked or the application is deleted.
Detection rules
GitLab OAuth Application Created or Updated
Detects an OAuth application being created (audit event type oauth_application_created, GitLab 18.2 and later) or updated (oauth_application_updated, GitLab 19.0 and later). An application receives tokens that act for every user who authorizes it, within the scopes it asks for, and an update can change its redirect URI or its scopes. Both event types have the User and Group scopes, which match user-owned and group-owned applications. The event type reference lists the events without their fields, so the rule matches on the event type. Read the application from the target fields and open it to see its redirect URI and scopes.
title: GitLab OAuth Application Created or Updated
id: 1f07999d-c229-46ee-832a-33787f6916ae
status: experimental
description: >-
Detects an OAuth application being created (audit event type
oauth_application_created, GitLab 18.2 and later) or updated
(oauth_application_updated, GitLab 19.0 and later). An application
receives tokens that act for every user who authorizes it, within the
scopes it asks for, and an update can change its redirect URI or its
scopes. Both event types have the User and Group scopes, which match
user-owned and group-owned applications. The event type reference
lists the events without their fields, so the rule matches on the
event type. Read the application from the target fields and open it
to see its redirect URI and scopes.
references:
- https://docs.gitlab.com/user/compliance/audit_event_types/
- https://docs.gitlab.com/integration/oauth_provider/
- https://attack.mitre.org/techniques/T1671/
author: Forestall
date: 2026-11-18
tags:
- attack.persistence
- attack.credential-access
- attack.t1671
- attack.t1528
logsource:
product: gitlab
service: audit
detection:
selection:
event_type:
- oauth_application_created
- oauth_application_updated
condition: selection
falsepositives:
- Developers and platform teams that register an application for a tool with sign-in through GitLab. Confirm the owner and the redirect URI, and keep a list of the approved applications.
- A renewed secret or an edited name of a known application. Check what changed before closing the alert.
level: medium
False positives
- Developers and platform teams that register an application for a tool with sign-in through GitLab. Confirm the owner and the redirect URI, and keep a list of the approved applications.
- A renewed secret or an edited name of a known application. Check what changed before closing the alert.
GitLab User Authorized an OAuth Application
Detects a user authorizing an OAuth application: the audit event type user_authorized_oauth_application (GitLab 17.9 and later), and for applications that declare granular scopes oauth_consent_grant_created and oauth_consent_grant_amended (GitLab 19.6 and later). After the authorization the application holds tokens that act for the user within the granted scopes. Users authorize known tools every day and the event type reference lists these events without their fields, so this is a low-level signal that matches on the event type. Its value is the list of applications it lets you build, and the first authorization of an application you do not know.
title: GitLab User Authorized an OAuth Application
id: bd8261a6-b8b2-46d5-a930-0fe9affd25b6
status: experimental
description: >-
Detects a user authorizing an OAuth application: the audit event type
user_authorized_oauth_application (GitLab 17.9 and later), and for
applications that declare granular scopes oauth_consent_grant_created
and oauth_consent_grant_amended (GitLab 19.6 and later). After the
authorization the application holds tokens that act for the user
within the granted scopes. Users authorize known tools every day and
the event type reference lists these events without their fields, so
this is a low-level signal that matches on the event type. Its value
is the list of applications it lets you build, and the first
authorization of an application you do not know.
references:
- https://docs.gitlab.com/user/compliance/audit_event_types/
- https://docs.gitlab.com/integration/oauth_provider/
- https://attack.mitre.org/techniques/T1528/
author: Forestall
date: 2026-11-18
tags:
- attack.credential-access
- attack.t1528
logsource:
product: gitlab
service: audit
detection:
selection:
event_type:
- user_authorized_oauth_application
- oauth_consent_grant_created
- oauth_consent_grant_amended
condition: selection
falsepositives:
- Authorizations of the GitLab CLI, the IDE extensions and the tools the organization connected to GitLab. Exclude an application once you have confirmed which field of the event names it on your version.
- Users who sign in to an internal tool for the first time. Expect a burst when a new tool is rolled out.
level: low
False positives
- Authorizations of the GitLab CLI, the IDE extensions and the tools the organization connected to GitLab. Exclude an application once you have confirmed which field of the event names it on your version.
- Users who sign in to an internal tool for the first time. Expect a burst when a new tool is rolled out.
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.
Authorization of an application that nobody in the organization authorized before
Most authorizations go to a small set of applications: the GitLab-provided ones and the tools the organization has connected. An authorization of an application that is not in that set, above all with a wide scope, is the moment an unknown party receives tokens for one of your users.
- Collect
user_authorized_oauth_applicationevents, and from GitLab 19.6oauth_consent_grant_created, over a learning period, for a start 30 days. - Build the list of applications from the target fields of the events (
target_type,target_id,target_details). - Alert when an event names an application that is not on the list, and read the user from
entity_pathand the address fromip_address. - Look for
oauth_application_createdshortly before the authorization. A new application that another user authorizes within hours fits a prepared request for consent.
Eventsuser_authorized_oauth_applicationoauth_consent_grant_createdoauth_application_created
LimitsGitLab does not document per event type what the target fields hold, so confirm on one test authorization which of them names the application. A newly connected tool looks the same on its first day, and the learning period is a starting point.
Triage
- Identify who acted (
author_name,author_id,ip_address) and the user or group the event belongs to (entity_type,entity_path). - Read the target fields of the event (
target_type,target_id,target_details) and thedetailsobject for the application, then open the application to see its redirect URI and scopes. - For a new or changed application, ask the owner what it is for. A redirect URI on a domain the organization does not own needs an explanation.
- For an authorization, check whether the application is one of your own, a GitLab-provided one such as the GitLab CLI or the IDE extensions, or unknown, and ask the user whether they started the sign-in.
- Look for other users who authorized the same application, and for a sign-in of the acting account from an unseen address around that time (
user_signed_in_from_unseen_ip).
Response
Once the attack is confirmed:
- Delete an application that should not exist. GitLab deletes all grants and tokens associated with an application when the application is deleted.
- For an application you cannot delete, have each affected user revoke it in the Authorized applications section of their profile.
- Treat everything the granted scopes cover as read or changed for the time the authorization existed, and review what the user's account did through the API in that period.
- Secure the account that created, changed or authorized the application. Reset its password and second factor and end its sessions.
- Renew the secret of a legitimate application whose settings were changed, and set its redirect URI and scopes back to the approved values.
- Rotate the CI/CD variables and tokens that the affected users could read if the application held the
apiscope.
Mitigation
- Review the instance-wide applications in the Admin area and the applications of your groups on a schedule, with their redirect URIs, scopes and owners.
- Mark an instance-wide application as trusted only when it is your own, because a trusted application skips the user authorization step.
- Teach users to read the scopes on the authorization screen, and to refuse an application that asks for
api,write_repository,sudooradmin_modewithout a reason. - Ask users to review the Authorized applications section of their profile and to revoke what they do not use.
- Stream audit events to your SIEM, alert on new and changed applications, and review authorizations of applications you do not know.
Frequently asked questions
What can an OAuth application do after a GitLab user authorizes it?
It receives an access token that acts for that user within the scopes the application asked for. GitLab lists the scopes: `api` is complete read and write access to the API, including all groups and projects, the container registry, the dependency proxy and the package registry, while `read_user` is limited to the profile. The token works without the user's password.
Does the access end when the two-hour access token expires?
No. GitLab states that access tokens expire after two hours by default and that integrations generate a new token with the refresh token, which can be used even after the access token itself expires. The access ends when the user revokes the application under Authorized applications, or when the application is deleted, which deletes all of its grants and tokens.
Why is an authorization only a low-level signal?
Users authorize applications as part of normal work, for example the GitLab CLI, an IDE extension or a tool that offers sign-in with GitLab. The event type reference lists the event without its fields, so the rule cannot tell a known application from an unknown one. Use it to build a list of the applications your users authorize and review the new names.
Is there a public incident report for this technique in GitLab?
No public incident report describes this at the audit event level. The page follows what GitLab documents about OAuth applications, their scopes and their tokens. Treat the rules as a way to see every new application and every new authorization, and decide case by case whether one is expected.