Removed Developer can continue viewing the source code of a private project
A removed developer could continue viewing the source code of a private project by creating a private fork and merge requests before removal. After removal, the attacker could still see updated source code through the merge requests in their fork.
GitLab
Originally disclosed on GitLab
- Fixed in 7 days
- Disclosed after 7 days
⚠️ 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 #2082551 by theluci on 2023-07-24, assigned to @cmaxim:
Report | Attachments | How To Reproduce
Report
Hello,
Background
Gitlab provides a feature to create a fork of a project.
Gitlab also provides a feature using which Developers can create merge requests between forks.
Vulnerability
When a merge request is created from a private project victim-project to one of its forks victim-project-fork (Private project as well), Only the members of the victim-project-fork has the ability to view, edit as well as delete the merge request.
A malicious developer of victim-project can utilize the above to create a merge request from victim-project to victim-project-fork and continue viewing the source code and repository of victim-project even after malicious developer has been removed.
Attack flow looks as follows,
victimis the Owner ofvictim-projectattackeris a Developer ofvictim-project
attackercreates a private fork ofvictim-projectin his Personal namespacevictim-project-fork.attackercreates merge requests from every branch invictim-projectto their respective branches invictim-project-fork.attackeris removed fromvictim-project.victimmakes some changes invictim-project.attackergoes to the merge requests invictim-project-forkand continues to be able to view the repository and source code ofvictim-project.
Steps to reproduce
-
victimcreates a private groupvictim-groupand a private projectvictim-projectinside. -
victimgoes tovictim-groupmembership pagehttps://gitlab.com/groups/<victim-group>/-/group_membersand addsattackeras Developer. -
victimgoes tovictim-projectand creates branchanother-branch. -
attackergoes tovictim-projectand creates a private fork in his Personal namespacevictim-project-fork. -
attackergoes tohttps://gitlab.com/<victim-group>/<victim-project>/-/merge_requests/new,attackercreates a merge request fromanother-branchinvictim-projecttoanother-branchinvictim-project-forkattackercreates a merge request frommainbranch invictim-projecttomainbranch invictim-project-fork
-
victimremovesattackerfromvictim-group. -
victimgoes tovictim-projectand makes some changes inmainbranch as well asanother-branch. -
attackergoes tovictim-project-fork. -
attackergoes tohttps://gitlab.com/<attacker_username>/<victim-project-fork>/-/merge_requestsand selects the required merge request. -
attackergoes to Changes tab and is able to see the updated source code invictim-project.
As can be seen, attacker is able to view the repository and source code of victim-project.
POC
Output of checks
This bug happens on GitLab.com (Probably on instance too).
Impact
A Removed Developer can continue viewing source code of a private project
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, merge requests between a private project and its fork retain access to the source project's repository even after the user is removed from the source project.
What the attacker needed
Attacker is a Developer in the victim project; attacker creates a private fork; attacker creates merge requests before removal; victim removes attacker and updates code
How it was found
- Victim creates a private group and a private project inside it.
- Victim adds attacker as Developer to the group.
- Victim creates a branch in the project.
- Attacker creates a private fork in their personal namespace.
- Attacker creates merge requests from branches in the victim project to corresponding branches in the fork.
- Victim removes attacker from the group and makes changes to branches.
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 developer can create a copy (fork) of a project and propose changes (merge requests) between the original and the fork. Normally, when someone is removed from a project, they lose access. Here, the removed developer kept access to the original project's code through the merge requests they had created earlier.
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.