Parameter injection in internal LFS API
The gitaly-lfs-smudge component failed to validate the oid field in LFS pointers, allowing an attacker to inject parameters into the internal LFS API. By crafting a malicious LFS pointer, an attacker could access private LFS objects from other projects if they knew the SHA-256 hash and project ID.
GitLab
Originally disclosed on GitLab
- Fixed in 39 days
- Disclosed after 39 days
HackerOne report #1062978 by braunske on 2020-12-20, assigned to @vdesousa:
Report | How To Reproduce
Report
Summary
gitaly-lfs-smudge doesn't properly validate the oid field in LFS pointers,
allowing arbitrary parameters to be passed to the internal LFS API.
In particular, other projects' LFS objects can be accessed via their sha256 sum.
Steps to reproduce
-
As a victim user create a private project, clone and add a file tracked by LFS:
# echo foo >bar # git lfs install # git lfs track bar # git add bar .gitattributes # git commit -m 'add lfs file' # git push -u origin master -
As a different user (attacker), create and clone another project
-
Add a fake LFS pointer file like the following:
# cat >ptr version https://git-lfs.github.com/spec/v1 oid sha256:b5bb9d8014a0f9b1d61e21e796d78dccdf1352f23cd32812f4850b878ae4944c&gl_repository=project-4# size 4 # git add ptr # git commit -m 'add fake pointer'Note the oid line. It contains not only the sha256 sum of the desired file
(needs to be known, this is the hash forfoo\n, usegit lfs pointer --file <path>otherwise) but also a parameter with the project ID (could
be bruteforced depending on instance size I suppose, for demo purposes it's
displayed below the projects' title on its main page) and a # to
neutralize the actualgl_repositorythat is appended by
gitaly-lfs-smudgelater. -
After committing the pointer, tell git to treat it as one:
# echo 'ptr filter=lfs diff=lfs merge=lfs -text' >.gitattributes # git add .gitattributes # git commit -m 'use lfs filter for ptr'This is a separate commit because we don't want the filter to be applied when
adding the fake pointer. -
Go to the settings for the attacking project, disable LFS, push, reenable
LFS. No LFS uploads should happen, you can inspect the raw uploaded pointer
while LFS is disabled. -
With LFS enabled, download an archive of the attacking repo (the button next
to clone here, endpoint/<user>/<project>/-/archive/master/<project>-master.zip).
The file that was the fake pointer should contain the (private) content it
referred to.
Notes
Tested on Debian buster using gitlab-ee 13.6.3-ee.0.
Impact
Private LFS objects can be leaked, given the hash and project ID.
Other use cases such as checking if a project contains a given file are also possible.
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
Impact
Private LFS objects could be leaked if the attacker knows the SHA-256 hash and project ID; other uses such as checking if a project contains a given file are also possible.
What the attacker needed
Victim has a private project with LFS file; attacker knows the SHA-256 hash of the file; attacker knows the project ID
How it was found
- As a victim, create a private project and add a file tracked by LFS.
- As an attacker, create another project and add a fake LFS pointer file with a crafted oid that includes a gl_repository parameter and a # to comment out the real one.
- Commit the fake pointer, then add a .gitattributes file to treat it as LFS and commit that separately.
- Disable LFS in the attacking project's settings, push, then re-enable LFS.
- Download an archive of the attacking repository; the fake pointer file will contain the private content from the victim's project.
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.
The tool did not properly validate the oid field in the pointer, so an attacker could add parameters to reach another project's private LFS files.
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.