Issues from other project can be closed via merge request description when auto-merge is enabled
When auto-merge is enabled, an attacker can edit the merge request description to reference an issue from another project, causing that issue to be closed without permission when the merge request is merged. The attacker can close issues they do not have access to.
GitLab
Originally disclosed on GitLab
- Fixed in 4 months
- Disclosed after 4 months
⚠️ Please read the process on how to fix security issues before starting to work on the issue. Vulnerabilities must be fixed in a security mirror.
HackerOne report #2781521 by xorz on 2024-10-15, assigned to GitLab Team:
Report | Attachments | How To Reproduce
Report
Summary
The doc of User responsibility when merging says " In both cases, the merge request widget shows information about the issue to close on merge", but it can be skipped and not shown to the reviewer by editing the merge request description to Closes test-group/project-b#1 when running auto merge.
Steps to reproduce
- setup a Gitlab instance with Ultimate license
** Login as Victim **
- create public project-a
- upload the CI yaml file
project-a-ci-config.ymlto.gitlab-ci.yml - create public project-b
- create an issue and copy the issue reference
test-group/project-b#1
** Login as Attacker **
- fork the
project-atoproject-a-fork - create a merge request to
project-awith a commit
** Login as Victim **
- click on
Set to auto merge
** Login as Attacker **
-
edit the merge request description to
Closes test-group/project-b#1 -
wait for the merge request to be merged
-
then you should see the
test-group/project-b#1was closed by theVictim
Impact
- Attacker can close issues without permission by editing the merge request description.
Examples
What is the current bug behavior?
- Attacker can close issues without permissions.
What is the expected correct behavior?
- Attacker should not be able to close issues without permissions.
Relevant logs and/or screenshots
Output of checks
System information
System:
Proxy: no
Current User: git
Using RVM: no
Ruby Version: 3.1.5p253
Gem Version: 3.5.17
Bundler Version:2.5.11
Rake Version: 13.0.6
Redis Version: 7.0.15
Sidekiq Version:7.2.4
Go Version: unknown
GitLab information
Version: 17.4.2-ee
Revision: e85e7bae1a9
Directory: /opt/gitlab/embedded/service/gitlab-rails
DB Adapter: PostgreSQL
DB Version: 14.11
URL: http://gitlab.test
HTTP Clone URL: http://gitlab.test/some-group/some-project.git
SSH Clone URL: [email protected]:some-group/some-project.git
Elasticsearch: no
Geo: no
Using LDAP: no
Using Omniauth: yes
Omniauth Providers:
GitLab Shell
Version: 14.39.0
Repository storages:
- default: unix:/var/opt/gitlab/gitaly/gitaly.socket
GitLab Shell path: /opt/gitlab/embedded/service/gitlab-shell
Gitaly
- default Address: unix:/var/opt/gitlab/gitaly/gitaly.socket
- default Version: 17.4.2
- default Git Version: 2.46.0
Impact
- Attacker can close issues without permission by editing the merge request description.
Attachments
Warning: Attachments received through HackerOne, please exercise caution!
How To Reproduce
Please add reproducibility information to this section:
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
How it worked
Root cause
Likely the merge request widget does not update or re-check the issues to be closed after the description is edited when auto-merge is enabled, so the victim does not see the change.
What the attacker needed
GitLab Ultimate license; Victim creates public projects; Attacker can fork project and create merge request; Victim enables auto-merge
How it was found
- Victim creates a public project and uploads a CI configuration.
- Victim creates another public project with an issue.
- Attacker forks the first project and creates a merge request.
- Victim sets the merge request to auto-merge.
- Attacker edits the merge request description to reference the issue from the other project.
- The merge request is merged and the issue is closed.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
In GitLab, a merge request can automatically close issues when it is merged if the description contains a special phrase like 'Closes #123'. Normally, the person merging sees which issues will be closed. Here, because auto-merge was set, the attacker could change the description after the victim set auto-merge, and the victim did not see the updated list of issues to be closed. So the attacker could make the merge request close an issue in a different project that they do not have permission to close.
What is Access control?
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.