able to access private project data using projectSyncFork
A removed project member could still access new commits in a private project by queuing a fork sync job while having push restrictions, then removing those restrictions later to import the commits. This allowed an attacker to read private project data after being removed.
GitLab
Originally disclosed on GitLab
- Fixed in 3 days
- Disclosed after 3 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 #1895174 by vaib25vicky on 2023-03-07, assigned to GitLab Team:
Report | Attachments | How To Reproduce
Report
Summary
In case of member remove from project or project goes private then its fork are able to access new commits in the parent project using projectSyncFork.
This is possible because of how projectSyncFork works for example, projectSyncFork queue the import job and don't cancels it even after 3 days as per my testing, and this gives an attacker an opportunity to cleverly craft an attack where he uses protected branch rules in his fork and projectSyncFork to gain access to new commits when he got removed from the private project or when project goes private.
In short the attack works like
- Attacker is a member of private project, can be
reporteror any role which is allow to read code - Attacker forks this project
- Attacker creates new protected branch in his own fork and opt for
Allow to push & merge->No one - Attacker then uses projectSyncFork api to fetch upstream repository, since his fork don't allow pushes this request will be queued.
- Attacker got removed from the private project by the owner
- After say 3 days, attacker removed protected branch rules from his fork.
- Then the queued job that he created before got executed and import all latest commits which are made after attacker got removed from the project.
Steps to reproduce on Gitlab.com
Two users
owner -> OWNR-A
reporter -> REP-B
OWNR-Acreates a private projectFOO-PARENTOWNR-AinvitesREP-Bas reporter role user inFOO-PARENTREP-Bcreates a fork ofFOO-PARENT. Lets sayFOO-FORKOWNR-Aadds a new commit toFOO-PARENTfor example, editsREADME.mdfile.REP-BforkFOO-FORKnow show1 commit behind from upstreammsg

REP-Bcreates a protected branch ruleAllow to push & merge -> No onein hisFOO-FORK

REP-Buses projectSyncFork graphQL api
mutation m{
projectSyncFork(input:{clientMutationId:"111",projectPath:"your-grp/foo-fork",targetBranch:"main"}){
clientMutationId
errors
}
}
- The above request will results in
200 OKand the job of importing upstream repository is now queued by the Gitlab OWNR-AremovesREP-BfromFOO-PARENT- Now,
REP-Bcan't accessFOO-PARENTor any of its new commits. OWNR-Acreates or add a new file namedpoc.txtto theFOO-PARENT. This is a new commit inFOO-PARENTREP-Bremoves the protected branch rule he created in hisFOO-FORK(step 6) and make the branch unprotected

- After some time, you will say that new file/commit
poc.txtgot imported to the FOO-FORK` project.
You can also wait for hours or even days (i've waited for 2 days) before removing protected branch rules from your fork at step 12.
So, that you will be able to gain access more data/commits of the parent upstream repository.
I've not tested how many days we can wait but in my testing ive waited for 2 days and made several commits to parent project in this time. After two days when I removed protected branch rules from my fork, all new commits made in 2days are imported to the fork.
Impact
able to access private project data using projectSyncFork. This can be exploited in two conditions that I know
- Member remove from project then he can use this bug to gain access to new commits/data of the parent project
- Project goes private then forks of this project maybe able to gain access to new private commits/data of the parent project
Thanks!
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 projectSyncFork feature queues a sync job without re-checking the user's permissions at execution time, and the job is not cancelled when the user is removed or the project becomes private.
What the attacker needed
Attacker is a member of the private project; attacker can fork the project; attacker can create protected branch rules in fork; attacker can use projectSyncFork API
How it was found
- Owner creates a private project and invites the attacker as a reporter.
- Attacker forks the project and creates a protected branch rule that disallows pushes.
- Attacker uses the projectSyncFork API to queue a sync job.
- Owner removes the attacker from the project.
- Owner adds a new commit to the private project.
- Attacker removes the protected branch rule, and the queued job imports the new commit into 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.
When you fork a project, you get your own copy. Normally, if you're removed from the original project, you can't get new updates. But here, the attacker found a way to delay the update so it still happened after removal, letting them see new private code.
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.