JSON serialization of any Project model results in all Runner tokens being exposed through Quick Actions
The Quick Actions interpreter allowed a user to reference a project they did not have access to, and the serialized project model returned in the JSON response exposed the runner token. An attacker could use the token to register a runner and potentially access secret project variables.
- Triaged in 1 hour
- Fixed in 7 days
- Paid in 7 days
- Disclosed after 37 days
The Quick Actions interpreter allows an attacker to reference a Project it does not have access to. The model attributes are then being serialized and returned to the user, which results in the Runner token (both encrypted and unencrypted) being returned to the user. This vulnerability is currently exploitable on GitLab.com.
Proof of concept
The vulnerability is relatively straightforward to reproduce.
- Create a project
- Create an issue
- Write
/move <full path of any other project>and click "Comment", a request to/:namespace/:project/notesis submitted - Observe the JSON response that is being returned, which contains the serialized Project model:
HTTP/1.1 200 OK
Server: nginx
...
{
"commands_changes": {
"target_project": {
"id": 11104317,
"name": " █████",
"path": "█████",
"description": "",
"created_at": "2019-03-02T01:39:34.285Z",
"updated_at": "2019-03-02T01:39:34.285Z",
"creator_id": 3627572,
"namespace_id": 4717826,
"last_activity_at": "2019-03-02T01:39:34.285Z",
"import_url": null,
"visibility_level": 0,
"archived": false,
"merge_requests_template": null,
"star_count": 0,
"merge_requests_rebase_enabled": false,
"import_type": null,
"import_source": null,
"avatar": {
"url": null
},
"approvals_before_merge": 0,
"reset_approvals_on_push": false,
"merge_requests_ff_only_enabled": false,
"issues_template": null,
"mirror": false,
"mirror_user_id": null,
"ci_id": null,
"shared_runners_enabled": true,
"runners_token": "mzssqx69THU██████████",
"build_coverage_regex": null,
"build_allow_git_fetch": true,
"build_timeout": 3600,
"mirror_trigger_builds": false,
"public_builds": true,
"pending_delete": false,
"last_repository_check_failed": null,
"last_repository_check_at": null,
"container_registry_enabled": true,
"only_allow_merge_if_pipeline_succeeds": false,
"has_external_issue_tracker": false,
"repository_storage": "nfs-file28",
"request_access_enabled": false,
"has_external_wiki": false,
"repository_read_only": null,
"lfs_enabled": true,
"only_allow_merge_if_all_discussions_are_resolved": false,
"repository_size_limit": null,
"service_desk_enabled": false,
"printing_merge_request_link_enabled": true,
"auto_cancel_pending_pipelines": "enabled",
"last_repository_updated_at": "2019-03-02T01:39:34.285Z",
"ci_config_path": null,
"disable_overriding_approvers_per_merge_request": null,
"delete_error": null,
"storage_version": 2,
"resolve_outdated_diff_discussions": false,
"remote_mirror_available_overridden": null,
"only_mirror_protected_branches": null,
"pull_mirror_available_overridden": null,
"jobs_cache_index": null,
"external_authorization_classification_label": "",
"mirror_overwrites_diverged_branches": null,
"external_webhook_token": null,
"pages_https_only": true,
"packages_enabled": true,
"merge_requests_author_approval": null,
"pool_repository_id": null,
"runners_token_encrypted": "A6nIFzMXZzDdfR5iu9hq6███████████████",
"bfg_object_map": {
"url": null
},
"merge_requests_require_code_owner_approval": null,
"import_status": "none",
"mirror_last_update_at": null,
"mirror_last_successful_update_at": null,
"import_error": null,
"import_jid": null
}
},
"valid": false,
"errors": {
"commands_only": [
"Commands applied"
]
}
}
Impact
This vulnerability gives any user who can create an Issue or comment on one the ability to obtain Runner tokens of Projects. This allows any user to register a runner for a project, which may give the attacker access to secret project variables. Given how these variables are used, this may allow an attacker to deploy arbitrary code to a victim's environment.
Context
GitLab is a web-based DevOps platform. Among its features are Issues, which carry a comment box that accepts Quick Actions: short slash commands such as /move that are interpreted when a comment is submitted and that change the state of the issue or of the project it belongs to. The Quick Actions interpreter is the component at the centre of this report.
When a Quick Action references another project, for example /move <full path of another project>, the server resolves that project and returns information about it in the JSON response to the comment request. The researcher found that this resolution did not check whether the user submitting the comment was allowed to see the referenced project, and that the serialised Project model returned in the response included the project's Runner token, both in plaintext and in its encrypted form. The report states that the vulnerability was exploitable on GitLab.com at the time.
Setup
The report does not describe any special accounts, roles, tools or versions. The only precondition that follows from the proof of concept is an account able to create a project and an issue, or to comment on an issue, and to submit a comment containing a Quick Action. The attacker does not need any access to the target project: the whole point is that the referenced project is one the attacker cannot reach.
Finding it
The researcher's observation is that the Quick Actions interpreter allows an attacker to reference a Project it does not have access to. The model attributes of that project are then serialised and returned to the user. Because the serialised Project model carries the Runner token, both encrypted and unencrypted, the token ends up in the response to an ordinary comment submission.
Exploitation
The reproduction is short and needs no tooling beyond a browser or an HTTP client.
Step 1: Create a project
Create a project of your own. This is the project that will host the issue and the comment.
Step 2: Create an issue
Create an issue in that project. The issue is the object the Quick Action will be applied to.
Step 3: Submit the /move Quick Action
Write the following in the comment box and click "Comment":
/move <full path of any other project>
This submits a request to /:namespace/:project/notes. The <full path of any other project> is the path of a project the attacker has no access to; the interpreter resolves it and applies the move command against it.
Step 4: Read the serialised Project model in the response
The response to the notes request contains the serialised Project model of the referenced project. The researcher shows it as follows (the project name and path are redacted in the report, as are parts of the tokens):
HTTP/1.1 200 OK
Server: nginx
...
{
"commands_changes": {
"target_project": {
"id": 11104317,
"name": " █████",
"path": "█████",
"description": "",
"created_at": "2019-03-02T01:39:34.285Z",
"updated_at": "2019-03-02T01:39:34.285Z",
"creator_id": 3627572,
"namespace_id": 4717826,
"last_activity_at": "2019-03-02T01:39:34.285Z",
"import_url": null,
"visibility_level": 0,
"archived": false,
"merge_requests_template": null,
"star_count": 0,
"merge_requests_rebase_enabled": false,
"import_type": null,
"import_source": null,
"avatar": {
"url": null
},
"approvals_before_merge": 0,
"reset_approvals_on_push": false,
"merge_requests_ff_only_enabled": false,
"issues_template": null,
"mirror": false,
"mirror_user_id": null,
"ci_id": null,
"shared_runners_enabled": true,
"runners_token": "mzssqx69THU██████████",
"build_coverage_regex": null,
"build_allow_git_fetch": true,
"build_timeout": 3600,
"mirror_trigger_builds": false,
"public_builds": true,
"pending_delete": false,
"last_repository_check_failed": null,
"last_repository_check_at": null,
"container_registry_enabled": true,
"only_allow_merge_if_pipeline_succeeds": false,
"has_external_issue_tracker": false,
"repository_storage": "nfs-file28",
"request_access_enabled": false,
"has_external_wiki": false,
"repository_read_only": null,
"lfs_enabled": true,
"only_allow_merge_if_all_discussions_are_resolved": false,
"repository_size_limit": null,
"service_desk_enabled": false,
"printing_merge_request_link_enabled": true,
"auto_cancel_pending_pipelines": "enabled",
"last_repository_updated_at": "2019-03-02T01:39:34.285Z",
"ci_config_path": null,
"disable_overriding_approvers_per_merge_request": null,
"delete_error": null,
"storage_version": 2,
"resolve_outdated_diff_discussions": false,
"remote_mirror_available_overridden": null,
"only_mirror_protected_branches": null,
"pull_mirror_available_overridden": null,
"jobs_cache_index": null,
"external_authorization_classification_label": "",
"mirror_overwrites_diverged_branches": null,
"external_webhook_token": null,
"pages_https_only": true,
"packages_enabled": true,
"merge_requests_author_approval": null,
"pool_repository_id": null,
"runners_token_encrypted": "A6nIFzMXZzDdfR5iu9hq6███████████████",
"bfg_object_map": {
"url": null
},
"merge_requests_require_code_owner_approval": null,
"import_status": "none",
"mirror_last_update_at": null,
"mirror_last_successful_update_at": null,
"import_error": null,
"import_jid": null
}
},
"valid": false,
"errors": {
"commands_only": [
"Commands applied"
]
}
}
The important parts of this response are:
commands_changes.target_projectholds the serialised Project model of the project named in the/movecommand, even though the commenting user has no access to it.runners_tokenis the project's Runner registration token in plaintext.runners_token_encryptedis the same token in its encrypted form.validisfalseanderrors.commands_onlycontainsCommands applied, so the response is a normal, successful reply to the comment request, not an error page.
Root cause
The Quick Actions interpreter resolves the project named in a command and serializes its model into the response, without checking that the user submitting the comment is authorised to see that project. The serialisation then includes attributes that should never leave the server for an unauthorised user, in particular runners_token and runners_token_encrypted. The report does not describe the code path or the fix.
Impact
Any user who can create an Issue or comment on one can obtain the Runner tokens of Projects. With a Runner token, a user can register a runner for the affected project. That may give the attacker access to the project's secret variables, and, given how these variables are used, may allow an attacker to deploy arbitrary code to a victim's environment. The report hedges this with "may": the outcome depends on how the victim's project uses its variables and runners.
Fix
Variants to test
- Other Quick Actions that take a project path as an argument: submit them against a project you cannot access and look for a serialised model in the JSON response.
- Other endpoints that resolve a user-supplied project reference and echo the resolved object back: check whether the response contains attributes the user should not see.
- Serialised models in general: look for token-like fields (
runners_token,runners_token_encrypted, webhook tokens) in any JSON response that includes an object the user did not directly request.
A positive result is a 200 response whose body contains the target project's attributes, especially runners_token, for a project the test account cannot open in the UI.
Hunting notes
This kind of bug tends to hide in features that accept a reference to another object by name or path and then return that object to the caller: slash commands, import and move operations, cross-project references and autocomplete endpoints. During recon, look for any request whose response embeds a full serialised model rather than a minimal summary; that is the signal that attribute-level authorisation may be missing. The researcher demonstrated impact by showing the plaintext runners_token in the response and explaining what a runner registration token allows: registering a runner for the project, which may give access to secret variables and may allow deploying arbitrary code to the victim's environment. That chain, from a single comment to a token to code deployment, is what makes the report convincing.
References
- Program: GitLab (HackerOne)
- Researcher: jobert
- Severity: critical, CVSS 9.1, Information Disclosure
- Asset: gitlab.com
- Bounty: 12,000 USD
- Disclosed: 2019-04-20
What happened, in plain words
GitLab is a website where teams keep their software projects. Each project has a comment box where people can write short slash commands, for example /move, that change things when the comment is posted. These commands are called Quick Actions.
When someone writes a Quick Action that names another project, the GitLab server looks that project up and sends information about it back in the reply to the comment. The researcher found that the server did not check whether the person writing the comment was allowed to see that other project. Worse, the information sent back was a full description of the project, and that description included the project's Runner token, both in plain text and in encrypted form.
A Runner token is a kind of password that lets a machine register itself to run jobs for a project. The report says this was exploitable on GitLab.com at the time.
Background you need first
Before walking through the steps, here are the ideas the report relies on, explained from zero.
- A web application and its API. When you use a website, your browser sends requests to a server and the server sends replies. Many modern sites also expose the same functionality as an API (Application Programming Interface): a way for programs, not just browsers, to talk to the server. The replies are often in a format called JSON, which is just structured text made of names and values, like a labelled list. Think of a restaurant menu: each dish has a name and a price, and JSON is the same idea for data.
- A request and a response. A request is what your browser sends (for example, "post this comment"). A response is what comes back (for example, "done, here is the result"). The first line of a response usually contains a status code such as
200 OK, which means the request succeeded. - A token. A token is a long random string that acts like a password or a key. If you have the token, the server treats you as entitled to whatever the token unlocks. A Runner token specifically lets a computer register as a runner: a machine that executes the automated jobs (builds, tests, deployments) a project defines.
- Encrypted versus plaintext. Encryption scrambles data so it cannot be read without the right key. Plaintext means the readable, unscrambled form. A server often stores a secret in encrypted form and only decrypts it when needed. If both forms leak, the plaintext one is immediately usable.
- Serialisation. When a server sends an object (here, a project) to a client, it converts the object into text, usually JSON. That conversion is called serialisation. The danger is that serialisation may include fields the sender never meant to expose, because the object holds more than the screen shows.
- Authorisation and visibility. Authentication is proving who you are. Authorisation is what you are allowed to do once identified. A visibility check is the part of authorisation that decides whether you may see a given project. A missing visibility check is the heart of this bug.
- The vulnerability class: Information Disclosure. This is the general name for bugs where data reaches someone who should not have it. It is not about breaking in with a password; it is about the server handing over information it should have kept back.
- The product and feature. GitLab's Issues are discussion threads attached to a project, each with a comment box. Quick Actions are slash commands typed into that box, interpreted by the server when you submit the comment.
/moveis one of them: it moves an issue to another project.
Setup
The report does not describe any special accounts, roles, tools or versions. The only precondition that follows from the proof of concept is an account able to create a project and an issue, or to comment on an issue, and to submit a comment containing a Quick Action. The attacker does not need any access to the target project: the whole point is that the referenced project is one the attacker cannot reach.
In everyday terms: you need an ordinary account on the site, nothing more. You do not need to be an administrator, and you do not need any permission on the victim's project.
Finding it
The researcher's observation is that the Quick Actions interpreter allows an attacker to reference a Project it does not have access to. The model attributes of that project are then serialised and returned to the user. Because the serialised Project model carries the Runner token, both encrypted and unencrypted, the token ends up in the response to an ordinary comment submission.
Put simply: the feature that reads your slash command also fetches the project you named, and then hands you back everything the server knows about that project, including its secrets.
Exploitation
The reproduction is short and needs no tooling beyond a browser or an HTTP client.
Step 1: Create a project
Create a project of your own. This is the project that will host the issue and the comment.
Why: you need somewhere you are allowed to write, because the attack starts from a comment you are permitted to post. Your own project is that place.
Step 2: Create an issue
Create an issue in that project. The issue is the object the Quick Action will be applied to.
Why: Quick Actions are interpreted inside issues. The issue is the container in which your slash command will be read and acted on.
Step 3: Submit the /move Quick Action
Write the following in the comment box and click "Comment":
/move <full path of any other project>
Line by line:
/moveis the Quick Action name. The leading slash tells GitLab this is a command, not ordinary text.<full path of any other project>is a placeholder for the address of a project you do not have access to. In GitLab, a project's full path looks like a namespace followed by a project name, for examplesomegroup/someproject. You replace the placeholder with the real path of the project you want to peek at.
This submits a request to /:namespace/:project/notes. The <full path of any other project> is the path of a project the attacker has no access to; the interpreter resolves it and applies the move command against it.
What the request address means: :namespace and :project are placeholders for the group and project that own the issue you are commenting on, and notes is the part of the site that handles comments. So the request is simply "add this comment to my issue", sent to the normal comment endpoint. Nothing about the request looks unusual; the trick is entirely in the text of the comment.
Why this step matters: the server reads the command, looks up the project you named, and prepares a reply describing what the command would change. That reply is where the leak happens.
Step 4: Read the serialised Project model in the response
The response to the notes request contains the serialised Project model of the referenced project. The researcher shows it as follows (the project name and path are redacted in the report, as are parts of the tokens):
HTTP/1.1 200 OK
Server: nginx
...
{
"commands_changes": {
"target_project": {
"id": 11104317,
"name": " █████",
"path": "█████",
"description": "",
"created_at": "2019-03-02T01:39:34.285Z",
"updated_at": "2019-03-02T01:39:34.285Z",
"creator_id": 3627572,
"namespace_id": 4717826,
"last_activity_at": "2019-03-02T01:39:34.285Z",
"import_url": null,
"visibility_level": 0,
"archived": false,
"merge_requests_template": null,
"star_count": 0,
"merge_requests_rebase_enabled": false,
"import_type": null,
"import_source": null,
"avatar": {
"url": null
},
"approvals_before_merge": 0,
"reset_approvals_on_push": false,
"merge_requests_ff_only_enabled": false,
"issues_template": null,
"mirror": false,
"mirror_user_id": null,
"ci_id": null,
"shared_runners_enabled": true,
"runners_token": "mzssqx69THU██████████",
"build_coverage_regex": null,
"build_allow_git_fetch": true,
"build_timeout": 3600,
"mirror_trigger_builds": false,
"public_builds": true,
"pending_delete": false,
"last_repository_check_failed": null,
"last_repository_check_at": null,
"container_registry_enabled": true,
"only_allow_merge_if_pipeline_succeeds": false,
"has_external_issue_tracker": false,
"repository_storage": "nfs-file28",
"request_access_enabled": false,
"has_external_wiki": false,
"repository_read_only": null,
"lfs_enabled": true,
"only_allow_merge_if_all_discussions_are_resolved": false,
"repository_size_limit": null,
"service_desk_enabled": false,
"printing_merge_request_link_enabled": true,
"auto_cancel_pending_pipelines": "enabled",
"last_repository_updated_at": "2019-03-02T01:39:34.285Z",
"ci_config_path": null,
"disable_overriding_approvers_per_merge_request": null,
"delete_error": null,
"storage_version": 2,
"resolve_outdated_diff_discussions": false,
"remote_mirror_available_overridden": null,
"only_mirror_protected_branches": null,
"pull_mirror_available_overridden": null,
"jobs_cache_index": null,
"external_authorization_classification_label": "",
"mirror_overwrites_diverged_branches": null,
"external_webhook_token": null,
"pages_https_only": true,
"packages_enabled": true,
"merge_requests_author_approval": null,
"pool_repository_id": null,
"runners_token_encrypted": "A6nIFzMXZzDdfR5iu9hq6███████████████",
"bfg_object_map": {
"url": null
},
"merge_requests_require_code_owner_approval": null,
"import_status": "none",
"mirror_last_update_at": null,
"mirror_last_successful_update_at": null,
"import_error": null,
"import_jid": null
}
},
"valid": false,
"errors": {
"commands_only": [
"Commands applied"
]
}
}
Line by line, in plain words:
HTTP/1.1 200 OKis the status line.200means the server accepted the request and is replying normally. This is not an error page; it is a success.Server: nginxnames the web server software that answered. The...stands for headers the report left out.- The outer braces
{and}wrap the whole JSON reply. "commands_changes"is the section describing what the Quick Action would change."target_project"is the project the command pointed at. Everything nested inside it is the serialised Project model: the full description of that project.- Fields such as
"id","name","path","created_at"and"visibility_level"are ordinary project details. The name and path are shown as█████because the report redacted them. "runners_token": "mzssqx69THU██████████"is the plaintext Runner token. The visible prefix is real; the rest is redacted. This is the field that makes the bug serious."runners_token_encrypted": "A6nIFzMXZzDdfR5iu9hq6███████████████"is the same token in encrypted form, also redacted."valid": falsetogether with"errors": { "commands_only": [ "Commands applied" ] }is the server's way of saying the command was processed. It is a normal reply, not a failure.
The important parts of this response are:
commands_changes.target_projectholds the serialised Project model of the project named in the/movecommand, even though the commenting user has no access to it.runners_tokenis the project's Runner registration token in plaintext.runners_token_encryptedis the same token in its encrypted form.validisfalseanderrors.commands_onlycontainsCommands applied, so the response is a normal, successful reply to the comment request, not an error page.
Root cause
The Quick Actions interpreter resolves the project named in a command and serializes its model into the response, without checking that the user submitting the comment is authorised to see that project. The serialisation then includes attributes that should never leave the server for an unauthorised user, in particular runners_token and runners_token_encrypted. The report does not describe the code path or the fix, so the exact location of the missing authorisation check is not stated.
In everyday terms: the door staff at the front of the building check your badge, but the side door used by the slash command does not. The command fetches the project and then copies the whole record into the reply, secrets included, because nobody asked "is this person allowed to see this?" before copying.
Impact
Any user who can create an Issue or comment on one can obtain the Runner tokens of Projects. With a Runner token, a user can register a runner for the affected project. That may give the attacker access to the project's secret variables, and, given how these variables are used, may allow an attacker to deploy arbitrary code to a victim's environment. The report hedges this with "may": the outcome depends on how the victim's project uses its variables and runners.
Why that chain matters: a runner is a machine that runs the project's automated jobs. If you can register your own machine as a runner, you may get access to the project's secret variables, and, given how these variables are used, an attacker may be able to deploy arbitrary code to the victim's environment. The report says this may happen, not that it always does.
Fix
In plain words: check the badge at every door, and do not copy secret fields into replies at all unless the person is entitled to them.
Variants to test
- Other Quick Actions that take a project path as an argument: submit them against a project you cannot access and look for a serialised model in the JSON response.
- Other endpoints that resolve a user-supplied project reference and echo the resolved object back: check whether the response contains attributes the user should not see.
- Serialised models in general: look for token-like fields (
runners_token,runners_token_encrypted, webhook tokens) in any JSON response that includes an object the user did not directly request.
A positive result is a 200 response whose body contains the target project's attributes, especially runners_token, for a project the test account cannot open in the UI.
Why these variants: the same mistake, "fetch an object the user named and send it back in full", can appear in many features. Testing them is a matter of trying each one and reading the reply carefully.
Hunting notes
This kind of bug tends to hide in features that accept a reference to another object by name or path and then return that object to the caller: slash commands, import and move operations, cross-project references and autocomplete endpoints. During recon, look for any request whose response embeds a full serialised model rather than a minimal summary; that is the signal that attribute-level authorisation may be missing. The researcher demonstrated impact by showing the plaintext runners_token in the response and explaining what a runner registration token allows: registering a runner for the project, which may give access to secret variables and may allow deploying arbitrary code to the victim's environment. That chain, from a single comment to a token to code deployment, is what makes the report convincing.
In everyday terms: whenever a website lets you type the name of something and then shows you details about it, ask yourself whether it checked that you are allowed to see those details, and whether it showed you more than the screen needed.
Glossary
- API: a way for programs to talk to a server, usually by sending requests and receiving structured replies.
- Authentication: proving who you are, for example by logging in.
- Authorisation: what you are allowed to do or see once you are identified.
- Comment endpoint: the part of the site that handles comments, here
/:namespace/:project/notes. - CVSS: a standard scoring system for the severity of a security issue; 9.1 is in the critical range.
- Encrypted: scrambled so it cannot be read without the right key.
- Information Disclosure: a class of bug where data reaches someone who should not have it.
- Issue: a discussion thread attached to a project, with a comment box.
- JSON: structured text made of names and values, used to send data between programs.
- Model: the server's internal representation of an object, such as a project, with all its fields.
- Plaintext: the readable, unscrambled form of data.
- Quick Actions: short slash commands typed into a comment box that the server interprets when the comment is submitted.
- Request: what a browser or program sends to a server.
- Response: what the server sends back, including a status code and usually a body.
- Runner: a machine that executes a project's automated jobs.
- Runner token: a secret string that lets a machine register as a runner for a project.
- Serialisation: converting an object into text, such as JSON, so it can be sent over the network.
- Status code: the number at the start of a response, such as
200, indicating the outcome. - Token: a long random string that acts like a password or key.
- Visibility check: the part of authorisation that decides whether you may see a given project.