Skip to content
Access control Disclosed report Intermediate

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 reporter or 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

  1. OWNR-A creates a private project FOO-PARENT
  2. OWNR-A invites REP-B as reporter role user in FOO-PARENT
  3. REP-B creates a fork of FOO-PARENT. Lets say FOO-FORK
  4. OWNR-A adds a new commit to FOO-PARENT for example, edits README.md file.
  5. REP-B fork FOO-FORK now show 1 commit behind from upstream msg
w1.png
w1.png From the original on GitLab
  1. REP-B creates a protected branch rule Allow to push & merge -> No one in his FOO-FORK
w2.png
w2.png From the original on GitLab
  1. REP-B uses projectSyncFork graphQL api
JSON

mutation m{  
	projectSyncFork(input:{clientMutationId:"111",projectPath:"your-grp/foo-fork",targetBranch:"main"}){  
		clientMutationId  
		errors  
		  
	}  
}


  1. The above request will results in 200 OK and the job of importing upstream repository is now queued by the Gitlab
  2. OWNR-A removes REP-B from FOO-PARENT
  3. Now, REP-B can't access FOO-PARENT or any of its new commits.
  4. OWNR-A creates or add a new file named poc.txt to the FOO-PARENT. This is a new commit in FOO-PARENT
  5. REP-B removes the protected branch rule he created in his FOO-FORK(step 6) and make the branch unprotected
w3.png
w3.png From the original on GitLab
  1. After some time, you will say that new file/commit poc.txt got 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:

The original report as published on GitLab. Images and videos are our own copies; raw HTML is shown as text. View it on GitLab.

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

  1. Owner creates a private project and invites the attacker as a reporter.
  2. Attacker forks the project and creates a protected branch rule that disallows pushes.
  3. Attacker uses the projectSyncFork API to queue a sync job.
  4. Owner removes the attacker from the project.
  5. Owner adds a new commit to the private project.
  6. 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.

More from GitLab

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Broken access control

The lesson behind this report.

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.