Skip to content
GitLab
Next
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • gitaly gitaly
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
    • Locked Files
  • Issues 561
    • Issues 561
    • List
    • Boards
    • Service Desk
    • Milestones
    • Iterations
    • Requirements
  • Merge requests 56
    • Merge requests 56
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
    • Test Cases
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Container Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Code review
    • Insights
    • Issue
    • Repository
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • GitLab.orgGitLab.org
  • gitalygitaly
  • Merge requests
  • !3426

git: Reject pushes into internal ref namespaces

  • Review changes

  • Download
  • Email patches
  • Plain diff
Merged Patrick Steinhardt requested to merge pks-reject-pushes-into-internal-namespaces into master Apr 29, 2021
  • Overview 15
  • Commits 2
  • Pipelines 5
  • Changes 4

Gitaly repositories host several internal ref namespaces which are used by several different parts of our application stack. These include ref namespaces for merge requests, pipelines and environments. Given that all of these represent internal state and are thus managed by GitLab, the expectation is that they shouldn't be modified by users. As it turns out, we do not have any restrictions in place though when the user performs a push: they can simply overwrite these references with their own commits.

Fix the issue by hiding those refs for git-receive-pack(1). The effect is twofold: first, these references aren't announced in the initial ref advertisement. Second, git will deny all pushes into these namespaces.

While the second property is what we're after, the first one is handy for us, too. For almost all repositories, the number of these special refs outweighs the number of normal refs by quite a bit. As an example, the initial ref advertisement of gitlab-org/gitlab results in 125,000 refs to be advertised. Of these refs, 115,000 are environments, pipelines and merge requests, and only about 10,000 are real references. Advertising this many refs makes the packfile negotiation much slower.

So by hiding these refs from the initial ref advertisement, not only do we properly protect these internal refs, but we should also see a speedup of that initial ref advertisement and thus the packfile negotiation. Win-win.

Edited Apr 29, 2021 by Patrick Steinhardt
Assignee
Assign to
Reviewers
Request review from
Time tracking
Source branch: pks-reject-pushes-into-internal-namespaces