`Prevent project forking outside current group` permission setting bypass
The 'Prevent project forking outside current group' setting was not enforced when creating a fork relationship via the API. An attacker with reporter access could create a fork outside the group and then sync updates or open merge requests to the victim project.
GitLab
Originally disclosed on GitLab
- Fixed in 3 months
- Disclosed after 3 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 #2019135 by theluci on 2023-06-09, assigned to @ottilia_westerlund:
Report | Attachments | How To Reproduce
Report
Hello,
Background
Gitlab provides a premium/ultimate feature to Prevent project forking outside current group
The permission setting can only be set by the owner of the top-level group and cannot be changed in any of the subgroups.
When permission setting is set new forks outside of the current group cannot be created

And if a member tries to create a new fork outside of the current group via intercepting the request, he is shown the following error,

Vulnerability
The permission setting is not enforced when creating a fork relationship using API.
As a result,
- An attacker can create a project outside the current group.
- Create a fork relationship between
attacker projectoutside the current group andvictim projectinside the current group. - Continue to access updated information via syncFork mutation or simply update fork functionality from UI.
- Create merge requests from
attacker projecttovictim project.
This vulnerability allows an attacker to create forks outside of the current group bypassing the setting set by the owner.
Steps to reproduce
As victim,
victimcreates a groupvictim-group.victimcreates a projectvictim-projectinvictim-group.victimgoes tovictim-groupsettings,https://gitlab.com/groups/<victim-group>/-/editand Expand Permissions and group features.victimchecks Prevent forking outside of the group and save changes.victimgoes tohttps://gitlab.com/groups/<victim-group>/-/group_membersand addsattackeras reporter in thevictim-group.
As attacker,
attackercreates a new projectattacker-projectinattacker-group
(Be sure to check the Initialize repository with a README)

attackergoes to command line and creates the fork relationship by writing the following command,
curl --request POST --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.com/api/v4/projects/<attacker_project_id>/fork/<victim_project_id>"
Replace the above values accordingly.
attackerdeletes the README file.attackerclicks on Update fork.attackerrefreshes the project.
attacker was able to create the victim-project's fork outside the victim-group and was able to bypass the Prevent forking outside of the group permission set by the victim.
Output of checks
This bug happens on GitLab.com (Probably on instance too).
Impact
Prevent project forking outside current group setting set by the owner can be bypassed by any of the members.
Attachments
Warning: Attachments received through HackerOne, please exercise caution!
How To Reproduce
Please add reproducibility information to this section:
Investigation (by @vyaklushin)
I believe the root cause of this bug is an incorrect permission check in Fork Relationship API.
We verify if users have a permission to fork user's project instead of checking the permission to fork the parent project. That allows attacker to skip this check.
We should update the permission check in API endpoint code. On top of that, let's add a permission check to Projects::ForkService to catch similar problems in future.
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
Impact
Any member with reporter access could bypass the owner's fork restriction, create a fork outside the group, and then sync updates or open merge requests to the victim project.
What the attacker needed
Victim enables fork restriction; attacker is a group member (reporter); attacker has an API token
The fix
The permission check in the API endpoint should be updated to check the parent project, and a similar check should be added to the fork service.
How it was found
- Victim creates a group and a project inside it.
- Victim enables 'Prevent forking outside of the group' in group settings.
- Victim adds the attacker as a reporter in the group.
- Attacker creates a new project in their own group.
- Attacker uses the API to create a fork relationship between their project and the victim project.
- Attacker deletes the README, clicks 'Update fork', and refreshes to see the fork.
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.
A group owner can turn on a setting that stops members from making copies (forks) of projects outside the group. The API endpoint that links two projects as a fork did not check this setting, so a member could still create a fork outside the group. This let them keep receiving updates and send merge requests to the original project.
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.